'说明:现在只能加载一张图片
Private Sub Form_Load()
Dim imageRow As Long '图片所在的行
Dim imageCol As Long '图片所在的列
Dim imagHeight As Long '图片所在行的高度
Dim ImageBln As Boolean 'True 存在有图片单元格
With Grid1
'——————————————————————————————————
'说明:取得模块的基本信息
ImageBln = False
'加载文件
.OpenFile "c:/1.cel"
'判断表格是否存在有图片单元格,如果有,取得表格的宽度和高度
For i = 1 To .Rows - 1
For j = 1 To .Cols - 1
If .Cell(i, j).ImageKey <> "" Then
imageRow = i '图片所在的行
imageCol = j '图片所在的列
imagHeight = .RowHeight(i)
ImageKey = .Cell(i, j).ImageKey '图片关键字
ImageBln = True '存在图片单元格
End If
Next
Next
'取得行数
Row = .Rows - 1
'选中,并复制
.Range(1, 1, Row, .Cols - 1).Selected
.Selection.CopyData
.AutoRedraw = False
'——————————————————————————————————
'——————————————————————————————————
'说明:加载数据
For i = 1 To 10
'插入行:和选中的行数一样
.Selection.InsertRows
.Range(1, 1, Row, .Cols - 1).Selected
'选中粘贴数据
.Selection.PasteData
'判断是否存在有图片
If ImageBln Then
.Cell(imageRow, imageCol).SetImage ImageKey
.RowHeight(imageRow) = imagHeight
End If
'分页符
.HPageBreaks.Add Row + 1
Next
'——————————————————————————————————
.Refresh
.AutoRedraw = True
End With
End Sub
Private Sub Form_Load()
Dim imageRow As Long '图片所在的行
Dim imageCol As Long '图片所在的列
Dim imagHeight As Long '图片所在行的高度
Dim ImageBln As Boolean 'True 存在有图片单元格
With Grid1
'——————————————————————————————————
'说明:取得模块的基本信息
ImageBln = False
'加载文件
.OpenFile "c:/1.cel"
'判断表格是否存在有图片单元格,如果有,取得表格的宽度和高度
For i = 1 To .Rows - 1
For j = 1 To .Cols - 1
If .Cell(i, j).ImageKey <> "" Then
imageRow = i '图片所在的行
imageCol = j '图片所在的列
imagHeight = .RowHeight(i)
ImageKey = .Cell(i, j).ImageKey '图片关键字
ImageBln = True '存在图片单元格
End If
Next
Next
'取得行数
Row = .Rows - 1
'选中,并复制
.Range(1, 1, Row, .Cols - 1).Selected
.Selection.CopyData
.AutoRedraw = False
'——————————————————————————————————
'——————————————————————————————————
'说明:加载数据
For i = 1 To 10
'插入行:和选中的行数一样
.Selection.InsertRows
.Range(1, 1, Row, .Cols - 1).Selected
'选中粘贴数据
.Selection.PasteData
'判断是否存在有图片
If ImageBln Then
.Cell(imageRow, imageCol).SetImage ImageKey
.RowHeight(imageRow) = imagHeight
End If
'分页符
.HPageBreaks.Add Row + 1
Next
'——————————————————————————————————
.Refresh
.AutoRedraw = True
End With
End Sub