2017-03-13 24 views
0

我使用table2excel.js出口HTML到Excel,它是工作的罚款。我想根据条件更改行或列的颜色。可能吗?的Excel格式table2excel.js

<table id="ExcelTable" style="text-align: left;display:none"> 
    <tr class="rpthide"> 
     <td class="Supplier" style="font-size:14px;"></td> 
     <td class="ContractNo" style="font-size:14px;"></td> 
     <td class="OrderNo" style="font-size:14px;"></td> 
     <td class="Article" style="font-size:14px;"></td> 
     <td class="Ordered" style="font-size:14px;"></td> 
     <td class="ContainerNo" style="font-size:14px;"></td> 
     <td class="ETA" style="font-size:14px;"></td> 
     <td class="Dispatched" style="font-size:14px;"></td> 
     <td class="AtPort" style="font-size:14px;"></td> 
     <td class="Arrived" style="font-size:14px;"></td> 

    </tr> 
</table> 

$("#ExcelTable").table2excel({ 
       // exclude CSS class 
       exclude: ".noExl", 
       name: "Yarn Status List", 
       filename: "Yarn Status List" //do not include extension 
      }); 
+0

你能提供代码显示你已经想出这么远? – Arg0n

+0

你办公室的excel版本是什么?我无法在我的电脑中打开生成的文件 –

回答

0

我建议你使用像为ExcellentExport.js 可以应用任何CSS样式的HTML表格更好的工具,他们将在输出端输出。

用法示例:

<script src="excellentexport.js"></script> 

<table id="ExcelTable"> 
    <tr> 
    <td style="color:red">Column 1</td> 
    <td style="color:blue">Column 2</td> 
    <td style="color:green; font-weight:bold">Column 3</td> 
    </tr> 
    <tr style="color: purple"> 
    <td>400</td> 
    <td>500</td> 
    <td>600</td> 
    </tr> 
</table> 

<a download="myFile.xls" href="#" onclick="return ExcellentExport.excel(this, 'ExcelTable', 'Sheet1');">Export to Excel</a>