Export HTML Table Data to Excel using JavaScript

Export HTML Table Data to Excel using JavaScript

CodexWorld

3 года назад

23,117 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

magda7373
magda7373 - 29.07.2023 21:36

in my previous comment is said to move the style section out of the ttable section. I meant, move it our of the thead section.

Ответить
magda7373
magda7373 - 29.07.2023 21:24

Hello, CodeX-World, I found a solution to exporting to excel from my previous problem. I was only getting one blank line of data on the table knowing that my table included n rows and n columns. What I did, was to move the STYLE section of the table to be exported ( because I have 2 tables) OUT of the "ttable" section and move it ABOVE the table (does not need to be inside the script tags). After that, I saved, refreshed my table and though I still got the same message alert from Excel before dumping I said yes to open the page. When it opened, the data was there with headers and data and all - complete. Thanks, for your algorithm. It's not as complex as other presentations. (July 29, 2023)

Ответить
magda7373
magda7373 - 29.07.2023 00:44

I went to your website and downloaded the code and tried to follow as much as possible. When I clicked the button, it opened the save as dialogue box and then when i tried to open it in Excel, it returned a message: 'The file you are trying to open ' MyHTMLtable-ToExcel.xls' is in a different format other than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to continue?" I pressed yes and it opened the file in Excel (MS Excel 2007) with a blank entry at cells A1. I checked the excel file length and it was only 1k. I had 36 rows and 9 columns of data in the table.
I put an alert to view the downloadLink variable and it returns blank: alert("downloadLink: " + downloadLink);
Apparently your code created an 'anchor' ("a") element. My alert should have returned an object reference but it was blank. I tested the createElement by substituting "input" instead of "a" and it returned an object reference. I had a return; statement following the alert to stop the debugging.


What line number should I recheck in your code? Thanks for the feedback. July 28, 2023, Friday. Phoenix, AZ 112° F.

Ответить
Ansh Patel
Ansh Patel - 24.07.2023 09:22

Thanks Bro I got a appropriate result. 👍

Ответить
Heath Haskins
Heath Haskins - 03.05.2023 17:54

copy....
paste...
GOT IT! :D Thanks!

Ответить
Ahmed Abdi GUURE
Ahmed Abdi GUURE - 25.02.2023 16:29

its downloads the file.. but as i open it says "the file format and extension don't match" When I cklick OK no data there is no data in the excel file

Ответить
An Who
An Who - 10.02.2023 12:17

how can I download file with .xlsx extension and open in excel.

Ответить
Raihanur Rahman
Raihanur Rahman - 28.01.2023 09:31

Thanks a ton! I got the result i was looking for!

Ответить
John Joseph Sanchez
John Joseph Sanchez - 19.01.2023 11:31

How about adding ignoreColumn?
I would like to export excluding certain columns

Ответить
Rahmat Dicky
Rahmat Dicky - 05.01.2023 05:28

thanks man, I wanna create invoice view with this technique. is it possible?

Ответить
Jerico Pangilinan
Jerico Pangilinan - 23.11.2022 10:00

Thank bro , how can i show border in html like in excel ?

Ответить
Favour Emmanuel
Favour Emmanuel - 11.07.2022 09:36

After a whole of research, this is what works for me
Thanks bro

Ответить
Learn Programming
Learn Programming - 07.02.2022 12:33

Thank bro , how can i show border in html like in excel ?

Ответить
Rafael
Rafael - 02.11.2021 21:33

Thanks! How do I change the format to xlsx?

Ответить
Miyagen Co., Ltd.
Miyagen Co., Ltd. - 05.07.2021 08:21

Thank bro.
After exporting , in excel file not showing Gridlines, How to solve?

Ответить
Brandon Llerena Urday
Brandon Llerena Urday - 10.06.2021 19:44

How can I use UTF-8?

Ответить