When exporting a table to an image, there is a small issue with handling the style of merged row headers.
Below is my original HTML table.
Then, I use the following code to export the table to an image:
document.getElementById("download-button").addEventListener("click", function () {
const table = document.getElementById("summary-table");
html2canvas(table).then(function (canvas) {
// Convert the canvas to an image and save it
const img = canvas.toDataURL("image/png");
const a = document.createElement('a');
a.href = img;
a.download = "summary-report.png"; // Set the download file name
a.click();
});
});
The exported image is displayed as follows:
Below is my original HTML table.
Then, I use the following code to export the table to an image:
document.getElementById("download-button").addEventListener("click", function () { const table = document.getElementById("summary-table"); html2canvas(table).then(function (canvas) { // Convert the canvas to an image and save it const img = canvas.toDataURL("image/png"); const a = document.createElement('a'); a.href = img; a.download = "summary-report.png"; // Set the download file name a.click(); }); }); The exported image is displayed as follows:
![]()
try to use this REPO fix all 🐞:https://github.com/qq15725/modern-screenshot
Then, I use the following code to export the table to an image: