These days I play with PHP integration - MS Excel. My job is to open an existing table, add some data and save the filled table as a new file. Basically, this is a way to populate a template, eventhough xlsx are used as templates.
I looked at PHPExcel , which looks pretty good. In order to implement the proof of concept, I did the following (minimized to illustrate what I need to do):
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load("myTemplateToFill.xlsx");
$objWorksheet = $objPHPExcel->createSheet();
$objWorksheet->setTitle('Apple') ;
$objWorksheet->setCellValue('A1', 'Banana');
$objPHPExcel->setActiveSheetIndex(0);
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->save('myFilledTemplate.xlsx');
Running this, I found that a new file is being created, my daat is inserted, but, unfortunately, all existing formatting is lost.
, , PHPExcel formattigs
? : ..
, ?
!