You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in PhpOffice/PhpSpreadsheet/Writer/Ods/Content.php there are two "Exceptions" thrown, when the datatype of the cell is either "TYPE_ERROR" or "TYPE_INLINE", because the relevant code is not yet developed.
Throwing an exception breaks the creation-process for such a document, which is not helpful. It would probably be more suitable not to "crash" the program.
What is the expected behavior?
Either develop the nessessary functionality, or as an intermediate solution, modify the content of such a cell with an error message.
In my current case, the cell values are actually "NULL". The Xlsx writer translates this to "#NV", and the Ods writer should act accordingly.
What is the current behavior?
Program throws an exception and stops processing, loosing ALL data, rather than only the unprocessable cell.
What are the steps to reproduce?
Provide input-data with actual NULL values, and then use PhpSpreadsheet writers Xlsx and Ods respectively.
To circumvent the actual issue, I out-commented the "throw exception" and write the exception-message into the cell value:
switch ($cell->getDataType()) {
case DataType::TYPE_BOOL:
$objWriter->writeAttribute('office:value-type', 'boolean');
$objWriter->writeAttribute('office:value', $cell->getValue());
$objWriter->writeElement('text:p', $cell->getValue());
break;
case DataType::TYPE_ERROR:
/*SITS*/ //throw new Exception('Writing of error not implemented yet.');
$objWriter->writeAttribute('office:value-type', 'string');
$objWriter->writeElement('text:p', 'Writing of error not implemented yet.');
break;
case DataType::TYPE_FORMULA:
$formulaValue = $cell->getValue();
if ($this->getParentWriter()->getPreCalculateFormulas()) {
try {
$formulaValue = $cell->getCalculatedValue();
} catch (Exception $e) {
// don't do anything
}
}
$objWriter->writeAttribute('table:formula', 'of:' . $cell->getValue());
if (is_numeric($formulaValue)) {
$objWriter->writeAttribute('office:value-type', 'float');
} else {
$objWriter->writeAttribute('office:value-type', 'string');
}
$objWriter->writeAttribute('office:value', $formulaValue);
$objWriter->writeElement('text:p', $formulaValue);
break;
case DataType::TYPE_INLINE:
/*SITS*/ //throw new Exception('Writing of inline not implemented yet.');
$objWriter->writeAttribute('office:value-type', 'string');
$objWriter->writeElement('text:p', 'Writing of inline not implemented yet.');
break;
case DataType::TYPE_NUMERIC:
$objWriter->writeAttribute('office:value-type', 'float');
$objWriter->writeAttribute('office:value', $cell->getValue());
$objWriter->writeElement('text:p', $cell->getValue());
break;
case DataType::TYPE_STRING:
$objWriter->writeAttribute('office:value-type', 'string');
$objWriter->writeElement('text:p', $cell->getValue());
break;
}
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.
bug report
in PhpOffice/PhpSpreadsheet/Writer/Ods/Content.php there are two "Exceptions" thrown, when the datatype of the cell is either "TYPE_ERROR" or "TYPE_INLINE", because the relevant code is not yet developed.
Throwing an exception breaks the creation-process for such a document, which is not helpful. It would probably be more suitable not to "crash" the program.
What is the expected behavior?
Either develop the nessessary functionality, or as an intermediate solution, modify the content of such a cell with an error message.
In my current case, the cell values are actually "NULL". The Xlsx writer translates this to "#NV", and the Ods writer should act accordingly.
What is the current behavior?
Program throws an exception and stops processing, loosing ALL data, rather than only the unprocessable cell.
What are the steps to reproduce?
Provide input-data with actual NULL values, and then use PhpSpreadsheet writers Xlsx and Ods respectively.
To circumvent the actual issue, I out-commented the "throw exception" and write the exception-message into the cell value:
The text was updated successfully, but these errors were encountered: