导出为ex​​cel时隐藏html列

我试图在php中使用头输出导出HTML表格。 我正在使用jQuery来隐藏checkbox事件的列。

我的jQuery代码来取消隐藏栏是:

$('.col').css('display','table-cell'); $('.col').css('display','none'); 

当我用隐藏的列导出我的html表时,隐藏的列仍然出现。 我想隐藏这些列,而出口到Excel使用PHP头。

感谢您的帮助提前。

我只是在寻找这个,我发现了

如何删除style =“display:none;” 导出HTML表格到Excel时的列? | ASP.NET论坛 ; 诀窍是首先克隆你的表格,然后在导出前从样式“ display:none; ”中删除所有元素:

最简单的方法(如果可以的话)可能是在提交表单之前明确地去掉任何不可见的<th><td>元素:

 // This will remove any hidden <th> or <td> elements from the DOM $("th:hidden,td:hidden").remove(); 

将现有的html克隆到一个jQueryvariables中,然后执行从该实际variables中删除:

 // When the stripped button is clicked, clone the existing source var $clonedTable = $("#my-table").clone(); // Strip your empty characters from the cloned table (hidden didn't seem to work since the cloned table isn't visible) $clonedTable.find('[style*="display: none"]').remove(); 

我写了一个小的类课程,你可以在用表单中的数据填充数组之后生成xls表单,它非常易于使用,并且可以根据您的需求进行扩展,希望有助于: http://www.anchorx。 COM / ALI / 2011/2月27日/创build电子表格与- PHP /