Export HTML Table to Excel with TableExport (No jQuery) — Copy-Ready Code


Programming Export HTML Table to Excel with TableExport (No jQuery) — Copy-Ready Code

15 Aug 2024 18:00 819 reads

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

1) Include the library files



2) Create a simple HTML table

  • This is the data we will export to .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

3) Add the Export button + vanilla JS

  • No jQuery needed. We instantiate 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.


Please rate your satisfaction with this article

Star 1 Star 2 Star 3 Star 4 Star 5

Post a Comment
Your email address will not be displayed to others. Required fields are marked *

CAPTCHA





Recommended Content

How to reset your iPhone when it is locked with the message
(01/02/2025 12:00)
If your iPhone shows the message "iPhone Unavailable" and you can’t unlock it, you’ll need to perform a Factory Reset a…
Read more
What is og : Open Graph, and what is its significance in SEO for Facebook and social media?
(07/08/2024 11:15)
Open Graph is a protocol developed by Facebook that is used to connect websites with social media platforms through the…
Read more
How to Add the Facebook Comments Plugin to Your Website — Full Guide + Code
(07/08/2024 11:15)
Using the Facebook Comments Plugin on your website is a great way to increase user engagement and make it easy for them…
Read more
Import Excel to PHP with phpoffice/phpspreadsheet – Step-by-Step Guide with Code
(06/08/2024 10:00)
phpoffice/phpspreadsheet is a popular PHP library used for working with Excel files, including creating new files, read…
Read more