For more information, see my website http://www.iyummy.com.cn/Blog/Detail/3
In our application system, we often need to export the data in the database into an Excel file. If you want to export a report, it is best to generate a beautiful Excel File Based on the defined template.
Previously, a style Excel file was generated. Generally, you can modify an Excel file in XML format or use an Excel API. The former is especially troublesome to modify the style, and the latter will initiate many processes in Asp.net.
Fortunately, Microsoft has used openxml to define office files since Office 2007. Decompress the XLSX file using RAR. You can see a lot of XML files. Here I will not explain the content and meaning of each file. For more information, see the Microsoft manual. The following describes how to use the open xml sdk to manipulate the content of these XML files and export database data to an Excel file.
Preparations:
1. Install open XML SDK
Http://www.microsoft.com/en-us/download/details.aspx? Id = 30425
There are two files: one is the SDK and the other is the tool. You can see how to use the SDK to generate an XLSX.
2. install Excel
You do not need to use Excel to create a template.
Process: