我需要以特定格式导出文件,目前我只是将查询导出为 excel 文件:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryReport", "path" & "name.xls"
这会导致这样的 excel 文件:
Name,Age,Sex
Bob,47,M
Janet,30,F
William,23,M
qryReport 是一个简单的选择查询。
现在我需要以不同的格式导出它,每个文件应该只有一条记录,如下所示:
_begin_file_
name=Bob
Age=47
Sex=M
列现在是行。我正在考虑将查询重写为这样的
Select "name=" & name as "_begin_file_" from clients
Where name = [whatever] UNION ALL
Select "Age=" & age as "_begin_file_" from clients
Where name = [whatever] UNION ALL
Select "Sex=" & sex as "_begin_file_" from clients
Where name = [whatever]
他们会每次导出一条记录吗?
有没有更好的办法?