C # Implementing Import and Export of Excel

Source: Internet
Author: User

Excel, as a daily use tool, often uses its import and export capabilities during the development process. After a little exercise, I learned the following import and export function.

Export article:

From the database query to the data to be exported, in the context of XML saved, and finally output the format of Excel, save it.

The first is the header that generates the XML

Create columns

Create rows

Create cells

XmlDocument xd = new XmlDocument ();

String tabletitle = Xmlsheet ();

Xd. LOADXML (Tabletitle);

XmlNodeList NodeList = xd. Documentelement.getelementsbytagname ("Worksheet");//Get XML Worksheet node, there may be multiple.

Import article:

PS: Exported Excel as a template error prone, it is best to create a new Excel as a template, import just test to get a DataTable, the rest of the data needed to filter according to their own needs, the import process may have empty data, later need to pay attention to. If the imported Excel suffix name is. xlsx, it is possible to report that the "microsoft.ace.oledb.12.0" provider is not registered on the local computer. need to download driver, drive connection address http://download.microsoft.com/download/7/0/3/703ffbcb-dc0c-4e19-b0da-1463960fdcdb/ AccessDatabaseEngine.exe.

The process of writing must have a lot of shortcomings, we have many pointers ...

C # Implementing Import and Export of Excel

Related Article

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.