0

I'm using PHPSpreadsheet to generate an XLS file with report data, and in some situations, display an XLS formatted as HTML on screen.

How can I display a formatted time range in an Excel worksheet?

I have a range of 25:30 hours that I would like to show using HH:MM:SS format, but if I use the code below it shows as 01:30:00.

$seconds = 91800;
$spreadsheet->getActiveSheet()->setCellValueExplicit('L' . $row, (seconds / 86400) , PHPExcel_Cell_DataType::TYPE_NUMERIC);
$spreadsheet->getActiveSheet()->getStyle('L'.$row)->getNumberFormat()->setFormatCode('HH:MM:SS');

If I change the time format to [HH]:MM:SS, the HTML displays a buggy result:

<span style="color:hh">[01]:30:00</span>
Tom
  • 641
  • 2
  • 8
  • 21

1 Answers1

0

Sometimes time ranges are a bit tricky. The easyer way is:

You can make a Time string with plane php and use a text column to store the data.