Xls generation

There is a table:

, , , , ,

The question is: how can I save all this in xls using php and provide it to the user for download?


Answer 1, authority 100%


Answer 2, authority 50%

  • There is a library for this called “Spreadsheet_Excel_Writer“.
  • It is also possible to create without third-party libraries, in a simplified form, i.e. no coloring of cells, font sizes and formulas. Just write any data in the desired cells. Look here.

Answer 3, authority 50%

If there are no decorations (adjusting the width of columns, boldness, color, etc.), then you can simply select the desired cells and write them out to any file as strings or into a variable, which is then issued to the user as a file. On each line, your fields are separated by a semicolon. Give the file extension CSV.
And if it is necessary with the design, then we take third-party libraries to work with esel. For example, I prefer PHPExcel(as an example, here is a simple description filling the file).


Answer 4

If XLSX suits you (for the latest versions of office), then there is just XML, which is not a problem to generate. That is, we take the finished .xlsx, look where what needs to be added by adding one more line and generate…


Answer 5

Do you want a simple XLS save?

Take all the information you need and write it to a file in the form of an HTML table stupidly and put the .xls extension on the file. you will be happy soon 🙂