Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

moctarss's avatar

How to export HTML table into an Excel file?

I have this excel file that i imported and displayed into my html table.

ID Number, Name, Address, DOB, ....

Then i made a button to export it into another excel file by selecting some column to be exported. For example user can select if he wants to export only the ID Number and Name of Person or ID Number and Passport Number etc. What i did was during my import i create a hidden input and put my list there: <input type="hidden" name="lt_employees" value="{{ json_encode($employees, TRUE) }}"> but upon submitting the button i receive this on my page:

This site can’t be reached
The webpage at http://127.0.0.1:8000/home/exportexcel?lt_employees=%5B%7B"id_number"%3A101064%2C"person"%3A%7B"name"%3A"John+III+Holmes+Buck"%2C"gender"%3A"Male"%2C"country"%3A""%2C"mobile_number"%3A12345678%2C"dob"%3A"01-Jan-95"%2C"blood_group"%3A"AB%2B"%2C"primary_email_address"%3A"john%40hotmail.com"%2C"passports"%3A%5B%7B"active"%3A1%2C"passport_number"%3A"L961851"%7D%5D%2C"moi_infos"%3A%5B%7B"iq_number"%3A"9500155284"%2C"status"%3A"Active"%7D%5D%2C"credentials"%3A%5B%7B"serial_number"%3A"11123457111"%2C"credential_type"%3A"Student+Council"%2C"date_expiry"%3A"01-Jun-20"%7D%5D%7D%2C"employee_level"%3A1%2C"employee_degree"%3A11%2C"mrn"%3A"11124549902"%2C"contracts"%3A%5B%7B"status"%3A"Active"%2C"job"%3A%7B"name"%3A"Senior+Rigistrar"%2C"category"%3A%7B"code"%3A1000%7D%7D%2C"basic_salary"%3A"26600"%2C"date_of_hire"%3A"15-Oct-04"%2C"department"%3A%7B"name"%3A"Administration"%7D%2C"pcn"%3A%7B"control_number"%3A"AD0414"%7D%2C"job_type"%3A"Senior+Registrar"%2C"contract_type"%3A"Local+"%2C"end_date"%3A"14-Oct-20"%7D%5D%7D%2C%7B"&submit= might be temporarily down or it may have moved permanently to a new web address.

where my button is from a form <form action="/home/exportexcel" name="lt-export-modal" id="lt-export-modal"> that points to my function below:

public function exportExcel(Request $request){
    //This is where i am going to manipulate the process.
    dd($request);
}
0 likes
4 replies
bobbybouwmann's avatar

@moctarss The Laravel Excel package is a wrapper around the PhpSpreadsheet package, so there shouldn't be any issues ;)

Please or to participate in this conversation.