aVadim483 / fast-excel-writer

Lightweight and very fast XLSX Excel Spreadsheet Writer in PHP
MIT License
163 stars 31 forks source link

Sum of Times #6

Closed jcabanillas closed 3 years ago

jcabanillas commented 3 years ago

Hello, The sum of times is wrong because the correct format should be [h]:mm How can I manage this format with your library?

aVadim483 commented 3 years ago

Hi! You can set the format as 'format' => 'H:MM' For example:

// Ex. #1
$rowData = ['2:55', '3:20'];
$sheet->writeRow($rowData, ['format' => 'H:MM']);

// Ex. #2
$header = [
    'Time column'   => 'H:MM',
];
$sheet->writeHeader($header);
$sheet->writeRow($rowData);

// Ex. #3
// You need define column format before wtiting data
$sheet->setColFormat('A', 'H:MM');
$sheet->writeRow($rowData);

// Ex. #4
// Write formula with format
$sheet->setValue('A3', '=A1+A2', ['format' => 'H:MM']);

// ... and so on