Skip to content
Open
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
update add row data
update for difficult structure
[[0=>"first",2=>"third"],[1=>"second",3=>"forth"]]
  • Loading branch information
DarkVss authored Mar 5, 2021
commit 19cc7f8b27f6fead990509e9aa8dcbe59940631a
16 changes: 9 additions & 7 deletions xlsxwriter.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,15 @@ public function writeSheetRow($sheet_name, array $row, $row_options=null)
}

$style = &$row_options;
$c=0;
foreach ($row as $v) {
$number_format = $sheet->columns[$c]['number_format'];
$number_format_type = $sheet->columns[$c]['number_format_type'];
$cell_style_idx = empty($style) ? $sheet->columns[$c]['default_cell_style'] : $this->addCellStyle( $number_format, json_encode(isset($style[0]) ? $style[$c] : $style) );
$this->writeCell($sheet->file_writer, $sheet->row_count, $c, $v, $number_format_type, $cell_style_idx);
$c++;
$rowKeys = array_key($row);
$maxCellIndex = end($rowKeys);
for($cellIndex = 0; $cellIndex <= $maxCellIndex; $cellIndex++){
$value = $row[$cellIndex] ?? '';

$number_format = $sheet->columns[$cellIndex]['number_format'];
$number_format_type = $sheet->columns[$cellIndex]['number_format_type'];
$cell_style_idx = empty($style) ? $sheet->columns[$cellIndex]['default_cell_style'] : $this->addCellStyle( $number_format, json_encode(isset($style[0]) ? $style[$cellIndex] : $style) );
$this->writeCell($sheet->file_writer, $sheet->row_count, $cellIndex, $value, $number_format_type, $cell_style_idx);
}
$sheet->file_writer->write('</row>');
$sheet->row_count++;
Expand Down