Hiding/Removing empty columns from the export (XLS)
-
Has anybody modified this code to work with the XLS option instead of CSV?
@session_start(); add_filter( "woe_csv_header_filter", function( $headers) { $_SESSION['woe_rows']= array(); return $headers; }); //save all rows to array add_filter( "woe_csv_custom_output_func", function($custom_output,$handle,$data,$delimiter,$linebreak,$enclosure,$is_header) { $_SESSION['woe_rows'][] = array_values($data); return true; },10,7); add_action( "woe_csv_print_footer", function($handle, $formatter ){ $header = reset($_SESSION['woe_rows']); foreach($header as $col=>$name) { $col_empty = true; for($i=1;$i<count($_SESSION['woe_rows']);$i++) { if( !empty($_SESSION['woe_rows'][$i][$col])) $col_empty = false; } if($col_empty) for($i=0;$i<count($_SESSION['woe_rows']);$i++) unset($_SESSION['woe_rows'][$i][$col]); } //done foreach($_SESSION['woe_rows'] as $row) fputcsv($handle,$row); },10,2);
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Hiding/Removing empty columns from the export (XLS)’ is closed to new replies.