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.cjs.js CHANGED
@@ -7117,6 +7117,10 @@ const EChartsUtils = {
7117
7117
  * @param isHideChart 是否隐藏图表
7118
7118
  */
7119
7119
  initChart: (spread, sheet, config, isHideChart = false) => {
7120
+ // 此时可能ECharts所在的div还没有渲染(如浮动元素还没有在可视区域的时候是不会创建的)
7121
+ if (document.getElementById(config.chartId + '_ec') == null) {
7122
+ return null;
7123
+ }
7120
7124
  // 获取多条x轴的数组(类似[[1,2,3,4],[1,2,3,4]])
7121
7125
  let xDataArr = [], yDataArr = [];
7122
7126
  // 获取多条x轴的数组(单元格原始数据,类似[['1.0','2.0','3.0'],['1.0','2.0','3.0']],此数据可能在有些情况下需要使用原始数据,如:原始数据为字符串的1.0,可能需要在x轴显示为1.0这个字符文本)
@@ -7695,11 +7699,39 @@ const SheetUtils = {
7695
7699
  },
7696
7700
  };
7697
7701
 
7698
- // 导出Excel文件所需的第三方包
7699
7702
  /**
7700
7703
  * SpreadJS工作簿工具函数属性
7701
7704
  */
7702
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
+ }),
7703
7735
  /**
7704
7736
  * 打印所有工作表
7705
7737
  * @param GC GC对象
@@ -7766,20 +7798,11 @@ const WorkbookUtils = {
7766
7798
  * @param spread 原始Spread对象
7767
7799
  * @param fileName 导出的文件名称,不传则为第一个工作表的名称
7768
7800
  */
7769
- exportToExcel: (GC, spread, fileName = "") => {
7801
+ exportToExcel: (GC, spread, fileName = '') => {
7770
7802
  // 导出模板为JSON对象,此处设置了参数includeBindingSource,改参数代表包含数据绑定的值
7771
7803
  const json = spread.toJSON({ includeBindingSource: true });
7772
7804
  // 需要移除的自定义公式名称集合(该变量的作用是,在导出Excel前,将工作簿中所有的自定义公式移除掉,其他内置的公式保留)
7773
- const removeCustomFormulas = [
7774
- "YJMAX",
7775
- "YJMIN",
7776
- "YJMID",
7777
- "YJGETNUM",
7778
- "YJGETS",
7779
- "YJGETCV",
7780
- "YJINTERPOLATIONMETHOD",
7781
- "YJINTERPOLATIONMETHOD_Y",
7782
- ];
7805
+ const removeCustomFormulas = ['YJMAX', 'YJMIN', 'YJMID', 'YJGETNUM', 'YJGETS', 'YJGETCV', 'YJINTERPOLATIONMETHOD', 'YJINTERPOLATIONMETHOD_Y'];
7783
7806
  // 临时工作簿
7784
7807
  const tempSpread = new GC.Spread.Sheets.Workbook();
7785
7808
  tempSpread.fromJSON(json);
@@ -7797,9 +7820,7 @@ const WorkbookUtils = {
7797
7820
  // 获取单元格的公式
7798
7821
  const cellFormula = sheet.getFormula(i, j);
7799
7822
  // 如果cellFormula不为null或undefined,则说明该单元格引用了公式
7800
- if (cellFormula != null &&
7801
- cellFormula != undefined &&
7802
- removeCustomFormulas.some((item) => cellFormula.indexOf(item) > -1)) {
7823
+ if (cellFormula != null && cellFormula != undefined && removeCustomFormulas.some((item) => cellFormula.indexOf(item) > -1)) {
7803
7824
  // 获取单元格的值
7804
7825
  const cellVal = sheet.getValue(i, j);
7805
7826
  // 移除单元格引用的公式
@@ -7814,7 +7835,7 @@ const WorkbookUtils = {
7814
7835
  }
7815
7836
  // 恢复绘制
7816
7837
  tempSpread.resumePaint();
7817
- if (fileName == "") {
7838
+ if (fileName == '') {
7818
7839
  fileName = tempSpread.getSheet(0).name();
7819
7840
  }
7820
7841
  let options = {