简体   繁体   中英

PHP: Export Table to Excel Without Hidden Columns

I'm trying to export a table from PHP in Excel. Everything is fine, but I need to hide some columns, using JQuery, in PHP. When I export the table with hidden colums to Excel, the hidden columns appear with zero values.

This is the code that I'm using:

import_request_variables('P');
$title="Table Results";
$var= "Content-Disposition: attachment; filename=".$title.".xls";
header('Content-type: application/vnd.ms-excel');
header($var);
echo $_POST['tableExcel'];

tableExcel is a form with the table.

Is there a way to not include hidden columns when I export to Excel?
Thank you

header('Content-type: application/vnd.ms-excel');

This is not an HTML filetype. In order to manipulate HTML, a script command or inline script is required within the HTML to able to call the jQuery. Unless your Excel program has some sort of jQuery emulator, you are asking to do something that is not possible for this filetype.

If this was HTML however, you could do this:

$('#myColumnId').css('display','none');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM