php - PHPExcel - Formatting gets lost when editing from code -
I'm playing with a PHP-MS Excel integration these days my work is to open an existing spreadsheet, add some data And save the spreadsheet filled in as a new file. In fact, a template-filling engine is used as EventHow XLSX files templates.
I saw which good framework seems to have been implemented to implement the proof of the concept (minimum required to minimize the minimum required to make this clear):
$ objReader = PHPExcel_IOFactory :: createReader ('Excel2007'); $ ObjReader- & gt; SetReadDataOnly (true); $ ObjPHPExcel = $ objReader-> Load ("myTemplateToFill.xlsx"); // Here the actual filling $ objWorksheet = $ objPHPExcel- & gt; Create Sheet (); $ ObjWorksheet- & gt; Setitle ('apple'); $ ObjWorksheet- & gt; Set Selwell ('A1', 'Banana'); $ ObjPHPExcel- & gt; SetActiveSheetIndex (0); $ ObjWriter = new PHPExcel_Writer_Excel2007 ($ objPHPExcel); $ ObjWriter- & gt; Save ('myFilledTemplate.xlsx');
To run it I found that a new file has been created, my tooth is inserted, but unfortunately all existing formatting is lost.
So the question is is there a way to keep those formatting in PHPExcel new file? Or to move forward: Is it possible to keep charts etc in the template file and it is possible to fill in the way I have tried?
Thanks in advance for all your experiences!
We, you are doing a new job, the default form of which the default form There is no format from I think that you have to add your values to the existing sheet?
$ objPHPExcel-> Set ActiveShot Index (0); // Index of Sheets workSheet = $ objPHPExcel-> GetActiveSheet (); $ WorkSheet- & gt; SetTitle ('Pflaume');
Comments
Post a Comment