发布网友 发布时间:2022-04-21 07:31
共3个回答
热心网友 时间:2022-06-18 17:42
单纯的说怎么读取很简单,假设你的控件名称为A,则 A.text = “sheet1.cells(2,2).value”
下面给出VB.NET 的完整代码:
Public Class Form1热心网友 时间:2022-06-18 17:42
Private Sub Command1_Click()
Dim A As Integer
Dim scxls As New excel.Application
Dim scbook As excel.Workbook
Dim scsheet As excel.Worksheet
Set scxls = CreateObject("excel.application") '创建EXCEL对象
scxls.DisplayAlerts = False '不显示对话框,如果D:\2\1\3.xls文件已存在,让它不出现这个提示,就需加这段代码。
Set scbook = scxls.Workbooks.Open("D:\2\4.xls")
'Set scbook = scxls.Workbooks.Add '新建EXCEL工件簿文件
Set scsheet = scbook.Worksheets(1) '设置活动工作表
scxls.Visible = True '显示Excle
Text1.Text = scsheet.Cells(2, 2) '读取数据 并在text1里显示
Text2.Text = scsheet.Cells(2, 6) '读取数据 并在text1里显示
scsheet.SaveAs ("D:\2\1\3.xls") 'excel 存档 语法:表达式.SaveAs(FileName, FileFormat, Password, WriteResPassword, ReadOnlyRecommended, CreateBackup, AccessMode, ConflictResolution, AddToMru, TextCodepage, TextVisualLayout, Local)
scxls.Quit 'excel 关闭
End Sub
热心网友 时间:2022-06-18 17:43
range("xx").value或者 cells(x,x).value