转换为 HTML 后单元格上方的图像中断

Image over cell breaks after conversion to HTML

我在 select 单元格上添加图像,图像完美地添加在单元格上,但是当我将 sheet 转换为 html 时,图像中断 这是我用来在单元格上添加图像的代码

Public Function SetImage(tag As String)
'tag is the selected image path
    On Error GoTo ErrHandler:

      Dim shp, rng As Range

    Set rng = Range(Selection.Address)

    Set shp = ActiveSheet.Pictures.Insert(tag)

    With shp
        .Top = rng.Top
        .Left = rng.Left
        .ShapeRange.LockAspectRatio = msoTrue
        .Width = .Width / Application.Max(.Width / rng.Width, _
                                          .Height / rng.Height)
                                          Visible = True
    End With
    Exit Function
ErrHandler:
    ShowErrorInfo ("SetTag")
End Function

这是这个函数的结果

但转换后图片在网页中显示为

Excel 像这样转换图像。 我正在使用 mocrosft 互操作库将 excel sheet 转换为网页

找到解决办法: 添加图片作为形状解决了问题

Set rng = Range(Selection.Address)
ActiveSheet.Shapes.AddPicture Filename:=tag, linktofile:=msoFalse, _
savewithdocument:=msoCTrue, Left:=rng.Left, Top:=rng.Top, Width:=rng.Width, Height:=rng.Height