OPEN XML to Export 2007/2010

两盒软妹~` 提交于 2019-12-30 11:35:43

问题


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:


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.



来源:https://stackoverflow.com/questions/24199859/open-xml-to-export-2007-2010

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!