VB.Net - 能够选择Excel电子表格 [英] VB.Net - Able to select an Excel spreadsheet

查看:122
本文介绍了VB.Net - 能够选择Excel电子表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我遇到以下问题。



我正在尝试



1.创建2个excel工作表....能够做到这一点

2.添加标题(相同)两个工作表,例如姓名,地址

3.选择工作表并填充数组

4.当填充的记录大于20,000时,选择工作表2填充其余部分



如果只是一个工作表我就可以做到这一点,但是在尝试上述时似乎让自己感到困惑。

解决方案

我假设你有这样的代码:

  Dim  oXL  As  Excel.Application 
Dim oWB As Excel.Workbook
Dim oSheet As Excel.Worksheet
Dim oRng As Excel.Range

' 启动Excel并获取Application对象。
oXL = CreateObject( Excel.Application
oXL.Visible = True

' 获取一个新的工作簿。
oWB = oXL.Workbooks.Add
oSheet = oWB.ActiveSheet





您可以使用以下命令设置第一个工作表:

 oSheet = oWB.Sheet( 1 



和第二个:

 oSheet = oWB.Sheet( 2 


Hi,

I am having a problem with the following.

I am trying to

1. create 2 excel worksheets....able to do this
2. Add a heading (which are the same) on both worksheets e.g. Name, Address
3. Select a worksheet and populate with an array
4. When the records populated are greater than 20,000 then select worksheet 2 to populate the rest

I can do this no bother when just the one worksheet but seem to have got myself all confused when trying the above.

解决方案

Im assuming that you have some sort of code as this:

Dim oXL As Excel.Application
        Dim oWB As Excel.Workbook
        Dim oSheet As Excel.Worksheet
        Dim oRng As Excel.Range

        ' Start Excel and get Application object.
        oXL = CreateObject("Excel.Application")
        oXL.Visible = True

        ' Get a new workbook.
        oWB = oXL.Workbooks.Add
        oSheet = oWB.ActiveSheet



You can set the first sheet with the command:

oSheet = oWB.Sheet(1)


and the second by:

oSheet = oWB.Sheet(2)


这篇关于VB.Net - 能够选择Excel电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆