Is there a way to get the current style and format from an existing cell? For example: bold text and format as date.
Is there a way to get the current style and format from an existing cell? For example: bold text and format as date.
Thank you for your reply.
In general this is not a real issue, except for cells representing a date. A cell containing a date has a numeric value. Example:
// Cell A1 contains the date 01-01-2023, with cell type "date"
$cellContents = $xlsx->getCell("A1");
echo $cellContents["value"];
// this gives the integer 44927
// Cell A2 contains the number 44927, with cell type "number"
$cellContents = $xlsx->getCell("A2");
echo $cellContents["value"];
// this gives the integer 44927
Converting 44927 to 01-01-2023 is not hard knowing the Excel 1900 date format. But, without knowing the cell format, we do not know if the value represents a date or an integer.
Hello,
Yes, the case you detail can't be detected, because both values use the same data, a number. In both cases MS Excel sets a number, and the display format is set using the numFmtId attribute of the styles file:
https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_numFmt_topic_ID0EHDH6.html
There's no method in the current stable version of phpxlsx to return this information. We have opened a task to add support.
Regards.