原創(chuàng)|使用教程|編輯:龔雪|2015-07-28 09:38:59.000|閱讀 625 次
概述:Spread JS可以為表格各個(gè)區(qū)域設(shè)置不同的樣式。既可以為整個(gè)表格設(shè)置一套完整的內(nèi)置樣式,也可以為指定的區(qū)域設(shè)置特殊的樣式。是不是很酷呢?
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
1. 內(nèi)置表格樣式
通過(guò)TableStyle 類,您能夠查看所有的內(nèi)置表格樣式。
讓我們通過(guò)下面的例子:創(chuàng)建表格,并為它設(shè)置內(nèi)置樣式。
代碼如下:
1: activeSheet.addTable("Table1", 0, 0, 3, 3, GcSpread.Sheets.TableStyles.dark1()); 2: activeSheet.getCell(0,0).text("Name"); 3: activeSheet.getCell(0,1).text("Value"); 4: activeSheet.getCell(0,2).text("T/F"); 5: activeSheet.getCell(1,0).text("AW"); 6: activeSheet.getCell(1,1).text("5"); 7: activeSheet.getCell(1,2).text("T");
2. 樣式函數(shù)開啟的秘密
為什么有的樣式函數(shù)設(shè)置之后不起作用呢?那是因?yàn)橛械臉邮胶瘮?shù)所呈現(xiàn)的區(qū)域不可見或者缺乏默認(rèn)的樣式設(shè)置。例如,只有在ShowFooter值為True時(shí),lastFooterCellStyle才有機(jī)會(huì)顯示。
下表就列出了樣式函數(shù)起作用的前提條件。第一列中的SheetTable必須為true,第二列中樣式函數(shù)才能在表格對(duì)應(yīng)的區(qū)域進(jìn)行樣式呈現(xiàn)。
3. 表腳樣式示例
下面這個(gè)例子中我們?cè)O(shè)置了表腳樣式:
代碼如下:
1: $(function () { 2: var spread = new GcSpread.Sheets.Spread($("#ss")[0]); 3: var sheet = spread.getActiveSheet(); 4: 5: //Add data 6: for (var col = 1; col < 6; col++) { 7: for (var row = 2; row < 11; row++) { 8: sheet.setValue(row, col, row + col); 9: } 10: } 11: var tableStyle = new GcSpread.Sheets.TableStyle(); 12: var thinBorder = new GcSpread.Sheets.LineBorder("black", GcSpread.Sheets.LineStyle.dotted); 13: tableStyle.wholeTableStyle(new GcSpread.Sheets.TableStyleInfo("aliceblue", "green", "bold 10pt arial", 14: thinBorder, thinBorder, thinBorder, thinBorder, thinBorder, thinBorder)); 15: 16: var tStyleInfo = new GcSpread.Sheets.TableStyleInfo(); 17: tStyleInfo.backColor = "green"; 18: tStyleInfo.foreColor = "red"; 19: tStyleInfo.borderBottom = new GcSpread.Sheets.LineBorder("green", GcSpread.Sheets.LineStyle.thin); 20: tStyleInfo.borderLeft = new GcSpread.Sheets.LineBorder("yellow", GcSpread.Sheets.LineStyle.medium); 21: tStyleInfo.borderTop = new GcSpread.Sheets.LineBorder("green", GcSpread.Sheets.LineStyle.thin); 22: tStyleInfo.borderRight = new GcSpread.Sheets.LineBorder("green", GcSpread.Sheets.LineStyle.thin); 23: tStyleInfo.font = "bold 11pt arial"; 24: tableStyle.footerRowStyle(tStyleInfo); 25: var sTable = sheet.addTable("Custom", 1, 1, 10, 5, tableStyle); 26: sTable.showFooter(true); 27: //set footer value 28: sTable.setColumnValue(0, "Total"); 29: //set footer formula 30: sTable.setColumnFormula(4, "SUM(F3:F11)"); 31: }) 32: ... 33: <div id="ss" style="width:500px;height:500px"></div>
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn