rapid-spreadjs 1.0.18 → 1.0.19

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.cjs.js CHANGED
@@ -7699,11 +7699,39 @@ const SheetUtils = {
7699
7699
  },
7700
7700
  };
7701
7701
 
7702
- // 导出Excel文件所需的第三方包
7703
7702
  /**
7704
7703
  * SpreadJS工作簿工具函数属性
7705
7704
  */
7706
7705
  const WorkbookUtils = {
7706
+ /**
7707
+ * 加载在线sjs文件
7708
+ * @param spread 工作簿对象
7709
+ * @param fileUrl 在线sjs文件地址
7710
+ * @param succFunc 文件打开成功后的回调函数,返回的第一个参数为spread工作簿对象
7711
+ * @param errorFunc 文件打开失败后的回调函数,返回的第一个参数为错误信息
7712
+ */
7713
+ loadSjsFile: (spread, fileUrl, succFunc, errorFunc) => __awaiter(void 0, void 0, void 0, function* () {
7714
+ // 获取文件响应结果
7715
+ const response = yield fetch(fileUrl, { method: 'GET' });
7716
+ // 获取成功
7717
+ if (response.ok) {
7718
+ // 文件的字节流对象
7719
+ const blob = yield response.blob();
7720
+ // 将Blob转换为File或Blob对象
7721
+ new File([blob], 'template.sjs', { type: 'application/octet-stream' });
7722
+ const sjsBlob = new Blob([blob], { type: 'application/zip' });
7723
+ // SpreadJS打开文件
7724
+ spread.open(sjsBlob, () => {
7725
+ if (typeof succFunc === 'function') {
7726
+ succFunc(spread);
7727
+ }
7728
+ }, (e) => {
7729
+ if (typeof errorFunc === 'function') {
7730
+ errorFunc(e);
7731
+ }
7732
+ });
7733
+ }
7734
+ }),
7707
7735
  /**
7708
7736
  * 打印所有工作表
7709
7737
  * @param GC GC对象
@@ -7770,20 +7798,11 @@ const WorkbookUtils = {
7770
7798
  * @param spread 原始Spread对象
7771
7799
  * @param fileName 导出的文件名称,不传则为第一个工作表的名称
7772
7800
  */
7773
- exportToExcel: (GC, spread, fileName = "") => {
7801
+ exportToExcel: (GC, spread, fileName = '') => {
7774
7802
  // 导出模板为JSON对象,此处设置了参数includeBindingSource,改参数代表包含数据绑定的值
7775
7803
  const json = spread.toJSON({ includeBindingSource: true });
7776
7804
  // 需要移除的自定义公式名称集合(该变量的作用是,在导出Excel前,将工作簿中所有的自定义公式移除掉,其他内置的公式保留)
7777
- const removeCustomFormulas = [
7778
- "YJMAX",
7779
- "YJMIN",
7780
- "YJMID",
7781
- "YJGETNUM",
7782
- "YJGETS",
7783
- "YJGETCV",
7784
- "YJINTERPOLATIONMETHOD",
7785
- "YJINTERPOLATIONMETHOD_Y",
7786
- ];
7805
+ const removeCustomFormulas = ['YJMAX', 'YJMIN', 'YJMID', 'YJGETNUM', 'YJGETS', 'YJGETCV', 'YJINTERPOLATIONMETHOD', 'YJINTERPOLATIONMETHOD_Y'];
7787
7806
  // 临时工作簿
7788
7807
  const tempSpread = new GC.Spread.Sheets.Workbook();
7789
7808
  tempSpread.fromJSON(json);
@@ -7801,9 +7820,7 @@ const WorkbookUtils = {
7801
7820
  // 获取单元格的公式
7802
7821
  const cellFormula = sheet.getFormula(i, j);
7803
7822
  // 如果cellFormula不为null或undefined,则说明该单元格引用了公式
7804
- if (cellFormula != null &&
7805
- cellFormula != undefined &&
7806
- removeCustomFormulas.some((item) => cellFormula.indexOf(item) > -1)) {
7823
+ if (cellFormula != null && cellFormula != undefined && removeCustomFormulas.some((item) => cellFormula.indexOf(item) > -1)) {
7807
7824
  // 获取单元格的值
7808
7825
  const cellVal = sheet.getValue(i, j);
7809
7826
  // 移除单元格引用的公式
@@ -7818,7 +7835,7 @@ const WorkbookUtils = {
7818
7835
  }
7819
7836
  // 恢复绘制
7820
7837
  tempSpread.resumePaint();
7821
- if (fileName == "") {
7838
+ if (fileName == '') {
7822
7839
  fileName = tempSpread.getSheet(0).name();
7823
7840
  }
7824
7841
  let options = {