tags:

views:

276

answers:

4

I have a xml document holding a small data for my project where I want to convert my xml to an excel file (microsoft office excel 2003 and over)

How can I do this programmatically?

A: 

How to open an XML file in Excel 2003.

In short, you can simply open it by using FileOpen. Then, when you select an XML file, you are prompted to select one of the following methods to import the XML data:

  • As an XML list
  • As a read-only workbook
  • Use the XML Source task pane
Mathias Bynens
i know that, thanks; but I need a code to do it as I told below. msdn documents were old I found and too complicated to understand :(
Cmptrb
A: 

Can't you simply open it in Excel? I thought Excel recognized the suffix XML?

MJB
xml file can be easily opened in excel. the reason to convert xml file via a program is to open xml file in sheets in excel more ordinarily. either it's not easy to say people here is your document in xml please open it with excel. To change the file extension does not works too.
Cmptrb
Late to the party, but I'm not sure I understood your explanation. I think you are saying that you want to do it with code. But I don't know what you mean by "the reason to convert is to open ... more ordinarily". I have no clue what that means.
MJB
A: 

If you have control over the XML generated, just generate an XML Spreadsheet file (the XML file standard for Excel 2002 and 2003).

These open natively in Excel, without having to change the extension. (To open by default in Excel, the file extension XML should be set to open with "XML Editor", which is an Office app that routes the XML file to Excel, Word, PowerPoint, InfoPath, or your external XML editor as needed. This is the default mapping when Office is installed, but it may be out of whack for some users, particularly devs who edit XML files in a text editor.)

Or, use the NPOI library to generate a native (97/2000 BIFF/XLS) Excel file rather than XML.

richardtallent
yes, opening xml with excel is okey, but I want to have my xml file as an excel file where I would write on excel small macro to work on.
Cmptrb
A: 

you can even read the XML file as string and use regular expressions to read the content between the tags and create a CSV file or use xpath expressions to read the XML file data and export to CSV file.

Laxmikanth Samudrala