VB/VB. NET/C # How to export data to Excel

Source: Internet
Author: User

In the VB project, reference "Microsoft Excel 11.0 Object" 11.0 as the version number. It is not important. The Excel2000 is 9.0.

Declarative Variables

Dim xlApp As Excel. Application
Dim xlBook As Excel. Workbook
Dim xlSheet As Excel. Worksheet
Set xlApp = CreateObject ("Excel. Application ")

Use Template
Set xlBook = xlApp. Workbooks. Open (App. Path & "common .xls ")
On Error GoTo 0
Set xlSheet = xlBook. Worksheets (1)
XlApp. Visible = False
XlSheet. Activate

Process data and fill in an Excel table
XlSheet. Cells (3, 4) = TextQuery. Text Product Name

......


//////////////



XlApp. Visible = True display table
Set xlApp = Nothing return control to Excel
Set xlBoook = Nothing
Set xlSheet = Nothing

At this point, export to Excel is complete. In. NET, you only need to change a little to run, but the C # syntax is somewhat different.


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.