您好,我没太明白您的意思,您是指当作为表格容器的div为隐藏时,表格无法正常创建吗?我写了一个Demo您参考一下,如果没能理解对您的意思,请您回帖指出。
JS代码:
- $(document).ready(function () {
- var spread = new GC.Spread.Sheets.Workbook(document.getElementById('ss'), {
- sheetCount: 1
- });
- initSpread(spread);
- });
- function initSpread(spread) {
- var activeSheet = spread.getSheet(0);
- activeSheet.suspendPaint();
- var scale = new GC.Spread.Sheets.ConditionalFormatting.ScaleRule();
- scale.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.threeScaleRule);
- scale.midColor("red");
- scale.midType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
- scale.midValue(50);
- scale.maxColor("blue");
- scale.maxType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
- scale.maxValue(100);
- scale.minColor("yellow");
- scale.minType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
- scale.minValue(10);
- scale.ranges([new GC.Spread.Sheets.Range(0, 0, 10, 10)]);
- activeSheet.conditionalFormats.addRule(scale);
- activeSheet.setValue(0,0, 10,3);
- activeSheet.setValue(1,0, 20,3);
- activeSheet.setValue(2,0, 30,3);
- activeSheet.setValue(3,0, 40,3);
- activeSheet.setValue(4,0, 50,3);
- activeSheet.setValue(5,0, 60,3);
- activeSheet.setValue(6,0, 70,3);
- activeSheet.setValue(7,0, 80,3);
- activeSheet.setValue(8,0, 90,3);
- activeSheet.setValue(9,0, 100,3);
- activeSheet.options.isProtected = true;
- activeSheet.resumePaint();
- $("#show").bind("click", function () {
- $("#ss").show();
- })
- $("#hide").bind("click", function () {
- $("#ss").hide();
- })
- }
复制代码
HTML代码:
- <html>
- <head>
- <meta charset="UTF-8" />
- <link rel="stylesheet" type="text/css" href="resources/css/spread/gc.spread.sheets.excel2013white.11.2.2.css">
- <script src="resources/js/jquery-1.8.2.min.js" type="text/javascript"></script>
- <script src="resources/js/spread/gc.spread.sheets.all.11.2.2.min.js" type="text/javascript"></script>
- <script src="resources/js/spread/gc.spread.sheets.resources.zh.11.2.2.min.js" type="text/javascript"></script>
- <script src="CellFormats.js" type="text/javascript"></script>
- </head>
- <body>
- <div id='ss' style='width:100%; height:800px; display: none;'></div>
- <button id="show">显示表格</button>
- <button id="hide">隐藏表格</button>
- </body>
- </html>
复制代码 |