谢谢,这个代码是有效的。现在我是想解决这个问题:
在窗口的某个标签的背景色,设置为与这个EXCEL单元格一样的背景色。
一直不成功(标签背景色不显示)。我的代码是这样的,能帮看下吗?(已事先定义:_app1 = New MSExcel.Application '定义一个EXCEL对象)
Dim r As Integer = _app1.ActiveCell.Row '定义行号
Dim l As Integer = _app1.ActiveCell.Column '定义列号
Dim dz As String = e.Form.Controls("Label4").text ‘这个文件的地址是有的。
Dim Book As New xls.Book(dz) ' 定义一个XLS对象
Dim Sheet As xls.Sheet = Book.Sheets(e.Form.Controls("Label12").text) '定义一个sheet表
Dim Style As xls.Style = Sheet(r,l).Style '确定当前单元格的样式
Dim ys As String = Style.BackColor.toARGB
Dim ysbj As WinForm.Label = e.Form.Controls("Label01")
Dim clr As Color = Color.FromARGB(ys)
ysbj.BackColor = clr ’ 显示标签背景色