I have some data in c#, and I want to put this data into Excel. I figure the easiest way is to export it as XML since Excel reads xml files.
What’s the easiest way to do this? I don’t know what format the xml needs to be in for Excel to read it. I want a simple table of data (headers, data, and totals, although the totals I can simply generate in c# rather than have excel do it).
There might also be a better way without using xml, but simplest is best and definitely no 3rd party stuff…
Ideas?
There’s a nice intro at http://www.codeproject.com/KB/office/excelxmlspreadsheet.aspx that should get you started writing basic XML spreadsheets.
You may want to reconsider using 3rd party tools; there are some nice ones out there with good licenses that will make your life a lot easier.
I’ve used http://www.carlosag.net/Tools/ExcelXmlWriter/ previously to write simple data to an Excel spreadsheet. It outputs right into the Excel XML format you mention.
I’ve also had success using Apache POI HSSF, though not its most recent incarnation (it lacked Office 2007 support at the time). You can use IKVM to recompile the Java library into a .NET library, and you’re good to go.