Sub ExportTableToExcel(tbl As Table) ' 设置导出的Excel文件名 Dim strFileName As String strFileName = "exported_data.xlsx"
' 创建Excel对象 Dim objExcel As New Excel.Application Dim objWorkbook As Excel.Workbook Dim objWorksheet As Excel.Worksheet Set objWorkbook = objExcel.Workbooks.Add Set objWorksheet = objWorkbook.Sheets("Sheet1")
' 将表格数据导出到Excel中 Dim i As Long, j As Long, k As Long For i = 1 To tbl.Rows.Count For j = 1 To tbl.Columns.Count objWorksheet.Cells(i, j).Value = tbl.Cell(i, j).Range.Text Next j Next i