Use open XML to export an Excel file by template (on)

Source: Internet
Author: User

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:

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.