|
@@ -8,9 +8,11 @@ let ColSettingObj = {
|
|
|
DEFAULT_DATA_STYLE: null,
|
|
|
cellType: {
|
|
|
getText: null,
|
|
|
- readOnly: null
|
|
|
+ cellType: null,
|
|
|
+ readOnly: null,
|
|
|
+ checkBox: null
|
|
|
},
|
|
|
- Rows: {data: 0, filedName: 0, getText: 1, width: 2, readOnly: 3},
|
|
|
+ Rows: {data: 0, filedName: 0, getText: 1, wordWrap: 2, cellType: 3, width: 4, readOnly: 5, showHint: 6, visible: 7},
|
|
|
columnValueChanged: function (e, info) {
|
|
|
let that = ColSettingObj;
|
|
|
info.colList.forEach(function (iCol) {
|
|
@@ -50,25 +52,36 @@ let ColSettingObj = {
|
|
|
|
|
|
this.cellType.getText = new GC.Spread.Sheets.CellTypes.ComboBox();
|
|
|
this.cellType.getText.items(['getText.type']);
|
|
|
+
|
|
|
+ this.cellType.cellType = new GC.Spread.Sheets.CellTypes.ComboBox();
|
|
|
+ this.cellType.cellType.items(['cellType.units']);
|
|
|
+
|
|
|
+ this.cellType.checkBox = new GC.Spread.Sheets.CellTypes.CheckBox();
|
|
|
},
|
|
|
initSheet: function (sheet, setting) {
|
|
|
+ let initColProperty = function (iRow, title) {
|
|
|
+ sheet.setText(setting.headRows + iRow, 0, title, GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
+ sheet.addSpan(setting.headRows + iRow, 0, 1, 2, GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
+ };
|
|
|
+
|
|
|
sheet.setColumnCount(2, GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
sheet.setColumnWidth(0, 80, GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
sheet.setColumnWidth(1, 70, GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
- sheet.setRowCount(setting.headRows + this.Rows.readOnly + 1);
|
|
|
+ sheet.setRowCount(setting.headRows + this.Rows.visible + 1);
|
|
|
|
|
|
sheet.setText(setting.headRows + this.Rows.data, 0, 'Data', GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
sheet.setStyle(setting.headRows + this.Rows.data, -1, this.DEFAULT_DATA_STYLE);
|
|
|
- sheet.addSpan(setting.headRows + this.Rows.data, 0, 2, 1, GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
+ sheet.addSpan(setting.headRows + this.Rows.data, 0, this.Rows.wordWrap + 1, 1, GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
|
|
|
sheet.setText(setting.headRows + this.Rows.filedName, 1, 'FieldName', GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
sheet.setText(setting.headRows + this.Rows.getText, 1, 'getText', GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
+ sheet.setText(setting.headRows + this.Rows.wordWrap, 1, 'wordWrap', GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
|
|
|
- sheet.setText(setting.headRows + this.Rows.width, 0, 'width', GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
- sheet.addSpan(setting.headRows + this.Rows.width, 0, 1, 2, GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
-
|
|
|
- sheet.setText(setting.headRows + this.Rows.readOnly, 0, 'ReadOnly', GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
- sheet.addSpan(setting.headRows + this.Rows.readOnly, 0, 1, 2, GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
+ initColProperty(this.Rows.width, 'Width');
|
|
|
+ initColProperty(this.Rows.readOnly, 'ReadOnly');
|
|
|
+ initColProperty(this.Rows.showHint, 'ShowHint');
|
|
|
+ initColProperty(this.Rows.visible, 'Visible');
|
|
|
+ initColProperty(this.Rows.cellType, 'CellType');
|
|
|
},
|
|
|
initColSetting: function (setting) {
|
|
|
this.DEFAULT_TITLE_STYLE = this.getCellStyle('Arial', GC.Spread.Sheets.HorizontalAlign.center, GC.Spread.Sheets.VerticalAlign.center);
|
|
@@ -80,11 +93,15 @@ let ColSettingObj = {
|
|
|
$('#header-row-count').val(setting.headRows);
|
|
|
|
|
|
colEditSpread = new GC.Spread.Sheets.Workbook($('#colEditSpread')[0], {sheetCount: 1});
|
|
|
+ colEditSpread.getActiveSheet().setRowCount(0);
|
|
|
+ colEditSpread.getActiveSheet().setColumnCount(0);
|
|
|
colEditSpread.options.tabStripVisible = false;
|
|
|
colEditSpread.bind(GC.Spread.Sheets.Events.ColumnWidthChanged, this.columnValueChanged);
|
|
|
colEditSpread.bind(GC.Spread.Sheets.Events.ValueChanged, this.valueChanged);
|
|
|
colEditSpread.bind(GC.Spread.Sheets.Events.SelectionChanged, this.selectionChanged);
|
|
|
|
|
|
+ colEditSpread.getActiveSheet().suspendPaint();
|
|
|
+
|
|
|
this.initSheet(colEditSpread.getActiveSheet(), setting);
|
|
|
this.setColCount(this.colSetting.cols.length);
|
|
|
this.setHeaderRowCount(this.colSetting.headRows);
|
|
@@ -124,14 +141,29 @@ let ColSettingObj = {
|
|
|
// getText
|
|
|
cell = sheet.getCell(this.colSetting.headRows + this.Rows.getText, iCol, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
cell.cellType(this.cellType.getText).value(col.data.getText).hAlign(GC.Spread.Sheets.HorizontalAlign.right);
|
|
|
+ // wordWrap
|
|
|
+ cell = sheet.getCell(this.colSetting.headRows + this.Rows.wordWrap, iCol, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ cell.cellType(this.cellType.checkBox).value(col.data.wordWrap).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
|
|
|
+ // cellType
|
|
|
+ cell = sheet.getCell(this.colSetting.headRows + this.Rows.cellType, iCol, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ cell.cellType(this.cellType.cellType).value(col.data.cellType).hAlign(GC.Spread.Sheets.HorizontalAlign.right);
|
|
|
// 列宽
|
|
|
sheet.setColumnWidth(iCol, col.width);
|
|
|
sheet.setValue(this.colSetting.headRows + this.Rows.width, iCol, sheet.getColumnWidth(iCol), GC.Spread.Sheets.SheetArea.viewport);
|
|
|
// readonly
|
|
|
cell = sheet.getCell(this.colSetting.headRows + this.Rows.readOnly, iCol, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
cell.cellType(this.cellType.readOnly).value(col.readOnly).hAlign(GC.Spread.Sheets.HorizontalAlign.right);
|
|
|
+ // showHint
|
|
|
+ cell = sheet.getCell(this.colSetting.headRows + this.Rows.showHint, iCol, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ cell.cellType(this.cellType.checkBox).value(col.showHint).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
|
|
|
+ // visible
|
|
|
+ cell = sheet.getCell(this.colSetting.headRows + this.Rows.visible, iCol, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ cell.cellType(this.cellType.checkBox).value(col.visible).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ colEditSpread.getActiveSheet().resumePaint();
|
|
|
+
|
|
|
let cell = colEditSpread.getActiveSheet().getCell(0, 0, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
if (cell) {
|
|
|
$('#font').val(cell.font());
|
|
@@ -139,11 +171,20 @@ let ColSettingObj = {
|
|
|
},
|
|
|
setColCount: function (count) {
|
|
|
let sheet = colEditSpread.getActiveSheet();
|
|
|
+ let orgCount = sheet.getColumnCount();
|
|
|
sheet.setColumnCount(count);
|
|
|
- for (let iCol = 0; iCol < sheet.getColumnCount(); iCol++) {
|
|
|
+ for (let iCol = orgCount; iCol < count; iCol++) {
|
|
|
+ for (let iRow = 0; iRow < this.colSetting.headRows; iRow ++) {
|
|
|
+ sheet.setStyle(iRow, iCol, this.DEFAULT_TITLE_STYLE);
|
|
|
+ }
|
|
|
+ sheet.getCell(this.colSetting.headRows + this.Rows.getText, iCol).cellType(this.cellType.getText).hAlign(GC.Spread.Sheets.HorizontalAlign.right);
|
|
|
+ sheet.getCell(this.colSetting.headRows + this.Rows.wordWrap, iCol).cellType(this.cellType.checkBox).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
|
|
|
+ sheet.getCell(this.colSetting.headRows + this.Rows.cellType, iCol).cellType(this.cellType.cellType).hAlign(GC.Spread.Sheets.HorizontalAlign.right);
|
|
|
sheet.setValue(this.colSetting.headRows + this.Rows.width, iCol, sheet.getColumnWidth(iCol), GC.Spread.Sheets.SheetArea.viewport);
|
|
|
- sheet.getCell(this.colSetting.headRows + this.Rows.readOnly, iCol, GC.Spread.Sheets.SheetArea.viewport).cellType(this.cellType.readOnly);
|
|
|
+ sheet.getCell(this.colSetting.headRows + this.Rows.readOnly, iCol).cellType(this.cellType.readOnly).hAlign(GC.Spread.Sheets.HorizontalAlign.right);
|
|
|
sheet.setValue(this.colSetting.headRows + this.Rows.readOnly, iCol, false, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ sheet.getCell(this.colSetting.headRows + this.Rows.showHint, iCol).cellType(this.cellType.checkBox).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
|
|
|
+ sheet.getCell(this.colSetting.headRows + this.Rows.visible, iCol).cellType(this.cellType.checkBox).hAlign(GC.Spread.Sheets.HorizontalAlign.center).value(true);
|
|
|
}
|
|
|
},
|
|
|
setHeaderRowCount: function (count) {
|
|
@@ -199,6 +240,10 @@ let ColSettingObj = {
|
|
|
let col = {};
|
|
|
col.width = sheet.getColumnWidth(iCol);
|
|
|
col.readOnly = sheet.getValue(setting.headRows + this.Rows.readOnly, iCol) || false;
|
|
|
+ if (sheet.getValue(setting.headRows + this.Rows.showHint, iCol)) {
|
|
|
+ col.showHint = sheet.getValue(setting.headRows + this.Rows.showHint, iCol) || false;
|
|
|
+ }
|
|
|
+ col.visible = sheet.getValue(setting.headRows + this.Rows.visible, iCol) || false;
|
|
|
|
|
|
col.head = {};
|
|
|
col.head.titleNames = [];
|
|
@@ -240,6 +285,8 @@ let ColSettingObj = {
|
|
|
col.data.getText = cell.text();
|
|
|
}
|
|
|
setting.cols.push(col);
|
|
|
+ // wordWrap
|
|
|
+ col.data.wordWrap = sheet.getValue(setting.headRows + this.Rows.wordWrap, iCol) || false;
|
|
|
}
|
|
|
return setting;
|
|
|
}
|