@newview/ui 1.1.40 → 1.1.41

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/README.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 1.1.40
2
+ 1、优化LuckySheet 从Excel导入后,预览边框不显示问题。
3
+ 2、优化LuckySheet 获取行数、列数API逻辑
4
+ 3、优化LuckySheet 获取行高、列框API逻辑
5
+
1
6
  ### 1.1.40
2
7
  1、LuckySheet 从Excel导入后,预览边框不显示问题。
3
8
 
@@ -184167,6 +184167,8 @@ var HtmlCells$1 = (
184167
184167
  HtmlCells2.prototype.setMerge = function(td, objValue) {
184168
184168
  if (objValue.mc) {
184169
184169
  td.isMerge = true;
184170
+ td.startRow = objValue.mc.r;
184171
+ td.startCol = objValue.mc.c;
184170
184172
  if (objValue.mc.cs == void 0) {
184171
184173
  td.isRender = false;
184172
184174
  } else {
@@ -184362,21 +184364,14 @@ var HtmlCells$1 = (
184362
184364
  if (!isMerge) {
184363
184365
  tdBorders[key2].right = rightStyle ? rightStyle.borderNumber : 0;
184364
184366
  this.setCss(style2, "border-right", rightStyle ? rightStyle.css : void 0);
184365
- } else if (td.isRender) {
184366
- var endRowIndex = border.value.row_index + td.rowspan - 1;
184367
- var endColIndex = border.value.col_index + td.colspan - 1;
184368
- var endKey = endRowIndex + "_" + endColIndex;
184369
- var endRightStyle = this.endTdRightStyle[endKey];
184370
- if (endRightStyle != void 0) {
184371
- tdBorders[key2].right = endRightStyle ? endRightStyle.borderNumber : 0;
184372
- this.setCss(style2, "border-right", endRightStyle ? endRightStyle.css : void 0);
184373
- } else {
184374
- this.startTds[endKey] = { startRowIndex: border.value.row_index, startColIndex: border.value.col_index };
184375
- }
184376
- } else {
184377
- var startRowCol = this.startTds[key2];
184378
- if (startRowCol != void 0) {
184379
- var startKey = startRowCol.startRowIndex + "_" + startRowCol.startColIndex;
184367
+ } else if (!td.isRender) {
184368
+ var startRow = td.startRow;
184369
+ var startCol = td.startCol;
184370
+ var startKey = startRow + "_" + startCol;
184371
+ var startTd = this.tds[startKey];
184372
+ var endRow = startRow + startTd.rowspan - 1;
184373
+ var endCol = startCol + startTd.colspan - 1;
184374
+ if (endRow == border.value.row_index && endCol == border.value.col_index) {
184380
184375
  tdBorders[startKey] = tdBorders[startKey] || {
184381
184376
  style: {},
184382
184377
  left: 0,
@@ -184387,8 +184382,6 @@ var HtmlCells$1 = (
184387
184382
  var startStyle = tdBorders[startKey].style;
184388
184383
  tdBorders[startKey].right = rightStyle ? rightStyle.borderNumber : 0;
184389
184384
  this.setCss(startStyle, "border-right", rightStyle ? rightStyle.css : void 0);
184390
- } else {
184391
- this.endTdRightStyle[key2] = rightStyle;
184392
184385
  }
184393
184386
  }
184394
184387
  };
@@ -184448,12 +184441,12 @@ var HtmlCells$1 = (
184448
184441
  if (tdcell.isMerge) {
184449
184442
  if (xcolwidth && tdcell.colspan) {
184450
184443
  for (var i2 = Cindex; i2 < Cindex + tdcell.colspan; i2++) {
184451
- cellwidth += Number(xcolwidth[i2]);
184444
+ cellwidth += xcolwidth[i2] == void 0 ? this.defaultColWidth : Number(xcolwidth[i2]);
184452
184445
  }
184453
184446
  }
184454
184447
  if (yrowheight && tdcell.rowspan) {
184455
184448
  for (var j2 = Rindex; j2 < Rindex + tdcell.rowspan; j2++) {
184456
- cellheight += Number(yrowheight[j2]);
184449
+ cellheight += yrowheight[j2] == void 0 ? this.defaultRowHeight : Number(yrowheight[j2]);
184457
184450
  }
184458
184451
  }
184459
184452
  } else {
@@ -184632,7 +184625,7 @@ var HtmlCells$1 = (
184632
184625
  var td = cells.tds[key2];
184633
184626
  var border = cells.borders[key2];
184634
184627
  if (row == 0) {
184635
- var width = this.sheet.config.columnlen ? this.sheet.config.columnlen[col_1] : this.defaultColWidth;
184628
+ var width = this.sheet.config.columnlen && this.sheet.config.columnlen[col_1] != void 0 ? this.sheet.config.columnlen[col_1] : this.defaultColWidth;
184636
184629
  if (!border)
184637
184630
  width++;
184638
184631
  width = ishiddencol ? 0 : width;
@@ -184648,7 +184641,7 @@ var HtmlCells$1 = (
184648
184641
  if (ishidenrow) {
184649
184642
  rowHeight = 0;
184650
184643
  } else {
184651
- rowHeight = this.sheet.config.rowlen ? this.sheet.config.rowlen[row] : this.defaultRowHeight;
184644
+ rowHeight = this.sheet.config.rowlen && this.sheet.config.rowlen[row] != void 0 ? this.sheet.config.rowlen[row] : this.defaultRowHeight;
184652
184645
  rowHeight = rowHeight || this.defaultRowHeight;
184653
184646
  if (rowHeight < 5) {
184654
184647
  rowHeight = 0;
@@ -187925,6 +187918,8 @@ class PrintApi extends BaseInstance {
187925
187918
  const sheetHeight = this.reportApi.sheetApi.getSheetHeight(sheetHandle);
187926
187919
  const countRow = this.reportApi.rowColApi.getRows(sheetHandle);
187927
187920
  const countCol = this.reportApi.rowColApi.getCols(sheetHandle);
187921
+ console.log(countRow, countCol);
187922
+ console.log(sheetWidth, sheetHeight);
187928
187923
  const dh = (a4Height - sheetHeight) / countRow;
187929
187924
  for (let i2 = 0; i2 < countRow - 1; i2++) {
187930
187925
  let height = this.reportApi.rowColApi.getRowHeight(i2, sheetHandle);
@@ -188088,7 +188083,8 @@ class RowColApi extends BaseInstance {
188088
188083
  getColWidth(colIndex, sheetHandle) {
188089
188084
  let cindex = this.utilities.isNull(sheetHandle) ? this.luckysheet.getSheet().order : Number(sheetHandle);
188090
188085
  const sheet = this.luckysheet.getSheet({ order: cindex });
188091
- let swidth = Number(sheet.config.columnlen[colIndex]);
188086
+ let defaultWidth = this.luckysheet.getDefaultColWidth({ order: cindex });
188087
+ let swidth = !this.utilities.isNull(sheet.config.columnlen[colIndex]) ? Number(sheet.config.columnlen[colIndex]) : defaultWidth;
188092
188088
  return swidth;
188093
188089
  }
188094
188090
  /**
@@ -188115,7 +188111,8 @@ class RowColApi extends BaseInstance {
188115
188111
  getRowHeight(rowIndex, sheetHandle) {
188116
188112
  let cindex = this.utilities.isNull(sheetHandle) ? this.luckysheet.getSheet().order : Number(sheetHandle);
188117
188113
  const sheet = this.luckysheet.getSheet({ order: cindex });
188118
- let sheight = Number(sheet.config.rowlen[rowIndex]);
188114
+ let defaultHeight = this.luckysheet.getDefaultRowHeight({ order: cindex });
188115
+ let sheight = !this.utilities.isNull(sheet.config.rowlen[rowIndex]) ? Number(sheet.config.rowlen[rowIndex]) : defaultHeight;
188119
188116
  return sheight;
188120
188117
  }
188121
188118
  /**
@@ -188157,26 +188154,39 @@ class RowColApi extends BaseInstance {
188157
188154
  * @param sheetHandle
188158
188155
  */
188159
188156
  getRows(sheetHandle) {
188160
- let config = this.reportApi.sheetApi.getSheetConfig(sheetHandle);
188161
- if (!this.utilities.isNull(config) && !this.utilities.isNull(config.rowlen)) {
188162
- const keys6 = Object.keys(config.rowlen);
188163
- return keys6.length;
188164
- } else {
188165
- return 0;
188157
+ let cindex = this.utilities.isNull(sheetHandle) ? this.luckysheet.getSheet().order : Number(sheetHandle);
188158
+ const datas = this.luckysheet.getSheetData({ order: cindex });
188159
+ let length = 0;
188160
+ if (datas.length == 0) {
188161
+ return length;
188162
+ }
188163
+ console.log(datas.length);
188164
+ for (const row of datas) {
188165
+ const cell = row[0];
188166
+ if (!this.utilities.isNull(cell)) {
188167
+ length++;
188168
+ }
188166
188169
  }
188170
+ return length;
188167
188171
  }
188168
188172
  /**
188169
188173
  * 获取总列数
188170
188174
  * @param sheetHandle
188171
188175
  */
188172
188176
  getCols(sheetHandle) {
188173
- let config = this.reportApi.sheetApi.getSheetConfig(sheetHandle);
188174
- if (!this.utilities.isNull(config) && !this.utilities.isNull(config.columnlen)) {
188175
- const keys6 = Object.keys(config.columnlen);
188176
- return keys6.length;
188177
- } else {
188178
- return 0;
188177
+ let cindex = this.utilities.isNull(sheetHandle) ? this.luckysheet.getSheet().order : Number(sheetHandle);
188178
+ const datas = this.luckysheet.getSheetData({ order: cindex });
188179
+ let length = 0;
188180
+ if (datas.length == 0) {
188181
+ return length;
188182
+ }
188183
+ const row = datas[0];
188184
+ for (const cell of row) {
188185
+ if (!this.utilities.isNull(cell)) {
188186
+ length++;
188187
+ }
188179
188188
  }
188189
+ return length;
188180
188190
  }
188181
188191
  /**
188182
188192
  * 删除行
@@ -188632,8 +188642,10 @@ class SheetApi extends BaseInstance {
188632
188642
  let cindex = this.utilities.isNull(sheetHandle) ? this.luckysheet.getSheet().order : Number(sheetHandle);
188633
188643
  let xsheet = this.luckysheet.getSheet({ order: cindex });
188634
188644
  let swidth = 0;
188635
- for (let p in xsheet.config.columnlen) {
188636
- swidth += Number(xsheet.config.columnlen[p]);
188645
+ let defaultWidth = this.luckysheet.getDefaultColWidth({ order: cindex });
188646
+ const colCount = this.reportApi.rowColApi.getCols(cindex);
188647
+ for (let col = 0; col < colCount; col++) {
188648
+ swidth += xsheet.config.columnlen && xsheet.config.columnlen[col] != void 0 ? Number(xsheet.config.columnlen[col]) : defaultWidth;
188637
188649
  }
188638
188650
  return swidth + this.reportApi.rowColApi.getCols(cindex);
188639
188651
  }
@@ -188644,8 +188656,10 @@ class SheetApi extends BaseInstance {
188644
188656
  let cindex = this.utilities.isNull(sheetHandle) ? this.luckysheet.getSheet().order : Number(sheetHandle);
188645
188657
  let xsheet = this.luckysheet.getSheet({ order: cindex });
188646
188658
  let sheight = 0;
188647
- for (let p in xsheet.config.rowlen) {
188648
- sheight += Number(xsheet.config.rowlen[p]);
188659
+ let defaultHeight = this.luckysheet.getDefaultRowHeight({ order: cindex });
188660
+ const rowCount = this.reportApi.rowColApi.getRows(cindex);
188661
+ for (let row = 0; row < rowCount; row++) {
188662
+ sheight += xsheet.config.rowlen && xsheet.config.rowlen[row] != void 0 ? Number(xsheet.config.rowlen[row]) : defaultHeight;
188649
188663
  }
188650
188664
  return sheight + this.reportApi.rowColApi.getRows(cindex);
188651
188665
  }