作者在 2021-06-02 07:23:18 发布以下内容
oExcel = CREATEOBJECT('Excel.Application')
WITH oExcel
.Workbooks.Add(-4167)
* 添加测试数据
.ActiveSheet.Cells(2, 2).Value = "abcd"
.ActiveSheet.Cells(4, 4).Value = "abcd"
.ActiveSheet.Cells(6, 6).Value = "abcd"
.ActiveSheet.Cells(100, 10).Value = "ABCD"
*删除空白行
lnRow = .ActiveSheet.UsedRange.Rows.Count
FOR lnj = lnRow TO 1 STEP - 1
IF .WorksheetFunction.CountA(.Rows(lnj)) = 0
.Rows(lnj).Delete
ENDIF
ENDFOR
*删除空白列
lnCol = .ActiveSheet.UsedRange.Columns.Count
FOR lnj = lnCol TO 1 STEP - 1
IF .WorksheetFunction.CountA(.Columns(lnj)) = 0
.Columns(lnj).Delete
ENDIF
ENDFOR
.Visible = .T.
ENDWITH