本帖最后由 q0156 于 2017-9-6 17:14 编辑
你好,这段是 在 各 版本 下 演示的代码.
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <style>
-
-
- </style>
- <meta charset="utf-8" />
- <script src="http://code.jquery.com/jquery-1.12.4.min.js"></script>
- <script src="http://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
- <!--
- <script src="http://cdn.wijmo.com/5.20172.328/controls/wijmo.min.js"></script>
- <script src="http://cdn.wijmo.com/5.20172.328/controls/wijmo.xlsx.min.js"></script>
- -->
-
- <script src="wijmo5_20172_338/wijmo.min.js"></script>
- <script src="wijmo5_20172_338/wijmo.xlsx.min.js"></script>
-
-
-
-
- <script>
- $(document).ready(function () {
- $('#btn2').click(function () {
-
- var workbook=new wijmo.xlsx.Workbook(), worksheet=new wijmo.xlsx.WorkSheet();
- workbook['company'] = 'Kyocera';
- workbook['created'] = new Date();
- worksheet['name'] = 'report';
-
-
-
- for(var i=0; i<1; i++){
- var wbRow=new wijmo.xlsx.WorkbookRow();
-
- for(var j=0; j<10; j++){
- var wbCell=new wijmo.xlsx.WorkbookCell();
- wbCell['value'] = 'test_'+j;
- wbRow.cells.push(wbCell);
- }
- worksheet.rows.push(wbRow);
- }
-
-
-
- for(var i=0; i<10; i++){
- var wbRow=new wijmo.xlsx.WorkbookRow();
-
- for(var j=0; j<10; j++){
- var wbCell=new wijmo.xlsx.WorkbookCell(), style=new wijmo.xlsx.WorkbookStyle();
-
-
- wbCell['value'] = j;
-
-
- if(j == 5){
- style['format'] = '@';
- wbCell['value'] = '00000351';
- }
-
-
- wbCell['style'] = style;
- wbCell['formula'] = null;
- wbCell['isDate'] = false;
-
- wbRow.cells.push(wbCell);
- }
- worksheet.rows.push(wbRow);
- }
-
- workbook.sheets.push(worksheet);
-
- console.log('workbook', workbook);
-
- workbook.saveAsync('report', function(base64){
-
- }, function (reason){
- console.log('The reason of save failure is ' + reason);
- });
-
- });
-
- });
- </script>
- </head>
- <body>
- <button id="btn2">Export2</button>
- <div id="theGrid" class="style1" style="height:200px;"></div>
- </body>
- </html>
复制代码 |