diff --git a/xlsxwriter.class.php b/xlsxwriter.class.php
index 91301c4c8..894eb83eb 100644
--- a/xlsxwriter.class.php
+++ b/xlsxwriter.class.php
@@ -106,7 +106,7 @@ public function writeToFile($filename)
$zip->close();
}
- protected function initializeSheet($sheet_name, $col_widths=array() )
+ protected function initializeSheet($sheet_name, $num_cols=0, $col_widths=array() )
{
//if already initialized
if ($this->current_sheet==$sheet_name || isset($this->sheets[$sheet_name]))
@@ -149,8 +149,15 @@ protected function initializeSheet($sheet_name, $col_widths=array() )
$sheet->file_writer->write( '
');
$i++;
}
+ } else if ($num_cols > 0) {
+ for ($i=0; $i<$num_cols; $i++) {
+ $sheet->file_writer->write( '');
+ }
+ } else {
+ // Some excel readers might not parse this and automatically
+ // hide all columns up to 1024 (AMK column)
+ $sheet->file_writer->write( '');
}
- $sheet->file_writer->write( '');
$sheet->file_writer->write( '');
$sheet->file_writer->write( '');
}
@@ -193,7 +200,7 @@ public function writeSheetHeader($sheet_name, array $header_types, $col_options
$style = &$col_options;
$col_widths = isset($col_options['widths']) ? (array)$col_options['widths'] : array();
- self::initializeSheet($sheet_name, $col_widths);
+ self::initializeSheet($sheet_name, count($header_types), $col_widths);
$sheet = &$this->sheets[$sheet_name];
$sheet->columns = $this->initializeColumnTypes($header_types);
if (!$suppress_row)