2
votes

I have a small wpf product which requires exporting data to excel with out excel installed on the client machine.How to achieve this in C#.After exporting, this excel can be opened by Open office. All I wanted is to save excel file to the client hard disk. Even excel is not installed he should be able to save the file,he may not be read it without excel but should be able to save. I dont want to any 3rd party or some other open xmls. Recently I downloaded a product which is able to export to excel without excel installed and able to open it with open office.

When i checked their binaries they contain office.dll ,Microsoft.Vbe.Interop.dll and Microsoft.Office.Interop.Excel.dll's only .I want to know how they are able to manage with these dlls.

I have already written code for this but its breaking when excel is not installed.

I have read many open xml and other stuff relating to this but not satisfied. My requirement is too simple ,just exporting datatable data to excel,no reading back the data and no fancy oparations with excel.

Please give me suggestions and links will be appreciated. Thanks in advance

3
Write a comma separated value file and read it with excel. - Steve
Steve's option is good and ClosedXML has worked for me if you need it closedxml.codeplex.com - kenny
I understand what Sateesh tries to accomplish here. Maybe you also need to add that the person who is going to use the application doesn't understand how it all works, creating a csv file for such user will just twinkle it's eyebrows because he doesn't know how to handle it. The same with creating a new xml file. It's important for a programmer to know that a user who doesn't program will never understand what we mostly of the time find extremely logic. - Schuere
@Schuere Really a CSV is confusing? A .csv file has an Excel icon and opens in Excel if you double click. - paparazzo
@Blam, i was simply referring to a user who doesn't has office installed, whereas he will not see an excel icon. My post was specific for that group. I do apologize for the inconvenience. - Schuere

3 Answers

2
votes

Either work out with CSV format or you may like to use EPPlus library. See similar answer here

1
votes

xslt transformation can also to the job. i use it to export wpf datagrid data.