Exporting table of canvas to excel or pdf

Issue

This Content is from Stack Overflow. Question asked by yoyo ashraf

i have a table with 1 td on each row that td contains a canvas element
i want to export the whole table to excel or pdf
i tried :
it output an image with all rows successfully but it didn’t work if the number of rows is greater than 1000

html2canvas($('#codes3').get(0)).then( function (canvas) {
                var a = document.createElement('a');
                a.href = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
                a.download = 'qrcodes.png';
                a.click();  
            });

and i tried and it get an empty excel sheet

        let table =$("#codes3");
html2canvas($('#codes3').get(0)).then( function (canvas) {
            var a = document.createElement('a'); 
            TableToExcel.convert(table[0], { // html code may contain multiple tables so here we are refering to 1st table tag
            name: $("#courseName").val(), // fileName you could use any name
            sheet: {
                name: 'Sheet 1' // sheetName
            }
        });
        });



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?