|
@@ -31,7 +31,7 @@ var __settingTemp = {
|
|
|
|
|
|
var SheetDataHelper = {
|
|
|
loadSheetHeader: function (setting, sheet) {
|
|
|
- sheet.setColumnCount(setting.cols.length, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ sheet.setColumnCount(setting.cols.length);
|
|
|
sheet.setRowCount(setting.headRows, GC.Spread.Sheets.SheetArea.colHeader);
|
|
|
setting.headRowHeight.forEach(function (rowHeight, index) {
|
|
|
sheet.setRowHeight(index, rowHeight, GC.Spread.Sheets.SheetArea.colHeader);
|
|
@@ -51,37 +51,59 @@ var SheetDataHelper = {
|
|
|
sheet.setColumnWidth(index, col.width);
|
|
|
});
|
|
|
},
|
|
|
- loadSheetData: function (setting, sheet, datas) {
|
|
|
+ protectdSheet: function (sheet) {
|
|
|
var option = {
|
|
|
allowSelectLockedCells: true,
|
|
|
allowSelectUnlockedCells: true,
|
|
|
allowResizeRows: true,
|
|
|
- allowResizeColumns: false
|
|
|
- };
|
|
|
- var getStyle = function (setting) {
|
|
|
- var style = new GC.Spread.Sheets.Style();
|
|
|
- style.locked = setting.readOnly;
|
|
|
- style.name = setting.id;
|
|
|
- style.font = setting.data.font;
|
|
|
- style.hAlign = setting.data.hAlign;
|
|
|
- style.vAlign = setting.data.vAlign;
|
|
|
- return style;
|
|
|
+ allowResizeColumns: true
|
|
|
};
|
|
|
|
|
|
sheet.options.protectionOptions = option;
|
|
|
- sheet.options.isProtected = true;
|
|
|
+ sheet.options.isProtected = true;
|
|
|
+ },
|
|
|
+ getSheetCellStyle: function (setting) {
|
|
|
+ var style = new GC.Spread.Sheets.Style();
|
|
|
+ style.locked = setting.readOnly;
|
|
|
+ style.name = setting.id;
|
|
|
+ style.font = setting.data.font;
|
|
|
+ style.hAlign = setting.data.hAlign;
|
|
|
+ style.vAlign = setting.data.vAlign;
|
|
|
+ //style.wordWrap = setting.data.wordWrap;
|
|
|
+ return style;
|
|
|
+ },
|
|
|
+ loadSheetData: function (setting, sheet, datas) {
|
|
|
+ SheetDataHelper.protectdSheet(sheet);
|
|
|
+
|
|
|
+ sheet.suspendPaint();
|
|
|
+ sheet.suspendEvent();
|
|
|
|
|
|
sheet.setRowCount(datas.length + setting.emptyRows, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
- setting.cols.forEach(function (colSetting, iCol) {
|
|
|
- var i, style = getStyle(colSetting);
|
|
|
+ setting.cols.forEach(function (colSetting, iCol) {
|
|
|
+ sheet.setStyle(-1, iCol, SheetDataHelper.getSheetCellStyle(colSetting));
|
|
|
datas.forEach(function (data, iRow) {
|
|
|
var cell = sheet.getCell(iRow, iCol, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
- cell.value(data[colSetting.data.field]);//.font(colSetting.data.font).hAlign(colSetting.data.hAling).vAlign(colSetting.data.vAlign);
|
|
|
- sheet.setStyle(iRow, iCol, style);
|
|
|
+ cell.value(data[colSetting.data.field]);
|
|
|
});
|
|
|
- for (i = 0; i < setting.emptyRows; i++) {
|
|
|
- sheet.setStyle(datas.length + i, iCol, style);
|
|
|
- }
|
|
|
+ });
|
|
|
+
|
|
|
+ sheet.resumeEvent();
|
|
|
+ sheet.resumePaint();
|
|
|
+ },
|
|
|
+ bindSheetData: function (setting, sheet, datas) {
|
|
|
+ var getBindColInfo = function (setting) {
|
|
|
+ var colInfo = {};
|
|
|
+ colInfo.name = setting.data.field;
|
|
|
+ colInfo.size = setting.width;
|
|
|
+ return colInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ SheetDataHelper.protectdSheet(sheet);
|
|
|
+ sheet.autoGenerateColumns = false;
|
|
|
+ sheet.setDataSource(datas);
|
|
|
+ setting.cols.forEach(function (colSetting, iCol) {
|
|
|
+ sheet.setStyle(-1, iCol, SheetDataHelper.getSheetCellStyle(colSetting));
|
|
|
+ sheet.bindColumn(iCol, getBindColInfo(colSetting));
|
|
|
});
|
|
|
}
|
|
|
};
|