Dim rg As MSExcel.Range
Dim tempWs = wb.WorkSheets.Add
Dim tempCell As MSExcel.Range = tempWs.Cells(1, 1)
Dim Strike As Boolean
For Each rg In ws.UsedRange
If rg.MergeCells AndAlso rg.MergeArea.Columns.count>1 Then
'' rg.Font.Strikethrough = Strike '设置删除线
Dim width As Double = 0
Dim tempCol
For Each tempcol In rg.MergeArea.Columns
width = width + tempcol.ColumnWidth
Next
tempWs.Columns(1).WrapText = True
tempWs.Columns(1).ColumnWidth = width
tempWs.Columns(1).Font.Size = rg.Font.Size
tempcell.Value = rg.Value
tempcell.RowHeight = 0
tempcell.EntireRow.Activate
tempcell.EntireRow.AutoFit
If (rg.RowHeight < tempcell.RowHeight) Then
Dim tempHeight As Double
Dim tempCount As Integer
tempHeight = tempcell.RowHeight
tempCount = rg.MergeArea.Rows.Count
For Each addHeightRow As object In rg.MergeArea.Rows
If (addHeightRow.RowHeight < tempHeight / tempCount) Then
addHeightRow.RowHeight = tempHeight / tempCount + 10
End If
tempHeight = tempHeight - addHeightRow.RowHeight
tempCount = tempCount - 1
Next
rg.WrapText = True
End If
End If
Next
app.DisplayAlerts = False
tempWs.Delete
app.visible = True
catch ex As exception
msgbox(ex.message)
app.quit
End try