Create OFX Request Files via C#
OFX request files creation without needing Microsoft Office installed or any other software.
How to Create OFX Request Files
After having the OFX Request files creation requirements within your application, Follow the steps in code snippet or enhance it as of your requirement.
- Create OfxRequestDocument class object.
- Assign the relevant properties using different classes provided by API like SignonRequest , FinancialInstitution , StatementTransactionRequest
- Use the ofxVersion V2x or V1x for xml and sgml files respectively from OfxVersionEnum as parameter in Save method.
- Call the Save method by providing the target file and ofxVersion.
Creation Requirement
To proceed for OFX Request file creation, .NET Finance API is the main requirement to be included within report generation application.
Install it via command line as
nuget install Aspose.Finance
or via Package Manager Console of Visual Studio withInstall-Package Aspose.Finance
.Alternatively, get the offline MSI installer or DLLs in a ZIP file from downloads .
C# code for OFX request files creation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string outputPath = RunExamples.Get_OutputDirectory(); | |
OfxRequestDocument ofxRequestDoc = new OfxRequestDocument(); | |
ofxRequestDoc.SignonRequestMessageSetV1 = new SignonRequestMessageSetV1(); | |
SignonRequest signonRequest = new SignonRequest(); | |
ofxRequestDoc.SignonRequestMessageSetV1.SignonRequest = signonRequest; | |
signonRequest.ClientDate = "20200611000000"; | |
signonRequest.UserId = "aspose"; | |
signonRequest.UserPassword = "password"; | |
FinancialInstitution fi = new FinancialInstitution(); | |
fi.Organization = "aspose"; | |
fi.FinancialInstitutionId = "1"; | |
signonRequest.FinancialInstitution = fi; | |
signonRequest.AppVersion = "1.0"; | |
signonRequest.AppId = "Aspose.Finance"; | |
signonRequest.ClientUserId = "aaaaaaa"; | |
ofxRequestDoc.BankRequestMessageSetV1 = new BankRequestMessageSetV1(); | |
StatementTransactionRequest stmtTransRequest = new StatementTransactionRequest(); | |
ofxRequestDoc.BankRequestMessageSetV1.StatementTransactionRequests.Add(stmtTransRequest); | |
stmtTransRequest.TransactionUniqueId = "1111111"; | |
stmtTransRequest.StatementRequest = new StatementRequest(); | |
stmtTransRequest.StatementRequest.BankAccountFrom = new BankAccount(); | |
stmtTransRequest.StatementRequest.BankAccountFrom.BankId = "sssss"; | |
stmtTransRequest.StatementRequest.BankAccountFrom.AccountId = "sfsdfsfsdf"; | |
stmtTransRequest.StatementRequest.BankAccountFrom.AccountType = AccountEnum.CHECKING; | |
stmtTransRequest.StatementRequest.IncTransaction = new IncTransaction(); | |
stmtTransRequest.StatementRequest.IncTransaction.StartDate = "20200601000000"; | |
stmtTransRequest.StatementRequest.IncTransaction.EndDate = "20200611000000"; | |
stmtTransRequest.StatementRequest.IncTransaction.Include = true; | |
ofxRequestDoc.Save(outputPath + @"newOfxRequestBankStatement.xml", OfxVersionEnum.V2x); | |
ofxRequestDoc.Save(outputPath + @"newOfxRequestBankStatement.sgml", OfxVersionEnum.V1x); |
Other Creation Options
OFX Response File (1.03 or 2.2 Format)
XBRL File (Extensible Business Reporting Language)