本帖最后由 Richard.Huang 于 2024-4-11 15:51 编辑
产品:SpreadJS
版本:V17.0.6
使用spread.export方法导出excel文件,但是不能导出绑定的数据,而是把模板的数据导出了。
已经设置includeBindingSource: true
我的需求是把多个spread对象合并成一个spread导出至同一个excel文件的不同sheet中。
- <div>
- <div> for (let i = 0; i < spreadRefs.length; i++) {
- const tempSpread = spreadRefs[i];
- const sheetCount = tempSpread.getSheetCount();
- for (let j = 0; j < sheetCount; j++) {
- const sheet = tempSpread.getSheet(j);
- let sheetJSON = JSON.stringify(sheet.toJSON());
- const newSheet = new GC.Spread.Sheets.Worksheet('sheet' + i + '_');
- newSheet.fromJSON(JSON.parse(sheetJSON));
- newSheet.name(sheetNames[i]);
- spread.addSheet(spread.getSheetCount(), newSheet);
- }
- }
- spread.removeSheet(0);
- spread.export(
- function (blob: any) {
- saveAs(blob, 'test.xlsx');
- },
- function () {
- },
- {
- fileType: GC.Spread.Sheets.FileType.excel,
- includeBindingSource: true,
- includeStyles: true,
- includeFormulas: true,
- saveAsView: false,
- rowHeadersAsFrozenColumns: false,
- columnHeadersAsFrozenRows: false,
- includeUnusedNames: false,
- includeEmptyRegionCells: false,
- includeAutoMergedCells: false,
- includeCalcModelCache: false,
- },
- );</div></div>
复制代码 |