Please tell me the solution to the following problem: I create a price list in MS Excel (xlsx) format using PHPExcel. To do this, in the previously created price list template file (in fact, only the header in the template and customized fields, font, etc.) write data, then apply styles (cell borders, etc.) and save the file under a different name on server. The code works fine, BUT, in the preview mode before printing, I see absolutely empty pages, the number of which is equal to the number of pages created ??? In the code, I do not refer to the cells of such sheets? Sheet properties and stuff are set correctly. Why "at the exit" blank sheets are obtained (once again, their number corresponds to the number of sheets filled with these sheets)?

  • and on print what? I did understand correctly that the document is filled, but the text is not visible only in the preview? Is the print area correctly marked? - teran
  • Naturally, I did not send for printing, but in the preview there are exactly twice as many sheets (namely printed ones). Interestingly, the footer (page of pages) is on all sheets, through line (well, numbering of headings) only on filled sheets ??? Here I chose from the database of goods that fit 50 pages, and I have 100 ??? Fifty of them are empty. The number of selected records from the database coincides with the number of rows in the Excel sheet. Those. my php-code does not refer to these sheets at all ??? It is completely empty. The last call to the cells is setting the borders of the cells (grid tables). - Vyacheslav Kirichenko

1 answer 1

I came to the conclusion that PHPExcel independently, after writing data to a template file and saving it as a new file, changes the borders (width) of the sheet. This can be seen in the page layout mode (in Excel) - new borders appear and a column from the neighboring sheet is captured (everything is fine in the template, php code does not change anything). Hence the appearance of new blank pages for printing. Everything was decided simply banal - set the print area before saving the file $ page-> getPageSetup () -> setPrintArea ('A1: E'. $ Row) ;.