Vb/vb.net/c#use Excel

Source: Internet
Author: User
I have recently concentrated on the three languages used to call Excel files for presentation.
Microsoft Excel is indeed useful in some small software, such as exporting data for reports.
However, to connect the programming language to the program, the com component must be involved. Here, we will introduce offiice2000/office xp/office 2003 to you.
When Excel2000/xp is called in VB, there is *. ole file, 2000 is 9. 0. and so on, the embedded file is no longer available at 2003, and the call of Excel 2003 in VB is not studied.. net. and the class library is 1. 5. and so on. in fact, there is a namespace under com. It should be called a library at that time. you can see it clearly When referencing the file. I will not talk more about these things. enter the subject:

VB
How to reference com components is not introduced by me, and a picture is attached.
I should tell you what I said before.
Dim myexcel As New Excel. Application
Dim myworkbook As Excel. Workbook
Dim myworksheet As Excel. Worksheet
Set myworkbook = myexcel. Workbooks. Open ("c: \ test.xls ")
Myexcel. Visible = True
There are a few questions to remind you that the first line should declare a new program and instantiate it. This should be clear after learning C #.
The second line declares a variable, which should be called a reference variable. In particular, there are two types of reference: Workbook/Workbook.
Worksheet/Worksheets: the four classes are opposite to each other. If there is one more s, it indicates a combination. Generally, This is not used. However, set is used first for the four rows.
This should be called a reference value. In the future, I didn't see it. Maybe it hasn't been met yet. Why does it use the Workbooks attribute?
In fact, only one Workbook in this set is used. Why do you introduce this? Of course, it is for your own understanding.

VB.net
Below should be VB.net. I am not familiar with c ++/delphi/Java. simply look at the syntax. never used. therefore, you can only use this relatively loose language. don't laugh at it. I do. enter topic
In the. net world, it is still referenced, but I am not allowed to reference namespaces like imports. I still use the full name.
Dim excelapp As New Microsoft. Office. Interop. Excel. Application
Dim excelworkbook As Microsoft. Office. Interop. Excel. Workbook
Dim excelworksheet As Microsoft. Office. Interop. Excel. Worksheet
Excelworkbook = excelapp. Workbooks. Open ("c: \ test.xls ")
Excelapp. Visible = True
What is the difference? I have stated before.

C #
I have learned this from the Internet, but at least I still don't understand it. First, all the declarations here are interfaces, not classes.
Microsoft. Office. Interop. Excel. Application myExcel = new Microsoft. Office. Interop. Excel. ApplicationClass ();
Microsoft. Office. Interop. Excel. Workbook myWorkBook;
Object missing = System. Reflection. Missing. Value;
MyWorkBook = myExcel. workbooks. open (@ "c: \ test.xls", missing, and missing );
MyExcel. Visible = true;

If you see the difference, do not open the method. All three languages are called methods. Because no return value is returned... hey. So it is not called Han number. 555555555555.
In fact, the open method is followed by so many parameters. vb/vb.net can save some parameters. I am not sure about the reason. it should have something to do with the value. I have a poor foundation. C # cannot save parameters. The object parameter value is Misssing. value
I don't want to draw conclusions. I added @ in front of the string, and this is not clear. I hope the netizens can give an explanation.

As for how to fill the data, it is estimated that this time will not come out. I will continue to serve the. net printing settings. report making (not referring to the crystal)
I think the use of the crystal function is big, but it is always not well written by myself, in place

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.