|
@@ -4,7 +4,7 @@
|
|
|
var sheetCommonObj = {
|
|
|
// createSpread、initSheet 在一个Spread多个Sheet分别调用时的情况下使用。
|
|
|
// buildSheet 在一个Spread、一个Sheet的情况下使用。
|
|
|
- createSpread: function(container, SheetCount){
|
|
|
+ createSpread: function (container, SheetCount) {
|
|
|
var me = this;
|
|
|
var spreadBook = new GC.Spread.Sheets.Workbook(container, { sheetCount: SheetCount });
|
|
|
spreadBook.options.allowCopyPasteExcelStyle = false;
|
|
@@ -20,7 +20,7 @@ var sheetCommonObj = {
|
|
|
return spreadBook;
|
|
|
},
|
|
|
|
|
|
- initSheet: function(sheet, setting, rowCount) {
|
|
|
+ initSheet: function (sheet, setting, rowCount) {
|
|
|
var me = this;
|
|
|
var spreadNS = GC.Spread.Sheets;
|
|
|
sheet.suspendPaint();
|
|
@@ -41,7 +41,7 @@ var sheetCommonObj = {
|
|
|
sheet.resumePaint();
|
|
|
},
|
|
|
|
|
|
- buildSheet: function(container, setting, rowCount) {
|
|
|
+ buildSheet: function (container, setting, rowCount, spreadOptions) {
|
|
|
var me = this;
|
|
|
var spreadBook = new GC.Spread.Sheets.Workbook(container, { sheetCount: 1 });
|
|
|
spreadBook.options.tabStripVisible = false;
|
|
@@ -54,6 +54,9 @@ var sheetCommonObj = {
|
|
|
spreadBook.options.allowUserDragFill = false;
|
|
|
spreadBook.options.allowUndo = false;
|
|
|
spreadBook.options.allowContextMenu = false;
|
|
|
+ if (spreadOptions) {
|
|
|
+ Object.assign(spreadBook.options, spreadOptions)
|
|
|
+ }
|
|
|
var spreadNS = GC.Spread.Sheets;
|
|
|
var sheet = spreadBook.getSheet(0);
|
|
|
sheet.suspendPaint();
|
|
@@ -77,13 +80,13 @@ var sheetCommonObj = {
|
|
|
sheet.resumePaint();
|
|
|
return spreadBook;
|
|
|
},
|
|
|
- buildHeader: function(sheet, setting){
|
|
|
+ buildHeader: function (sheet, setting) {
|
|
|
var me = this, ch = GC.Spread.Sheets.SheetArea.colHeader;
|
|
|
for (var i = 0; i < setting.header.length; i++) {
|
|
|
sheet.setValue(0, i, setting.header[i].headerName, ch);
|
|
|
sheet.setColumnWidth(i, setting.header[i].headerWidth ? setting.header[i].headerWidth : 100);
|
|
|
}
|
|
|
- if(setting.headerHeight) sheet.setRowHeight(0, setting.headerHeight, GC.Spread.Sheets.SheetArea.colHeader);
|
|
|
+ if (setting.headerHeight) sheet.setRowHeight(0, setting.headerHeight, GC.Spread.Sheets.SheetArea.colHeader);
|
|
|
},
|
|
|
cleanData: function (sheet, setting, rowCount) {
|
|
|
sheet.suspendPaint();
|
|
@@ -93,7 +96,7 @@ var sheetCommonObj = {
|
|
|
sheet.resumeEvent();
|
|
|
sheet.resumePaint();
|
|
|
},
|
|
|
- cleanSheet: function(sheet, setting, rowCount) {
|
|
|
+ cleanSheet: function (sheet, setting, rowCount) {
|
|
|
sheet.suspendPaint();
|
|
|
sheet.suspendEvent();
|
|
|
sheet.clear(-1, 0, -1, setting.header.length, GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
|
|
@@ -102,7 +105,7 @@ var sheetCommonObj = {
|
|
|
sheet.resumeEvent();
|
|
|
sheet.resumePaint();
|
|
|
},
|
|
|
- setAreaAlign: function(area, hAlign, vAlign){
|
|
|
+ setAreaAlign: function (area, hAlign, vAlign) {
|
|
|
if (!(hAlign) || hAlign === "left") {
|
|
|
area.hAlign(GC.Spread.Sheets.HorizontalAlign.left);
|
|
|
} else if (hAlign === "right") {
|
|
@@ -122,118 +125,118 @@ var sheetCommonObj = {
|
|
|
area.vAlign(GC.Spread.Sheets.VerticalAlign.center);
|
|
|
}
|
|
|
},
|
|
|
- showData: function(sheet, setting, data,distTypeTree) {
|
|
|
+ showData: function (sheet, setting, data, distTypeTree) {
|
|
|
var me = this, ch = GC.Spread.Sheets.SheetArea.viewport;
|
|
|
sheet.suspendPaint();
|
|
|
sheet.suspendEvent();
|
|
|
//sheet.addRows(row, 1);
|
|
|
|
|
|
sheet.clear(0, 0, sheet.getRowCount(), sheet.getColumnCount(), GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
|
|
|
- if(sheet.getRowCount()<data.length){
|
|
|
- data.length<30? sheet.setRowCount(30):sheet.setRowCount(data.length);
|
|
|
- }else if(sheet.getRowCount()==0){
|
|
|
+ if (sheet.getRowCount() < data.length) {
|
|
|
+ data.length < 30 ? sheet.setRowCount(30) : sheet.setRowCount(data.length);
|
|
|
+ } else if (sheet.getRowCount() == 0) {
|
|
|
sheet.setRowCount(30);
|
|
|
}
|
|
|
for (var col = 0; col < setting.header.length; col++) {
|
|
|
var hAlign = "left", vAlign = "center";
|
|
|
if (setting.header[col].hAlign) {
|
|
|
hAlign = setting.header[col].hAlign;
|
|
|
- } else if (setting.header[col].dataType !== "String"){
|
|
|
+ } else if (setting.header[col].dataType !== "String") {
|
|
|
hAlign = "right";
|
|
|
}
|
|
|
- vAlign = setting.header[col].vAlign?setting.header[col].vAlign:vAlign;
|
|
|
+ vAlign = setting.header[col].vAlign ? setting.header[col].vAlign : vAlign;
|
|
|
me.setAreaAlign(sheet.getRange(-1, col, -1, 1), hAlign, vAlign);
|
|
|
if (setting.header[col].formatter) {
|
|
|
sheet.setFormatter(-1, col, setting.header[col].formatter, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
}
|
|
|
- if(setting.header[col].cellType === "checkBox"||setting.header[col].cellType === "button"){//clear and reset
|
|
|
+ if (setting.header[col].cellType === "checkBox" || setting.header[col].cellType === "button") {//clear and reset
|
|
|
var me = this, header = GC.Spread.Sheets.SheetArea.colHeader;
|
|
|
- sheet.deleteColumns(col,1);
|
|
|
+ sheet.deleteColumns(col, 1);
|
|
|
sheet.addColumns(col, 1);
|
|
|
sheet.setValue(0, col, setting.header[col].headerName, header);
|
|
|
- sheet.setColumnWidth(col, setting.header[col].headerWidth?setting.header[col].headerWidth:100);
|
|
|
+ sheet.setColumnWidth(col, setting.header[col].headerWidth ? setting.header[col].headerWidth : 100);
|
|
|
}
|
|
|
- if(setting.header[col].visible === false){
|
|
|
- sheet.setColumnVisible(col,false);
|
|
|
+ if (setting.header[col].visible === false) {
|
|
|
+ sheet.setColumnVisible(col, false);
|
|
|
}
|
|
|
sheet.getCell(0, col, GC.Spread.Sheets.SheetArea.colHeader).wordWrap(true);
|
|
|
}
|
|
|
for (var row = 0; row < data.length; row++) {
|
|
|
//var cell = sheet.getCell(row, col, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
- this.showRowData(sheet,setting,row,data,distTypeTree);
|
|
|
- if(setting.getStyle && setting.getStyle(data[row])){
|
|
|
+ this.showRowData(sheet, setting, row, data, distTypeTree);
|
|
|
+ if (setting.getStyle && setting.getStyle(data[row])) {
|
|
|
sheet.setStyle(row, -1, setting.getStyle(data[row]));
|
|
|
}
|
|
|
}
|
|
|
- this.lockCells(sheet,setting);
|
|
|
+ this.lockCells(sheet, setting);
|
|
|
sheet.resumeEvent();
|
|
|
sheet.resumePaint();
|
|
|
//me.shieldAllCells(sheet);
|
|
|
},
|
|
|
- getCheckBox(threeState = false){
|
|
|
+ getCheckBox(threeState = false) {
|
|
|
var c = new GC.Spread.Sheets.CellTypes.CheckBox();
|
|
|
c.isThreeState(threeState);
|
|
|
return c
|
|
|
},
|
|
|
// 无法勾选的复选框
|
|
|
- getReadOnlyCheckBox (threeState = false) {
|
|
|
- function ReadOnlyCheckBox() {}
|
|
|
+ getReadOnlyCheckBox(threeState = false) {
|
|
|
+ function ReadOnlyCheckBox() { }
|
|
|
ReadOnlyCheckBox.prototype = this.getCheckBox(threeState);
|
|
|
ReadOnlyCheckBox.prototype.processMouseUp = function () {
|
|
|
return;
|
|
|
};
|
|
|
return new ReadOnlyCheckBox();
|
|
|
},
|
|
|
- showRowData:function (sheet,setting,row,data,distTypeTree=null) {
|
|
|
+ showRowData: function (sheet, setting, row, data, distTypeTree = null) {
|
|
|
let ch = GC.Spread.Sheets.SheetArea.viewport;
|
|
|
for (var col = 0; col < setting.header.length; col++) {
|
|
|
//var cell = sheet.getCell(row, col, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
var val = data[row][setting.header[col].dataCode];
|
|
|
- if(val&&setting.header[col].dataType === "Number"){
|
|
|
- if(setting.header[col].hasOwnProperty('tofix')){
|
|
|
- val =scMathUtil.roundToString(val,setting.header[col].tofix);
|
|
|
+ if (val && setting.header[col].dataType === "Number") {
|
|
|
+ if (setting.header[col].hasOwnProperty('tofix')) {
|
|
|
+ val = scMathUtil.roundToString(val, setting.header[col].tofix);
|
|
|
} else {
|
|
|
- val =val+'';
|
|
|
+ val = val + '';
|
|
|
}
|
|
|
}
|
|
|
- if(val!=null&&setting.header[col].cellType === "checkBox"){
|
|
|
- this.setCheckBoxCell(row,col,sheet,val)
|
|
|
+ if (val != null && setting.header[col].cellType === "checkBox") {
|
|
|
+ this.setCheckBoxCell(row, col, sheet, val)
|
|
|
}
|
|
|
- if(setting.header[col].cellType === "comboBox"){
|
|
|
- this.setComboBox(row,col,sheet,setting.header[col].options,setting.header[col].editorValueType);
|
|
|
+ if (setting.header[col].cellType === "comboBox") {
|
|
|
+ this.setComboBox(row, col, sheet, setting.header[col].options, setting.header[col].editorValueType);
|
|
|
}
|
|
|
- if(setting.header[col].getText){
|
|
|
- val = setting.getText[setting.header[col].getText](data[row],val)
|
|
|
+ if (setting.header[col].getText) {
|
|
|
+ val = setting.getText[setting.header[col].getText](data[row], val)
|
|
|
}
|
|
|
sheet.setValue(row, col, val, ch);
|
|
|
}
|
|
|
- this.setRowStyle(row,sheet,data[row].bgColour);
|
|
|
- if(setting.autoFit==true){
|
|
|
+ this.setRowStyle(row, sheet, data[row].bgColour);
|
|
|
+ if (setting.autoFit == true) {
|
|
|
sheet.getRange(row, -1, 1, -1, GC.Spread.Sheets.SheetArea.viewport).wordWrap(true);
|
|
|
sheet.autoFitRow(row);
|
|
|
}
|
|
|
},
|
|
|
- setCheckBoxCell(row,col,sheet,val){
|
|
|
+ setCheckBoxCell(row, col, sheet, val) {
|
|
|
var c = new GC.Spread.Sheets.CellTypes.CheckBox();
|
|
|
c.isThreeState(false);
|
|
|
- sheet.setCellType(row, col,c,GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ sheet.setCellType(row, col, c, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
sheet.getCell(row, col).value(val);
|
|
|
sheet.getCell(row, col).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
|
|
|
|
|
|
},
|
|
|
- setComboBox(row,col,sheet,options,editorValueType){
|
|
|
+ setComboBox(row, col, sheet, options, editorValueType) {
|
|
|
//let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
|
|
|
let dynamicCombo = sheetCommonObj.getDynamicCombo(true);
|
|
|
- if(options){
|
|
|
+ if (options) {
|
|
|
dynamicCombo.itemHeight(options.length).items(options);
|
|
|
- if(editorValueType==true){
|
|
|
+ if (editorValueType == true) {
|
|
|
dynamicCombo.editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
|
|
|
}
|
|
|
}
|
|
|
- sheet.setCellType(row, col,dynamicCombo,GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ sheet.setCellType(row, col, dynamicCombo, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
},
|
|
|
- setRowStyle(row,sheet,bgColour) {
|
|
|
- if(bgColour){
|
|
|
+ setRowStyle(row, sheet, bgColour) {
|
|
|
+ if (bgColour) {
|
|
|
let style = new GC.Spread.Sheets.Style();
|
|
|
style.backColor = bgColour;
|
|
|
style.borderLeft = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
|
|
@@ -243,7 +246,7 @@ var sheetCommonObj = {
|
|
|
sheet.setStyle(row, -1, style);
|
|
|
}
|
|
|
},
|
|
|
- analyzePasteData: function(setting, pastedInfo) {
|
|
|
+ analyzePasteData: function (setting, pastedInfo) {
|
|
|
var rst = [], propId = pastedInfo.cellRange.col, preStrIdx = 0, itemObj = {};
|
|
|
for (var i = 0; i < pastedInfo.pasteData.text.length; i++) {
|
|
|
if (pastedInfo.pasteData.text[i] === "\n") {
|
|
@@ -271,17 +274,17 @@ var sheetCommonObj = {
|
|
|
}
|
|
|
return rst;
|
|
|
},
|
|
|
- combineRowData: function(sheet, setting, row) {
|
|
|
+ combineRowData: function (sheet, setting, row) {
|
|
|
var rst = {};
|
|
|
for (var col = 0; col < setting.header.length; col++) {
|
|
|
rst[setting.header[col].dataCode] = sheet.getValue(row, col);
|
|
|
}
|
|
|
return rst;
|
|
|
},
|
|
|
- shieldAllCells: function(sheet) {
|
|
|
+ shieldAllCells: function (sheet) {
|
|
|
sheet.options.isProtected = true;
|
|
|
},
|
|
|
- unShieldAllCells: function(sheet) {
|
|
|
+ unShieldAllCells: function (sheet) {
|
|
|
sheet.options.isProtected = false;
|
|
|
},
|
|
|
unLockAllCells: function (sheet) {
|
|
@@ -301,21 +304,21 @@ var sheetCommonObj = {
|
|
|
let defaultStyle = new GC.Spread.Sheets.Style();
|
|
|
defaultStyle.locked = true;
|
|
|
sheet.setDefaultStyle(defaultStyle, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
- for(let i = 0; i < sheet.getRowCount(); i++){
|
|
|
+ for (let i = 0; i < sheet.getRowCount(); i++) {
|
|
|
sheet.setStyle(i, 0, defaultStyle);
|
|
|
}
|
|
|
sheet.options.isProtected = true;
|
|
|
sheet.resumePaint();
|
|
|
sheet.resumeEvent();
|
|
|
},
|
|
|
- lockCells: function(sheet, setting){
|
|
|
+ lockCells: function (sheet, setting) {
|
|
|
sheet.suspendPaint();
|
|
|
sheet.suspendEvent();
|
|
|
if (setting && setting.view.lockColumns && setting.view.lockColumns.length > 0) {
|
|
|
sheet.options.isProtected = true;
|
|
|
sheet.getRange(-1, 0, -1, setting.header.length, GC.Spread.Sheets.SheetArea.viewport).locked(false);
|
|
|
for (var i = 0; i < setting.view.lockColumns.length; i++) {
|
|
|
- sheet.getRange(-1,setting.view.lockColumns[i] , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
|
|
|
+ sheet.getRange(-1, setting.view.lockColumns[i], -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
|
|
|
}
|
|
|
}
|
|
|
sheet.resumePaint();
|
|
@@ -324,13 +327,13 @@ var sheetCommonObj = {
|
|
|
setLockCol: function (sheet, col, isLocked) {
|
|
|
sheet.suspendPaint();
|
|
|
sheet.suspendEvent();
|
|
|
- for(let row = 0, len = sheet.getRowCount(); row < len; row++){
|
|
|
+ for (let row = 0, len = sheet.getRowCount(); row < len; row++) {
|
|
|
sheet.getCell(row, col).locked(isLocked);
|
|
|
}
|
|
|
sheet.resumePaint();
|
|
|
sheet.resumeEvent();
|
|
|
},
|
|
|
- chkIfEmpty: function(rObj, setting) {
|
|
|
+ chkIfEmpty: function (rObj, setting) {
|
|
|
var rst = true;
|
|
|
if (rObj) {
|
|
|
for (var i = 0; i < setting.header.length; i++) {
|
|
@@ -350,7 +353,7 @@ var sheetCommonObj = {
|
|
|
ComboCellForActiveCell.prototype.paintValue = function (ctx, value, x, y, w, h, style, options) {
|
|
|
let sheet = options.sheet;
|
|
|
if (options.row === sheet.getActiveRowIndex() && options.col === sheet.getActiveColumnIndex()) {
|
|
|
- GC.Spread.Sheets.CellTypes.ComboBox.prototype.paintValue.apply(this, arguments);
|
|
|
+ GC.Spread.Sheets.CellTypes.ComboBox.prototype.paintValue.apply(this, arguments);
|
|
|
} else {
|
|
|
GC.Spread.Sheets.CellTypes.Base.prototype.paintValue.apply(this, arguments);
|
|
|
}
|
|
@@ -369,14 +372,14 @@ var sheetCommonObj = {
|
|
|
let me = this;
|
|
|
sheet.suspendPaint();
|
|
|
let combo = me.getDynamicCombo();
|
|
|
- if(itemsHeight) {
|
|
|
+ if (itemsHeight) {
|
|
|
combo.itemHeight(itemsHeight);
|
|
|
combo._maxDropDownItems = itemsHeight + 5;
|
|
|
}
|
|
|
- if(itemsType === 'value') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
|
|
|
- else if(itemsType === 'text') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.text);
|
|
|
+ if (itemsType === 'value') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
|
|
|
+ else if (itemsType === 'text') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.text);
|
|
|
else combo.items(items);
|
|
|
- for(let i = 0, len = rowCount; i < len; i++){
|
|
|
+ for (let i = 0, len = rowCount; i < len; i++) {
|
|
|
sheet.getCell(beginRow + i, col).cellType(combo);
|
|
|
}
|
|
|
sheet.resumePaint();
|
|
@@ -384,10 +387,10 @@ var sheetCommonObj = {
|
|
|
setStaticCombo: function (sheet, beginRow, col, rowCount, items, itemsHeight, itemsType) {
|
|
|
sheet.suspendPaint();
|
|
|
let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
|
|
|
- for(let i = 0, len = rowCount; i < len; i++){
|
|
|
- if(itemsHeight) combo.itemHeight(itemsHeight);
|
|
|
- if(itemsType === 'value') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
|
|
|
- else if(itemsType === 'text') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.text);
|
|
|
+ for (let i = 0, len = rowCount; i < len; i++) {
|
|
|
+ if (itemsHeight) combo.itemHeight(itemsHeight);
|
|
|
+ if (itemsType === 'value') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
|
|
|
+ else if (itemsType === 'text') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.text);
|
|
|
else combo.items(items);
|
|
|
sheet.getCell(beginRow + i, col).cellType(combo);
|
|
|
}
|
|
@@ -401,45 +404,45 @@ var sheetCommonObj = {
|
|
|
},
|
|
|
//解决esc后触发了编辑结束的保存事件,显示与实际数据不同问题
|
|
|
bindEscKey: function (workBook, sheets) {
|
|
|
- function isDef(v){
|
|
|
+ function isDef(v) {
|
|
|
return typeof v !== 'undefined' && v !== null;
|
|
|
}
|
|
|
workBook.commandManager().register('myEsc', function () {
|
|
|
let activeSheet = workBook.getActiveSheet();
|
|
|
let hasTheSheet = false;
|
|
|
- for(let sheetObj of sheets){
|
|
|
+ for (let sheetObj of sheets) {
|
|
|
let sheet = sheetObj.sheet;
|
|
|
- if(sheet === activeSheet){
|
|
|
+ if (sheet === activeSheet) {
|
|
|
hasTheSheet = true;
|
|
|
let editStarting = sheetObj.editStarting;
|
|
|
let editEnded = sheetObj.editEnded;
|
|
|
- if(editStarting){
|
|
|
+ if (editStarting) {
|
|
|
sheet.unbind(GC.Spread.Sheets.Events.EditStarting);
|
|
|
}
|
|
|
- if(editEnded){
|
|
|
+ if (editEnded) {
|
|
|
sheet.unbind(GC.Spread.Sheets.Events.EditEnded);
|
|
|
}
|
|
|
let row = sheet.getActiveRowIndex();
|
|
|
let col = sheet.getActiveColumnIndex();
|
|
|
let orgV = sheet.getValue(row, col);
|
|
|
- if(!isDef(orgV)){
|
|
|
+ if (!isDef(orgV)) {
|
|
|
orgV = '';
|
|
|
}
|
|
|
- if(sheet.isEditing()){
|
|
|
+ if (sheet.isEditing()) {
|
|
|
sheet.endEdit();
|
|
|
sheet.setValue(row, col, orgV);
|
|
|
}
|
|
|
- if(editStarting){
|
|
|
+ if (editStarting) {
|
|
|
sheet.bind(GC.Spread.Sheets.Events.EditStarting, editStarting);
|
|
|
}
|
|
|
- if(editEnded){
|
|
|
+ if (editEnded) {
|
|
|
sheet.bind(GC.Spread.Sheets.Events.EditEnded, editEnded);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//容错处理,以防没把所有工作簿的表格信息传入参数
|
|
|
- if(!hasTheSheet){
|
|
|
- if(activeSheet.isEditing()){
|
|
|
+ if (!hasTheSheet) {
|
|
|
+ if (activeSheet.isEditing()) {
|
|
|
activeSheet.endEdit();
|
|
|
}
|
|
|
}
|
|
@@ -451,8 +454,8 @@ var sheetCommonObj = {
|
|
|
initColMapping: function (obj, headers) {
|
|
|
//colToField 列下标与列字段映射
|
|
|
//fieldToCol 列字段与列下标映射
|
|
|
- let colMapping = {colToField: {}, fieldToCol: {}};
|
|
|
- for(let header of headers){
|
|
|
+ let colMapping = { colToField: {}, fieldToCol: {} };
|
|
|
+ for (let header of headers) {
|
|
|
colMapping['colToField'][headers.indexOf(header)] = header.dataCode;
|
|
|
colMapping['fieldToCol'][header.dataCode] = headers.indexOf(header);
|
|
|
}
|
|
@@ -460,17 +463,17 @@ var sheetCommonObj = {
|
|
|
obj.colMapping = colMapping
|
|
|
},
|
|
|
//动态根据工作簿宽度和各列宽度比例设置宽度
|
|
|
- setColumnWidthByRate: function (workBookWidth, workBook, headers){
|
|
|
- if(workBook){
|
|
|
+ setColumnWidthByRate: function (workBookWidth, workBook, headers) {
|
|
|
+ if (workBook) {
|
|
|
const sheet = workBook.getActiveSheet();
|
|
|
sheet.suspendEvent();
|
|
|
sheet.suspendPaint();
|
|
|
- for(let col = 0; col < headers.length; col++){
|
|
|
- if(headers[col]['rateWidth'] !== undefined && headers[col]['rateWidth'] !== null && headers[col]['rateWidth'] !== ''){
|
|
|
+ for (let col = 0; col < headers.length; col++) {
|
|
|
+ if (headers[col]['rateWidth'] !== undefined && headers[col]['rateWidth'] !== null && headers[col]['rateWidth'] !== '') {
|
|
|
sheet.setColumnWidth(col, workBookWidth * headers[col]['rateWidth'], GC.Spread.Sheets.SheetArea.colHeader)
|
|
|
}
|
|
|
else {
|
|
|
- if(headers[col]['headerWidth'] !== undefined && headers[col]['headerWidth'] !== null && headers[col]['headerWidth'] !== ''){
|
|
|
+ if (headers[col]['headerWidth'] !== undefined && headers[col]['headerWidth'] !== null && headers[col]['headerWidth'] !== '') {
|
|
|
sheet.setColumnWidth(col, headers[col]['headerWidth'], GC.Spread.Sheets.SheetArea.colHeader)
|
|
|
}
|
|
|
}
|
|
@@ -479,10 +482,10 @@ var sheetCommonObj = {
|
|
|
sheet.resumePaint();
|
|
|
}
|
|
|
},
|
|
|
- renderSheetFunc: function (sheet, func){
|
|
|
+ renderSheetFunc: function (sheet, func) {
|
|
|
sheet.suspendEvent();
|
|
|
sheet.suspendPaint();
|
|
|
- if(func){
|
|
|
+ if (func) {
|
|
|
func();
|
|
|
}
|
|
|
sheet.resumeEvent();
|