Formatting issues on HTML/PDF output #418
Description
This is a merge from issue created at Codeplex (https://phpexcel.codeplex.com/workitem/21190) and pull request #410. Whenever this issue is updated I'll close the Codeplex one.
_____________ Codeplex:
Whenever a conditional format is used within the PHPExcel_Style_NumberFormat, the HTML and PDF output are double escaped, displaying the in the output.
The reason is behind a double escape issue, with a proposed fix in a pull request I've submitted at: #410
Here's an example test code:
objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()
->setCellValue('A1', '-0.5')
->setCellValue('A2', '-0.25')
->setCellValue('A3', '0.0')
->setCellValue('A4', '0.25')
->setCellValue('A5', '0.5')
->setCellValue('A6', '0.75')
->setCellValue('A7', '1.0')
->setCellValue('A8', '1.25')
;
$objPHPExcel->getActiveSheet()->getStyle('A1:A8')
->getNumberFormat()
->setFormatCode('0.00;[Red]-0.00');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('test.xlsx');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
$objWriter->save('test.html');
Excel output works as expected, but HTML/PDF have escaping problems (the PDF Writer is based on the HTML for this purpose).
I'd also like to make available the cell comments in the HTML/PDF output, could I work on it? Is there any advice/rules to follow?
_________ pull request:
Still focusing the HTML Writer support, the styles generated are incompatible with the HTML structure used: at the style element you set column widths to col.colX while the table structure used td with the class as .columnX
Another issue: setting the td width has no apparently effect, leaving the HTML cells plainly different than the Excel or PDF versions — but if you switch it to min-width
then you have a fully compatible layout. Both these updates are at the commit https://github.com/capile/PHPExcel/commit/4673d188fd0fdc9ab9ce9f75ddcde9f962528a34 available at this pull request.
Just checked and both issues are still buggy in develop branch.
Thanks,
Guilherme Capilé