LODOP Export and write excel test

LODOP have export excel method, there are methods to write files can be written to excel.
SAVE_TO_FILE : deriving only a table, (with ADD_PRINT_TABLE output, and which contains table)
if a plurality of contents tale tag, the output of the first table default label.
WRITE_FILE_TEXT : write excel, can write a plurality of tables, the table may be written outside.

Both output effect of this blog to see pictures and test code, test code is exported d1 this div, SAVE_TO_FILE export only d1 in the first label, WRITE_FILE_TEXT export all content.

Others excel Bowen:

Test code:

<script language="javascript" src="LodopFuncs.js"></script>
</head>
<body>
<div id="d1">
<p>table外的文字</p>
<table width="100%" border=1 style="border-collapse:collapse;">
<tr>
    <td id="td1">12</td>
    <td id="td2">12</td>
</tr>
<tr>
    <td id="td3">14</td>
    <td id="td4">3</td>
</tr>
<tr>
    <td>cccccc</td>
    <td>dddd</td>
</tr>
</table>
<table width="100%" border=1 style="border-collapse:collapse;">
<tr>
    <td id="td1">33</td>
    <td id="td2">44</td>
</tr>
<tr>
    <td id="td3">55</td>
    <td id="td4">66</td>
</tr>
<tr>
    <td>eeeec</td>
    <td>fffff</td>
</tr>
</table>
</div>
<a href="javascript:OutToFileOneSheet()">save默认的</a><br>
<a href="javascript:OutToFileOneSheet2()">write默认的</a><br>
<script language="javascript" type="text/javascript">   
        var LODOP; //声明为全局变量 
    function OutToFileOneSheet(){ 
        LODOP=getLodop();   
        LODOP.PRINT_INIT(""); 
        LODOP.ADD_PRINT_TABLE(100,20,500,60,document.getElementById("d1").innerHTML); 
        LODOP.SAVE_TO_FILE("saveDef.xlsx"); 
        };
    function OutToFileOneSheet2(){ 
        LODOP= GetLodop ();    
        LODOP.PRINT_INIT ( "" ); 
        LODOP.ADD_PRINT_TABLE ( 100 , 20 is , 500 , 60 , document.getElementById ( " D1 " ) .innerHTML); // this sentence need not 
        LODOP.WRITE_FILE_TEXT ( " UTF . 8 " , " D: \\ AAA .... omitted part of the filename QA1 \\ \\ writeDef.xls LU ... " , document.getElementById ( " D1 " ) .innerHTML); 
        }; 
</ Script > 

Icon:

Guess you like

Origin www.cnblogs.com/huaxie/p/12143560.html