Import data to excel from Datagride in VB

Source: Internet
Author: User


It takes me a long time to find the program on the Internet. I just wrote the program and added comments to it, hoping to help you.
Reference before writing a program
Microsoft excel 11.0 object Library
The article I see is 10.0. Here I am office2003 and 11.0. As long as excel is installed, there will be this reference ~
Private Sub cmdsave_Click ()
MsgBox "file saved as: D: electrical network distribution circuit Management Information System Information Query Result Accident Information Query Result .xls"
Dim I As Integer
Dim j As Integer
Dim ex As Object
Dim exwbook As Object
Dim exsheet As Object

Set ex = CreateObject ("Excel. Application ")
Set exwbook = Nothing
Set exsheet = Nothing
Set exwbook = ex. Workbooks (). Add
Set exsheet = exwbook. Worksheets ("sheet1 ")

'Table header in excel. This is the header added according to my needs.
Ex. Range ("c3"). Value = "date"
Ex. Range ("d3"). Value = "time"
Ex. Range ("e3"). Value = "Site"
Ex. Range ("f3"). Value = "Reporter"

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.