|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Private Sub CommandButton6_Click()
Dim fileOpenName
fileOpenName = Application.GetOpenFilename("excel文件(*.xls*),*.xls")
If fileOpenName = False Then Exit Sub
fs = fileOpenName
Set wb = Workbooks.Open(fs)
Dim lst As ListItem
arr = wb.Worksheets(1).[a1].CurrentRegion
wb.Close fasle
With Me.ListView1
For j = 2 To UBound(arr, 2)
.ColumnHeaders.Add , , arr(2, j), 110
Next
'设置标题行
.CheckBoxes = True
.Gridlines = True
.View = lvwReport '报表视图
.Gridlines = True '显示网格线
.Font.Size = 12 '设置字号为9号
.FullRowSelect = True '整行选择
.BackColor = 155
'设置视图
For k = 3 To UBound(arr)
Set lst = .ListItems.Add()
lst.Text = arr(k, 2)
For m = 3 To UBound(arr, 2)
lst.SubItems(m - 2) = arr(k, m)
Next
Next
'添加记录
Set .SelectedItem = .ListItems(1)
'选择第一条记录
End With
Set lst = Nothing
End Sub
|
|