mk-j / PHP_XLSXWriter

Lightweight XLSX Excel Spreadsheet Writer in PHP
MIT License
1.84k stars 663 forks source link

Trouble on styling cells #344

Closed marceloguiot closed 1 year ago

marceloguiot commented 1 year ago

Hello everyone and thanks for this helpful class. I have a problem i can´t use styles in cells, i have review the examples but it looks like i have a diferent version. This is my WriteSheetRow function:

public function writeSheetRow($sheet_name, array $row) { if (empty($sheet_name) || empty($row)) return;

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

    $sheet->file_writer->write('<row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.1" outlineLevel="0" r="' . ($sheet->row_count + 1) . '">');
    $column_count = 0;
    foreach ($row as $k => $v) {
        $this->writeCell($sheet->file_writer, $sheet->row_count, $column_count, $v, $sheet->columns[$column_count]);
        $column_count++;
    }
    $sheet->file_writer->write('</row>');
    $sheet->row_count++;
    $this->current_sheet = $sheet_name;
}

As you can see i don´t have the style options and if i try to fix with the las version i get a error. there is some way to change the styles directly in the writecell function?

I want to do it in this way:

$file->write(' (HERE SOME TAGS WITH THE OPTIONS)' . self::xmlspecialchars($this->setSharedString($value)) . '');

Regards to all

mk-j commented 1 year ago

look at examples/ex03-styles.php