Setting up VB.NET to work with Excel

Setting up VB.NET to work with Excel,第1张

概述Click on File and click on New Project. Under Visual basic, Select “Windows” and then select “Windows Form Application”. Give the project an appropriate name and select a location where you want to sa

Click on file and click on New Project. Under Visual basic,Select “windows” and then select “windows Form Application”. Give the project an appropriate name and select a location where you want to save this project.

When the project opens you will be presented with Form1. For the time being just lets create 3 buttons and name then “Create”,“Open”,“Cancel”. Give an appropriate heading to the form. Your form should look like this.

Now let’s set references for Excel in our project. For this click on the menu Project~~>Add Reference. You will be presented with a “Add Reference”-dialog Box. Navigate to the “COM” Tab and select the Microsoft Excel Object library.

After setting the reference,double click on any of the button to open the Form1 Code Area and paste this line of code at the very top.

imports Excel = Microsoft.Office.Interop.Excel
在.Net标签中可以找到
Microsoft.Office.Interop.Excel
Microsoft.Office.Tool.Excel
将这些都加入进来

Double-click on the third button “Cancel” and paste the code. This is how your code should look like.

imports Excel = Microsoft.Office.Interop.Excel Public Class Form1 Private Sub button3_Click( ByVal sender As System. Object , ByVal e As System.EventArgs) Handles button3.Click Me .Close() End Sub End Class

And you are all set for automating Excel From VB.Net.

总结

以上是内存溢出为你收集整理的Setting up VB.NET to work with Excel全部内容,希望文章能够帮你解决Setting up VB.NET to work with Excel所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1272333.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-08
下一篇 2022-06-08

发表评论

登录后才能评论

评论列表(0条)

保存