sheet_common.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. /**
  2. * Created by Tony on 2017/4/28.
  3. */
  4. var sheetCommonObj = {
  5. // createSpread、initSheet 在一个Spread多个Sheet分别调用时的情况下使用。
  6. // buildSheet 在一个Spread、一个Sheet的情况下使用。
  7. createSpread: function(container, SheetCount){
  8. var me = this;
  9. var spreadBook = new GC.Spread.Sheets.Workbook(container, { sheetCount: SheetCount });
  10. spreadBook.options.allowCopyPasteExcelStyle = false;
  11. spreadBook.options.allowExtendPasteRange = true;
  12. spreadBook.options.tabStripVisible = false;
  13. //spreadBook.options.showHorizontalScrollbar = false;
  14. spreadBook.options.allowUserDragDrop = false;
  15. spreadBook.options.allowUserDragFill = false;
  16. spreadBook.options.scrollbarMaxAlign = true;
  17. spreadBook.options.allowContextMenu = false;
  18. spreadBook.options.allowUndo = false;
  19. spreadBook.options.cutCopyIndicatorVisible = false;
  20. return spreadBook;
  21. },
  22. initSheet: function(sheet, setting, rowCount) {
  23. var me = this;
  24. var spreadNS = GC.Spread.Sheets;
  25. sheet.suspendPaint();
  26. sheet.suspendEvent();
  27. sheet.setRowCount(1, spreadNS.SheetArea.colHeader);
  28. sheet.setColumnCount(setting.header.length, spreadNS.SheetArea.viewport);
  29. sheet.options.colHeaderAutoTextIndex = 1;
  30. sheet.options.colHeaderAutoText = spreadNS.HeaderAutoText.numbers;
  31. sheet.options.protectionOptions = {
  32. allowResizeRows: true,
  33. allowResizeColumns: true
  34. };
  35. sheet.showRowOutline(false);
  36. sheet.options.allowCellOverflow = false;
  37. me.buildHeader(sheet, setting);
  38. if (rowCount > 0) sheet.setRowCount(rowCount);
  39. sheet.resumeEvent();
  40. sheet.resumePaint();
  41. },
  42. buildSheet: function(container, setting, rowCount) {
  43. var me = this;
  44. var spreadBook = new GC.Spread.Sheets.Workbook(container, { sheetCount: 1 });
  45. spreadBook.options.tabStripVisible = false;
  46. //spreadBook.options.showHorizontalScrollbar = false;
  47. spreadBook.options.scrollbarMaxAlign = true;
  48. spreadBook.options.allowCopyPasteExcelStyle = false;
  49. spreadBook.options.cutCopyIndicatorVisible = false;
  50. spreadBook.options.allowExtendPasteRange = true;
  51. spreadBook.options.allowUserDragDrop = false;
  52. spreadBook.options.allowUserDragFill = false;
  53. spreadBook.options.allowUndo = false;
  54. spreadBook.options.allowContextMenu = false;
  55. var spreadNS = GC.Spread.Sheets;
  56. var sheet = spreadBook.getSheet(0);
  57. sheet.suspendPaint();
  58. sheet.suspendEvent();
  59. //Set rowHeader count and columnHeader count.
  60. sheet.setRowCount(1, spreadNS.SheetArea.colHeader);
  61. sheet.setColumnCount(setting.header.length, spreadNS.SheetArea.viewport);
  62. sheet.options.colHeaderAutoTextIndex = 1;
  63. sheet.options.colHeaderAutoText = spreadNS.HeaderAutoText.numbers;
  64. sheet.options.clipBoardOptions = GC.Spread.Sheets.ClipboardPasteOptions.values;
  65. sheet.options.protectionOptions = {
  66. allowResizeRows: true,
  67. allowResizeColumns: true
  68. };
  69. sheet.showRowOutline(false);
  70. //setup column header
  71. me.buildHeader(sheet, setting);
  72. //setup cells
  73. if (rowCount > 0) sheet.setRowCount(rowCount);
  74. sheet.resumeEvent();
  75. sheet.resumePaint();
  76. return spreadBook;
  77. },
  78. buildHeader: function(sheet, setting){
  79. var me = this, ch = GC.Spread.Sheets.SheetArea.colHeader;
  80. for (var i = 0; i < setting.header.length; i++) {
  81. sheet.setValue(0, i, setting.header[i].headerName, ch);
  82. sheet.setColumnWidth(i, setting.header[i].headerWidth ? setting.header[i].headerWidth : 100);
  83. }
  84. if(setting.headerHeight) sheet.setRowHeight(0, setting.headerHeight, GC.Spread.Sheets.SheetArea.colHeader);
  85. },
  86. cleanData: function (sheet, setting, rowCount) {
  87. sheet.suspendPaint();
  88. sheet.suspendEvent();
  89. sheet.clear(-1, 0, -1, setting.header.length, GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
  90. if (rowCount > 0) sheet.setRowCount(rowCount);
  91. sheet.resumeEvent();
  92. sheet.resumePaint();
  93. },
  94. cleanSheet: function(sheet, setting, rowCount) {
  95. sheet.suspendPaint();
  96. sheet.suspendEvent();
  97. sheet.clear(-1, 0, -1, setting.header.length, GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
  98. if (rowCount > 0) sheet.setRowCount(rowCount);
  99. sheet.clearSelection();
  100. sheet.resumeEvent();
  101. sheet.resumePaint();
  102. },
  103. setAreaAlign: function(area, hAlign, vAlign){
  104. if (!(hAlign) || hAlign === "left") {
  105. area.hAlign(GC.Spread.Sheets.HorizontalAlign.left);
  106. } else if (hAlign === "right") {
  107. area.hAlign(GC.Spread.Sheets.HorizontalAlign.right);
  108. } else if (hAlign === "center") {
  109. area.hAlign(GC.Spread.Sheets.HorizontalAlign.center);
  110. } else {
  111. area.hAlign(GC.Spread.Sheets.HorizontalAlign.left);
  112. }
  113. if (!(vAlign) || vAlign === "center") {
  114. area.vAlign(GC.Spread.Sheets.VerticalAlign.center);
  115. } else if (vAlign === "top") {
  116. area.vAlign(GC.Spread.Sheets.VerticalAlign.top);
  117. } else if (vAlign === "bottom") {
  118. area.vAlign(GC.Spread.Sheets.VerticalAlign.bottom);
  119. } else {
  120. area.vAlign(GC.Spread.Sheets.VerticalAlign.center);
  121. }
  122. },
  123. showData: function(sheet, setting, data,distTypeTree) {
  124. var me = this, ch = GC.Spread.Sheets.SheetArea.viewport;
  125. sheet.suspendPaint();
  126. sheet.suspendEvent();
  127. //sheet.addRows(row, 1);
  128. sheet.clear(0, 0, sheet.getRowCount(), sheet.getColumnCount(), GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
  129. if(sheet.getRowCount()<data.length){
  130. data.length<30? sheet.setRowCount(30):sheet.setRowCount(data.length);
  131. }else if(sheet.getRowCount()==0){
  132. sheet.setRowCount(30);
  133. }
  134. for (var col = 0; col < setting.header.length; col++) {
  135. var hAlign = "left", vAlign = "center";
  136. if (setting.header[col].hAlign) {
  137. hAlign = setting.header[col].hAlign;
  138. } else if (setting.header[col].dataType !== "String"){
  139. hAlign = "right";
  140. }
  141. vAlign = setting.header[col].vAlign?setting.header[col].vAlign:vAlign;
  142. me.setAreaAlign(sheet.getRange(-1, col, -1, 1), hAlign, vAlign);
  143. if (setting.header[col].formatter) {
  144. sheet.setFormatter(-1, col, setting.header[col].formatter, GC.Spread.Sheets.SheetArea.viewport);
  145. }
  146. if(setting.header[col].cellType === "checkBox"||setting.header[col].cellType === "button"){//clear and reset
  147. var me = this, header = GC.Spread.Sheets.SheetArea.colHeader;
  148. sheet.deleteColumns(col,1);
  149. sheet.addColumns(col, 1);
  150. sheet.setValue(0, col, setting.header[col].headerName, header);
  151. sheet.setColumnWidth(col, setting.header[col].headerWidth?setting.header[col].headerWidth:100);
  152. }
  153. if(setting.header[col].visible === false){
  154. sheet.setColumnVisible(col,false);
  155. }
  156. sheet.getCell(0, col, GC.Spread.Sheets.SheetArea.colHeader).wordWrap(true);
  157. }
  158. for (var row = 0; row < data.length; row++) {
  159. //var cell = sheet.getCell(row, col, GC.Spread.Sheets.SheetArea.viewport);
  160. this.showRowData(sheet,setting,row,data,distTypeTree);
  161. if(setting.getStyle && setting.getStyle(data[row])){
  162. sheet.setStyle(row, -1, setting.getStyle(data[row]));
  163. }
  164. }
  165. this.lockCells(sheet,setting);
  166. sheet.resumeEvent();
  167. sheet.resumePaint();
  168. //me.shieldAllCells(sheet);
  169. },
  170. getCheckBox(threeState = false){
  171. var c = new GC.Spread.Sheets.CellTypes.CheckBox();
  172. c.isThreeState(threeState);
  173. return c
  174. },
  175. // 无法勾选的复选框
  176. getReadOnlyCheckBox (threeState = false) {
  177. function ReadOnlyCheckBox() {}
  178. ReadOnlyCheckBox.prototype = this.getCheckBox(threeState);
  179. ReadOnlyCheckBox.prototype.processMouseUp = function () {
  180. return;
  181. };
  182. return new ReadOnlyCheckBox();
  183. },
  184. showRowData:function (sheet,setting,row,data,distTypeTree=null) {
  185. let ch = GC.Spread.Sheets.SheetArea.viewport;
  186. for (var col = 0; col < setting.header.length; col++) {
  187. //var cell = sheet.getCell(row, col, GC.Spread.Sheets.SheetArea.viewport);
  188. var val = data[row][setting.header[col].dataCode];
  189. if(val&&setting.header[col].dataType === "Number"){
  190. if(setting.header[col].hasOwnProperty('tofix')){
  191. val =scMathUtil.roundToString(val,setting.header[col].tofix);
  192. } else {
  193. val =val+'';
  194. }
  195. }
  196. if(val!=null&&setting.header[col].cellType === "checkBox"){
  197. this.setCheckBoxCell(row,col,sheet,val)
  198. }
  199. if(setting.header[col].cellType === "comboBox"){
  200. this.setComboBox(row,col,sheet,setting.header[col].options,setting.header[col].editorValueType);
  201. }
  202. if(setting.header[col].getText){
  203. val = setting.getText[setting.header[col].getText](data[row],val)
  204. }
  205. sheet.setValue(row, col, val, ch);
  206. }
  207. this.setRowStyle(row,sheet,data[row].bgColour);
  208. if(setting.autoFit==true){
  209. sheet.getRange(row, -1, 1, -1, GC.Spread.Sheets.SheetArea.viewport).wordWrap(true);
  210. sheet.autoFitRow(row);
  211. }
  212. },
  213. setCheckBoxCell(row,col,sheet,val){
  214. var c = new GC.Spread.Sheets.CellTypes.CheckBox();
  215. c.isThreeState(false);
  216. sheet.setCellType(row, col,c,GC.Spread.Sheets.SheetArea.viewport);
  217. sheet.getCell(row, col).value(val);
  218. sheet.getCell(row, col).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
  219. },
  220. setComboBox(row,col,sheet,options,editorValueType){
  221. //let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
  222. let dynamicCombo = sheetCommonObj.getDynamicCombo(true);
  223. if(options){
  224. dynamicCombo.itemHeight(options.length).items(options);
  225. if(editorValueType==true){
  226. dynamicCombo.editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
  227. }
  228. }
  229. sheet.setCellType(row, col,dynamicCombo,GC.Spread.Sheets.SheetArea.viewport);
  230. },
  231. setRowStyle(row,sheet,bgColour) {
  232. if(bgColour){
  233. let style = new GC.Spread.Sheets.Style();
  234. style.backColor = bgColour;
  235. style.borderLeft = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
  236. style.borderTop = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
  237. style.borderRight = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
  238. style.borderBottom = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
  239. sheet.setStyle(row, -1, style);
  240. }
  241. },
  242. analyzePasteData: function(setting, pastedInfo) {
  243. var rst = [], propId = pastedInfo.cellRange.col, preStrIdx = 0, itemObj = {};
  244. for (var i = 0; i < pastedInfo.pasteData.text.length; i++) {
  245. if (pastedInfo.pasteData.text[i] === "\n") {
  246. propId = pastedInfo.cellRange.col;
  247. preStrIdx = i + 1;
  248. rst.push(itemObj);
  249. if (i < pastedInfo.pasteData.text.length - 1) {
  250. itemObj = {};
  251. }
  252. } else if (pastedInfo.pasteData.text[i] === "\t" || pastedInfo.pasteData.text[i] === "\r") {
  253. if (setting.header[propId]) {
  254. itemObj[setting.header[propId].dataCode] = pastedInfo.pasteData.text.slice(preStrIdx, i);
  255. }
  256. propId++;
  257. preStrIdx = i + 1;
  258. //if the last copied-cell were empty, should check whether the end of text
  259. if (i == pastedInfo.pasteData.text.length - 1 && setting.header[propId]) {
  260. itemObj[setting.header[propId].dataCode] = pastedInfo.pasteData.text.slice(preStrIdx);
  261. rst.push(itemObj);
  262. }
  263. } else if (i == pastedInfo.pasteData.text.length - 1 && setting.header[propId]) {
  264. itemObj[setting.header[propId].dataCode] = pastedInfo.pasteData.text.slice(preStrIdx);
  265. rst.push(itemObj);
  266. }
  267. }
  268. return rst;
  269. },
  270. combineRowData: function(sheet, setting, row) {
  271. var rst = {};
  272. for (var col = 0; col < setting.header.length; col++) {
  273. rst[setting.header[col].dataCode] = sheet.getValue(row, col);
  274. }
  275. return rst;
  276. },
  277. shieldAllCells: function(sheet) {
  278. sheet.options.isProtected = true;
  279. },
  280. unShieldAllCells: function(sheet) {
  281. sheet.options.isProtected = false;
  282. },
  283. unLockAllCells: function (sheet) {
  284. sheet.suspendPaint();
  285. sheet.suspendEvent();
  286. let defaultStyle = new GC.Spread.Sheets.Style();
  287. defaultStyle.locked = false;
  288. sheet.setDefaultStyle(defaultStyle, GC.Spread.Sheets.SheetArea.viewport);
  289. sheet.setStyle(-1, 0, defaultStyle);
  290. sheet.options.isProtected = false;
  291. sheet.resumePaint();
  292. sheet.resumeEvent();
  293. },
  294. lockAllCells: function (sheet) {
  295. sheet.suspendPaint();
  296. sheet.suspendEvent();
  297. let defaultStyle = new GC.Spread.Sheets.Style();
  298. defaultStyle.locked = true;
  299. sheet.setDefaultStyle(defaultStyle, GC.Spread.Sheets.SheetArea.viewport);
  300. for(let i = 0; i < sheet.getRowCount(); i++){
  301. sheet.setStyle(i, 0, defaultStyle);
  302. }
  303. sheet.options.isProtected = true;
  304. sheet.resumePaint();
  305. sheet.resumeEvent();
  306. },
  307. lockCells: function(sheet, setting){
  308. sheet.suspendPaint();
  309. sheet.suspendEvent();
  310. if (setting && setting.view.lockColumns && setting.view.lockColumns.length > 0) {
  311. sheet.options.isProtected = true;
  312. sheet.getRange(-1, 0, -1, setting.header.length, GC.Spread.Sheets.SheetArea.viewport).locked(false);
  313. for (var i = 0; i < setting.view.lockColumns.length; i++) {
  314. sheet.getRange(-1,setting.view.lockColumns[i] , -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
  315. }
  316. }
  317. sheet.resumePaint();
  318. sheet.resumeEvent();
  319. },
  320. setLockCol: function (sheet, col, isLocked) {
  321. sheet.suspendPaint();
  322. sheet.suspendEvent();
  323. for(let row = 0, len = sheet.getRowCount(); row < len; row++){
  324. sheet.getCell(row, col).locked(isLocked);
  325. }
  326. sheet.resumePaint();
  327. sheet.resumeEvent();
  328. },
  329. chkIfEmpty: function(rObj, setting) {
  330. var rst = true;
  331. if (rObj) {
  332. for (var i = 0; i < setting.header.length; i++) {
  333. if (rObj[setting.header[i].dataCode]) {
  334. rst = false;
  335. break;
  336. }
  337. }
  338. }
  339. return rst;
  340. },
  341. //add by zhong 2017-10-10
  342. //动态下拉框
  343. getDynamicCombo: function () {
  344. let ComboCellForActiveCell = function () { };
  345. ComboCellForActiveCell.prototype = new GC.Spread.Sheets.CellTypes.ComboBox();
  346. ComboCellForActiveCell.prototype.paintValue = function (ctx, value, x, y, w, h, style, options) {
  347. let sheet = options.sheet;
  348. if (options.row === sheet.getActiveRowIndex() && options.col === sheet.getActiveColumnIndex()) {
  349. GC.Spread.Sheets.CellTypes.ComboBox.prototype.paintValue.apply(this, arguments);
  350. } else {
  351. GC.Spread.Sheets.CellTypes.Base.prototype.paintValue.apply(this, arguments);
  352. }
  353. };
  354. ComboCellForActiveCell.prototype.getHitInfo = function (x, y, cellStyle, cellRect, options) {
  355. let sheet = options.sheet;
  356. if (options.row === sheet.getActiveRowIndex() && options.col === sheet.getActiveColumnIndex()) {
  357. return GC.Spread.Sheets.CellTypes.ComboBox.prototype.getHitInfo.apply(this, arguments);
  358. } else {
  359. return GC.Spread.Sheets.CellTypes.Base.prototype.getHitInfo.apply(this, arguments);
  360. }
  361. };
  362. return new ComboCellForActiveCell();
  363. },
  364. setDynamicCombo: function (sheet, beginRow, col, rowCount, items, itemsHeight, itemsType) {
  365. let me = this;
  366. sheet.suspendPaint();
  367. let combo = me.getDynamicCombo();
  368. if(itemsHeight) {
  369. combo.itemHeight(itemsHeight);
  370. combo._maxDropDownItems = itemsHeight + 5;
  371. }
  372. if(itemsType === 'value') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
  373. else if(itemsType === 'text') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.text);
  374. else combo.items(items);
  375. for(let i = 0, len = rowCount; i < len; i++){
  376. sheet.getCell(beginRow + i, col).cellType(combo);
  377. }
  378. sheet.resumePaint();
  379. },
  380. setStaticCombo: function (sheet, beginRow, col, rowCount, items, itemsHeight, itemsType) {
  381. sheet.suspendPaint();
  382. let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
  383. for(let i = 0, len = rowCount; i < len; i++){
  384. if(itemsHeight) combo.itemHeight(itemsHeight);
  385. if(itemsType === 'value') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
  386. else if(itemsType === 'text') combo.items(items).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.text);
  387. else combo.items(items);
  388. sheet.getCell(beginRow + i, col).cellType(combo);
  389. }
  390. sheet.resumePaint();
  391. },
  392. //注册自定义回车键事件
  393. bindEnterKey: function (workBook, operation) {
  394. workBook.commandManager().register('myEnter', operation);
  395. workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.enter, false, false, false, false);
  396. workBook.commandManager().setShortcutKey('myEnter', GC.Spread.Commands.Key.enter, false, false, false, false);
  397. },
  398. //解决esc后触发了编辑结束的保存事件,显示与实际数据不同问题
  399. bindEscKey: function (workBook, sheets) {
  400. function isDef(v){
  401. return typeof v !== 'undefined' && v !== null;
  402. }
  403. workBook.commandManager().register('myEsc', function () {
  404. let activeSheet = workBook.getActiveSheet();
  405. let hasTheSheet = false;
  406. for(let sheetObj of sheets){
  407. let sheet = sheetObj.sheet;
  408. if(sheet === activeSheet){
  409. hasTheSheet = true;
  410. let editStarting = sheetObj.editStarting;
  411. let editEnded = sheetObj.editEnded;
  412. if(editStarting){
  413. sheet.unbind(GC.Spread.Sheets.Events.EditStarting);
  414. }
  415. if(editEnded){
  416. sheet.unbind(GC.Spread.Sheets.Events.EditEnded);
  417. }
  418. let row = sheet.getActiveRowIndex();
  419. let col = sheet.getActiveColumnIndex();
  420. let orgV = sheet.getValue(row, col);
  421. if(!isDef(orgV)){
  422. orgV = '';
  423. }
  424. if(sheet.isEditing()){
  425. sheet.endEdit();
  426. sheet.setValue(row, col, orgV);
  427. }
  428. if(editStarting){
  429. sheet.bind(GC.Spread.Sheets.Events.EditStarting, editStarting);
  430. }
  431. if(editEnded){
  432. sheet.bind(GC.Spread.Sheets.Events.EditEnded, editEnded);
  433. }
  434. }
  435. }
  436. //容错处理,以防没把所有工作簿的表格信息传入参数
  437. if(!hasTheSheet){
  438. if(activeSheet.isEditing()){
  439. activeSheet.endEdit();
  440. }
  441. }
  442. });
  443. workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.esc, false, false, false, false);
  444. workBook.commandManager().setShortcutKey('myEsc', GC.Spread.Commands.Key.esc, false, false, false, false);
  445. },
  446. //生成列字段与列号映射
  447. initColMapping: function (obj, headers) {
  448. //colToField 列下标与列字段映射
  449. //fieldToCol 列字段与列下标映射
  450. let colMapping = {colToField: {}, fieldToCol: {}};
  451. for(let header of headers){
  452. colMapping['colToField'][headers.indexOf(header)] = header.dataCode;
  453. colMapping['fieldToCol'][header.dataCode] = headers.indexOf(header);
  454. }
  455. console.log(colMapping);
  456. obj.colMapping = colMapping
  457. },
  458. //动态根据工作簿宽度和各列宽度比例设置宽度
  459. setColumnWidthByRate: function (workBookWidth, workBook, headers){
  460. if(workBook){
  461. const sheet = workBook.getActiveSheet();
  462. sheet.suspendEvent();
  463. sheet.suspendPaint();
  464. for(let col = 0; col < headers.length; col++){
  465. if(headers[col]['rateWidth'] !== undefined && headers[col]['rateWidth'] !== null && headers[col]['rateWidth'] !== ''){
  466. sheet.setColumnWidth(col, workBookWidth * headers[col]['rateWidth'], GC.Spread.Sheets.SheetArea.colHeader)
  467. }
  468. else {
  469. if(headers[col]['headerWidth'] !== undefined && headers[col]['headerWidth'] !== null && headers[col]['headerWidth'] !== ''){
  470. sheet.setColumnWidth(col, headers[col]['headerWidth'], GC.Spread.Sheets.SheetArea.colHeader)
  471. }
  472. }
  473. }
  474. sheet.resumeEvent();
  475. sheet.resumePaint();
  476. }
  477. },
  478. renderSheetFunc: function (sheet, func){
  479. sheet.suspendEvent();
  480. sheet.suspendPaint();
  481. if(func){
  482. func();
  483. }
  484. sheet.resumeEvent();
  485. sheet.resumePaint();
  486. }
  487. }