rapid-spreadjs 1.0.29 → 1.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -8092,13 +8092,22 @@ const WorkbookUtils = {
8092
8092
  * 合并多个工作簿并导出Excel(同时返回合并后的工作簿实例)
8093
8093
  * @param GC Spread的GC对象
8094
8094
  * @param spreads 工作簿实例集合
8095
+ * @param isExcel 是否导出为Excel文件,默认为true(如果为false,则导出为PDF)
8095
8096
  * @param exportName 导出的文件名称,不传则为第一个Sheet的名称
8097
+ * @param regFonts 注册的字体集合,默认注册宋体和Arial字体
8096
8098
  * @returns 合并后的工作簿实例
8097
8099
  */
8098
- mergeWorkbooksToExcel: (GC, spreads, exportName) => __awaiter(void 0, void 0, void 0, function* () {
8100
+ mergeWorkbooksToExcelOrPdf: (GC_1, spreads_1, ...args_1) => __awaiter(void 0, [GC_1, spreads_1, ...args_1], void 0, function* (GC, spreads, isExcel = true, exportName, regFonts = [
8101
+ { name: '宋体', type: 'normal', url: '/spreadJsFonts/simsun.ttf' },
8102
+ { name: 'Arial', type: 'normal', url: '/spreadJsFonts/arial.ttf' },
8103
+ ]) {
8099
8104
  if (!spreads || spreads.length == 0) {
8100
8105
  return;
8101
8106
  }
8107
+ // 导出PDF的时候,注册字体(必须在初始化Workbook前注册)
8108
+ if (!isExcel) {
8109
+ yield WorkbookUtils.registerFont(GC, regFonts);
8110
+ }
8102
8111
  // 主工作簿
8103
8112
  const mainWorkbook = new GC.Spread.Sheets.Workbook();
8104
8113
  // 暂停绘制
@@ -8168,10 +8177,30 @@ const WorkbookUtils = {
8168
8177
  mainWorkbook.options.showVerticalScrollbar = true;
8169
8178
  // 滚动条是否与活动工作表的最后一行和最后一列对齐(避免滚动的时候出现灰色区域)
8170
8179
  mainWorkbook.options.scrollbarMaxAlign = false;
8180
+ // 导出PDF时
8181
+ if (!isExcel) {
8182
+ // 获取最后一个要打印的PDF工作表
8183
+ const pdfSheet = mainWorkbook.getSheet(mainWorkbook.getSheetCount() - 1);
8184
+ let printInfo = pdfSheet.printInfo();
8185
+ printInfo.margin({ top: 0, bottom: 0, left: 0, right: 0, header: 0, footer: 0 });
8186
+ printInfo.showBorder(false);
8187
+ printInfo.showGridLine(false);
8188
+ printInfo.blackAndWhite(false);
8189
+ printInfo.showRowHeader(GC.Spread.Sheets.Print.PrintVisibilityType.hide);
8190
+ printInfo.showColumnHeader(GC.Spread.Sheets.Print.PrintVisibilityType.hide);
8191
+ printInfo.zoomFactor(1.06); //1.06
8192
+ }
8171
8193
  // 恢复绘制
8172
8194
  mainWorkbook.resumePaint();
8173
8195
  // 导出Excel文件
8174
- WorkbookUtils.exportToExcel(GC, mainWorkbook, exportName);
8196
+ if (isExcel) {
8197
+ WorkbookUtils.exportToExcel(GC, mainWorkbook, exportName);
8198
+ }
8199
+ else {
8200
+ mainWorkbook.savePDF(function (blob) {
8201
+ saveAs(blob, `${exportName && exportName.length > 0 ? exportName : '文件'}.pdf`);
8202
+ }, console.log);
8203
+ }
8175
8204
  return mainWorkbook;
8176
8205
  }),
8177
8206
  /**