Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Improve writeCsvLine
  • Loading branch information
vinivf committed May 30, 2016
commit 668bf86bbc79d16d1ac1197fe6b74dbe5f6eca46
21 changes: 13 additions & 8 deletions xlsxwriter.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,13 @@ protected function initializeSheet($sheet_name)
$sheet->file_writer->write( '<sheetData>');
}

public function writeSheetHeader($sheet_name, array $header_types)
{
if (empty($sheet_name) || empty($header_types) || !empty($this->sheets[$sheet_name]))
public function writeSheetHeader($sheet_name, array $header_types, $format = 'xlsx') {
if (empty($sheet_name) || empty($header_types) || !empty($this->sheets[$sheet_name])) {
return;
}
if ($format == 'csv') {
$this->writeCSVLine($header_types, true);
}

self::initializeSheet($sheet_name);
$sheet = &$this->sheets[$sheet_name];
Expand All @@ -156,15 +159,17 @@ public function writeSheetHeader($sheet_name, array $header_types)
$this->current_sheet = $sheet_name;
}

public function writeSheetRow($sheet_name, array $row)
{
if (empty($sheet_name) || empty($row))
public function writeSheetRow($sheet_name, array $row, $format = 'xlsx') {
if (empty($sheet_name) || empty($row)) {
return;
}
if ($format == 'csv') {
$this->writeCSVLine($row);
}

self::initializeSheet($sheet_name);
$sheet = &$this->sheets[$sheet_name];
if (empty($sheet->cell_formats))
{
if (empty($sheet->cell_formats)) {
$sheet->cell_formats = array_fill(0, count($row), 'string');
}

Expand Down