views:

52

answers:

1

I'm already generating an excel XML file (.xml) containing 2 worksheets.

issue #1:

the people downloading the XML file wouldn't know to open the file in Excel. (they'd complain.)

solution #1:

I rename the file to .XLS instead of .XML.

issue #2:

when opening the file in Excel i get the this error:

The file you are trying to open, ‘XXX.xls’ is in a different format than specified   by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file.

Solution #2:

Convert the XML file to XLS file somehow.

so here's where i turn to you...

Goal:

they need to be able to open the file by double-clicking it. i don't want to have to rebuild the excel file using some 3rd party library.

Ideas:

perhaps convert XML to xls using tools like the following:

http://npoi.codeplex.com/
http://excelpackage.codeplex.com/

I'd need some sample code of the simplest and LITEst way of achieving this.

any other ideas?

A: 

Just a random thought: if you're generating XML for people to open with Excel, why not generate XSL (or maby XSLX) in the first place?

nyn3x
(i'm guessing you mean xls and xlsx)A text based template is used for all other reports on the project.I don't like that this would be the only report that uses a 3rd party dll in order to generate spreadsheets, simply because it has multiple worksheets.
X-Dev
OK, for XSL you'll need some kind of component. As for XSLX you don't necessary need any 3rd party component. Basically this is just some XML in a zip-file.BTW: if you're running a web-app, you can create a HTML-table and mark the content-type of the page to application/excel and excel will be able to show the table as a spreadsheet.
nyn3x
I thing setting the content-type will not allow for multiple worksheets.unless someone else states otherwise it seems that the zip file is the way to go.
X-Dev
you're right, you won't be able to do multiple worksheets with the solution is described.
nyn3x