Click here to Skip to main content
14,776,127 members
Articles » Desktop Development » Grid & Data Controls » DataSets, DataGrids etc
Posted 8 Jun 2006


35 bookmarked

Class to transform an OFX (Microsoft Money) file into a DataSet

Rate me:
Please Sign up or sign in to vote.
2.06/5 (8 votes)
28 Jul 2010CPOL
A small class that transforms the contens of an OFX file into a DataSet.


This is my first article to CodeProject, so please be patient. I will tell you why I developed this class.

I wanted to have better control of my money, but I thought most financial programs were too complicated. So I decided to do one on my own. The problem in having my own financial program is that I don't have the patience and the memory to type my expenses one by one.

Then I saw my bank had an interesting service that exported all my expenses to an OFX file. I decided to download the file and see if I could do something with that. I opened the file in Notepad, and surprise!! The file was not binary format and it was almost a perfect XML.

What my class does is, it reads the file and makes the content a perfect XML, loads it on a DataSet and returns. Then you can manipulate the DataSet anyway you want.

Visit my homepage to see more interesting stuff:

Using the new code (LinqToXml)

XElement doc = ImportOfx.toXElement(pathToOfx);
//queryiny the XElement
var imps = (from c in doc.Descendants("STMTTRN")
            where c.Element("TRNTYPE").Value == "DEBIT"
            select new tb_import
                amount = decimal.Parse(c.Element("TRNAMT").Value.Replace("-", ""),
                data = DateTime.ParseExact(c.Element("DTPOSTED").Value, 
                                           "yyyyMMdd", null),
                description = c.Element("MEMO").Value,
                id_account = id_account

Points of interest

These are the columns inside the DataSet:

  • TRNTYPE - Type of transaction: DEBIT or CREDIT
  • DTPOSTED - Date of the transaction, formatted YYYYMMDDHHMMSS
  • TRNAMT - Amount (negative when it is a DEBIT)
  • FITID - Transaction ID CHECKNUM - Number of the check or transaction ID
  • MEMO - Small description of the transaction; very useful when you use your debit card


  • Version 2.0 - Some minor adjustments and uses .NET Framework 2.0
  • Version 3.0 - Uses Framework 3.5 and LinqToXml to return an XElement


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

rodrigo diniz
Web Developer
Brazil Brazil
I am Web Developer since 1999 , and I am a
Microsoft Certified Professional since 2005.
I work with and c# since 2003.
Extender Samples .

Comments and Discussions

NewsSite of more recente version Pin
RichardsonVix27-Nov-15 6:53
MemberRichardsonVix27-Nov-15 6:53 
GeneralStuck with linq.... Pin
psycik12-Aug-10 18:51
Memberpsycik12-Aug-10 18:51 
GeneralRe: Stuck with linq.... Pin
rodrigo diniz13-Aug-10 2:50
Memberrodrigo diniz13-Aug-10 2:50 
GeneralNew Tag Pin
Sabrina Hope1-Jul-10 6:12
MemberSabrina Hope1-Jul-10 6:12 
NewsNew version Pin
Zote8-May-09 5:26
MemberZote8-May-09 5:26 
GeneralRe: New version Pin
Jim Jewett31-Jul-09 7:39
MemberJim Jewett31-Jul-09 7:39 
GeneralRe: New version Pin
RichardsonVix27-Nov-15 6:54
MemberRichardsonVix27-Nov-15 6:54 
GeneralRe: New version Pin
Member 1505818427-Jan-21 20:30
MemberMember 1505818427-Jan-21 20:30 
GeneralSource not available Pin
Brett Swift6-Mar-09 3:21
MemberBrett Swift6-Mar-09 3:21 
GeneralRe: Source not available Pin
rodrigo diniz6-Mar-09 5:33
Memberrodrigo diniz6-Mar-09 5:33 
GeneralWorks - OFX version differences Pin
nicza6-May-08 20:39
Membernicza6-May-08 20:39 
GeneralDoes not work Pin
jimmers@codeproject14-May-07 17:54
Memberjimmers@codeproject14-May-07 17:54 
GeneralRe: Does not work Pin
rodrigo diniz1-Jun-07 3:26
Memberrodrigo diniz1-Jun-07 3:26 
GeneralRe: Does not work Pin
Member 81546635-Dec-07 5:21
MemberMember 81546635-Dec-07 5:21 
GeneralRe: Does not work Pin
Member 81546635-Dec-07 5:21
MemberMember 81546635-Dec-07 5:21 
GeneralRe: Does not work Pin
Leonardo Melo Santos15-Aug-08 18:03
MemberLeonardo Melo Santos15-Aug-08 18:03 
GeneralRe: Does not work Pin
Leonardo Melo Santos15-Aug-08 18:08
MemberLeonardo Melo Santos15-Aug-08 18:08 
Generalworks like a charm! Pin
Usarian9-Sep-06 19:59
MemberUsarian9-Sep-06 19:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.