1
votes

In my application I already have functionality to export into 2003 format. Where I am constructing a string out of the template and write using System.IO.File.WriteAllText.

But it does not work with excel 2007/2010, that's why I wanted to convert it to Openxml in order to support 2007 and 2010.

I have string ready with creation of cells and rows from template.

I want advice on how to achieve or any body has reference link.

Please let me know.

Regards

1
Have you tried the Office Interop Excel API to create a workbook? - Haris
@Haris That solution is almost as worse as his current solution: slow, unmainnatable, random errors, and prone to hangs. Use a library like EPPLUS, which can write native xlsx files in milliseconds and has a nice API, something which cannot be said of the native Office Open XML library - Christian Sauer

1 Answers

1
votes

WriteAllText class will save you a text file. You are saving an html(text) based file with xls extension. This is not a real xls file (that is actually a binary file), but MS Excel recognize and interpret the html format.

An xlsx file is a binary file. You can use OpenXML Office library ( Excel.XlFileFormat.xlOpenXMLWorkbook ) or another .NET Excel library like EasyXLS. Check this sample of code for more details.