Programming › Export HTML Table to Excel with TableExport (No jQuery) — Copy-Ready Code
From our previous article about importing Excel data with phpoffice/phpspreadsheet, let’s now see how to export an HTML table to an Excel file. Below is a minimal, working setup using the vanilla (non-jQuery) version of TableExport.
If you need the import tutorial, read: Import Excel with PHP using phpoffice/phpspreadsheet
.xlsx.First name |
Last name |
Sex |
Mobile |
|---|---|---|---|
Mr. A |
AAA |
Male |
123456 |
Mr. B |
BBB |
Male |
78910 |
Ms. C |
CCC |
Female |
111213 |
Mr. D |
DDD |
Male |
141516 |
Ms. E |
EEE |
Female |
171819 |
TableExport, then call export2file.
That’s it — click the button and your table will download as an .xlsx file. You can change the formats option to also support CSV or TXT.