VB.Net - 能够选择Excel电子表格 [英] VB.Net - Able to select an Excel spreadsheet
问题描述
我遇到以下问题。
我正在尝试
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屋!