Asp.net export Excel and set the format (1/2)

Source: Internet
Author: User

Asp tutorial. net export excel and set the format
Add reference: microsoft excel 11.0 object library;

Add: using microsoft. office. interop. excel;


1. Open an excel file ==============================

Microsoft. office. interop. excel. application excel1 = new microsoft. office. interop. excel. application ();

Workbook workbook1 = excel1.workbooks. open (@ "e: aaa.xls", type. missing, type. missing, type. missing, type. missing, type. missing, type. missing, type. missing, type. missing, type. missing, type. missing, type. missing, type. missing, type. missing, type. missing );

Excel1.visible = true;

2. Create an excel file ==============================

Microsoft. office. interop. excel. application excel1 = new microsoft. office. interop. excel. application ();

Workbook workbook1 = excel1.workbooks. add (xlwbatemplate. xlwbatworksheet or true );

Worksheet1.activate (); // activate the table sheet1

Excel1.visible = true;

3. Create an excel table ============================

Microsoft. office. interop. excel. application excel1 = new microsoft. office. interop. excel. application ();

Workbook workbook1 = excel1.workbooks. add (true );

Worksheet worksheet1 = (worksheet) workbook1.worksheets ["sheet1"];

Worksheet worksheet1 = (worksheet) workbook1.worksheets. add (type. missing, workbook1.worksheets [1], 1, type. missing );

Excel1.visible = true;

4. Rename an excel table

Microsoft. office. interop. excel. application excel1 = new microsoft. office. interop. excel. application ();

Workbook workbook1 = excel1.workbooks. add (true );

Worksheet worksheet1 = (worksheet) workbook1.worksheets ["sheet1" or 1];

Worksheet1.name = "work schedule ";

Excel1.visible = true;

Homepage 1 2 Last page
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.