rapid-spreadjs 1.0.17 → 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.esm.js CHANGED
@@ -7095,6 +7095,10 @@ const EChartsUtils = {
7095
7095
  * @param isHideChart 是否隐藏图表
7096
7096
  */
7097
7097
  initChart: (spread, sheet, config, isHideChart = false) => {
7098
+ // 此时可能ECharts所在的div还没有渲染(如浮动元素还没有在可视区域的时候是不会创建的)
7099
+ if (document.getElementById(config.chartId + '_ec') == null) {
7100
+ return null;
7101
+ }
7098
7102
  // 获取多条x轴的数组(类似[[1,2,3,4],[1,2,3,4]])
7099
7103
  let xDataArr = [], yDataArr = [];
7100
7104
  // 获取多条x轴的数组(单元格原始数据,类似[['1.0','2.0','3.0'],['1.0','2.0','3.0']],此数据可能在有些情况下需要使用原始数据,如:原始数据为字符串的1.0,可能需要在x轴显示为1.0这个字符文本)
@@ -7673,11 +7677,39 @@ const SheetUtils = {
7673
7677
  },
7674
7678
  };
7675
7679
 
7676
- // 导出Excel文件所需的第三方包
7677
7680
  /**
7678
7681
  * SpreadJS工作簿工具函数属性
7679
7682
  */
7680
7683
  const WorkbookUtils = {
7684
+ /**
7685
+ * 加载在线sjs文件
7686
+ * @param spread 工作簿对象
7687
+ * @param fileUrl 在线sjs文件地址
7688
+ * @param succFunc 文件打开成功后的回调函数,返回的第一个参数为spread工作簿对象
7689
+ * @param errorFunc 文件打开失败后的回调函数,返回的第一个参数为错误信息
7690
+ */
7691
+ loadSjsFile: (spread, fileUrl, succFunc, errorFunc) => __awaiter(void 0, void 0, void 0, function* () {
7692
+ // 获取文件响应结果
7693
+ const response = yield fetch(fileUrl, { method: 'GET' });
7694
+ // 获取成功
7695
+ if (response.ok) {
7696
+ // 文件的字节流对象
7697
+ const blob = yield response.blob();
7698
+ // 将Blob转换为File或Blob对象
7699
+ new File([blob], 'template.sjs', { type: 'application/octet-stream' });
7700
+ const sjsBlob = new Blob([blob], { type: 'application/zip' });
7701
+ // SpreadJS打开文件
7702
+ spread.open(sjsBlob, () => {
7703
+ if (typeof succFunc === 'function') {
7704
+ succFunc(spread);
7705
+ }
7706
+ }, (e) => {
7707
+ if (typeof errorFunc === 'function') {
7708
+ errorFunc(e);
7709
+ }
7710
+ });
7711
+ }
7712
+ }),
7681
7713
  /**
7682
7714
  * 打印所有工作表
7683
7715
  * @param GC GC对象
@@ -7744,20 +7776,11 @@ const WorkbookUtils = {
7744
7776
  * @param spread 原始Spread对象
7745
7777
  * @param fileName 导出的文件名称,不传则为第一个工作表的名称
7746
7778
  */
7747
- exportToExcel: (GC, spread, fileName = "") => {
7779
+ exportToExcel: (GC, spread, fileName = '') => {
7748
7780
  // 导出模板为JSON对象,此处设置了参数includeBindingSource,改参数代表包含数据绑定的值
7749
7781
  const json = spread.toJSON({ includeBindingSource: true });
7750
7782
  // 需要移除的自定义公式名称集合(该变量的作用是,在导出Excel前,将工作簿中所有的自定义公式移除掉,其他内置的公式保留)
7751
- const removeCustomFormulas = [
7752
- "YJMAX",
7753
- "YJMIN",
7754
- "YJMID",
7755
- "YJGETNUM",
7756
- "YJGETS",
7757
- "YJGETCV",
7758
- "YJINTERPOLATIONMETHOD",
7759
- "YJINTERPOLATIONMETHOD_Y",
7760
- ];
7783
+ const removeCustomFormulas = ['YJMAX', 'YJMIN', 'YJMID', 'YJGETNUM', 'YJGETS', 'YJGETCV', 'YJINTERPOLATIONMETHOD', 'YJINTERPOLATIONMETHOD_Y'];
7761
7784
  // 临时工作簿
7762
7785
  const tempSpread = new GC.Spread.Sheets.Workbook();
7763
7786
  tempSpread.fromJSON(json);
@@ -7775,9 +7798,7 @@ const WorkbookUtils = {
7775
7798
  // 获取单元格的公式
7776
7799
  const cellFormula = sheet.getFormula(i, j);
7777
7800
  // 如果cellFormula不为null或undefined,则说明该单元格引用了公式
7778
- if (cellFormula != null &&
7779
- cellFormula != undefined &&
7780
- removeCustomFormulas.some((item) => cellFormula.indexOf(item) > -1)) {
7801
+ if (cellFormula != null && cellFormula != undefined && removeCustomFormulas.some((item) => cellFormula.indexOf(item) > -1)) {
7781
7802
  // 获取单元格的值
7782
7803
  const cellVal = sheet.getValue(i, j);
7783
7804
  // 移除单元格引用的公式
@@ -7792,7 +7813,7 @@ const WorkbookUtils = {
7792
7813
  }
7793
7814
  // 恢复绘制
7794
7815
  tempSpread.resumePaint();
7795
- if (fileName == "") {
7816
+ if (fileName == '') {
7796
7817
  fileName = tempSpread.getSheet(0).name();
7797
7818
  }
7798
7819
  let options = {