feat(export): support multi-result xlsx export

This commit is contained in:
t8y2 committed 2026-06-19 14:05:08 +08:00
1 parent 1a5e2d6247
commit 954dba1e13
17 files changed
+477 -51

No files matched your search

+15
View File
@@ -1310,6 +1310,21 @@ export async function exportQueryResultXlsx(filePath: string, sheetName: string
URL.revokeObjectURL(url);
}
export async function exportQueryResultsXlsx(filePath: string, worksheets: readonly { sheetName?: string; columns: string[]; rows: readonly (readonly XlsxCellValue[])[] }[]): Promise<void> {
const { buildXlsxWorkbookMulti } = await import("./xlsxExport");
const workbook = buildXlsxWorkbookMulti(worksheets);
const fileName = filePath.split(/[\\/]/).pop() || "export.xlsx";
const blob = new Blob([new Uint8Array(workbook)], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
});
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = fileName;
a.click();
URL.revokeObjectURL(url);
}
export async function exportQueryResultJson(filePath: string, columns: string[], rows: readonly (readonly XlsxCellValue[])[]): Promise<void> {
const result = await post<{ content: string }>("/api/export/query-result-json", { columns, rows });
downloadTextFile(filePath, "export.json", result.content, "application/json;charset=utf-8");