我通过查询来导出的, 因为导出的格式基本一样,所以主要设置好查询的字段就基本满足查询的数据的要求
Dim StrExcelName As String
Dim StrFilename As String
StrFilename = Me.TxtCcode & "总表.xls"
StrExcelName = CurrentProject.Path & "\ExcelFile\" & StrFilename
If Dir(StrExcelName) <> "" Then
Kill StrExcelName
End If
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "汇总报表", StrExcelName, True