Issue
I'm having a problem when donwloading a HTML table to Excel. Doesn't matter how I try to set the font size, the excel always have the font in size 10. Already tried to set the size by inline CSS, CSS selector, set element by element and nothing works.
Here is the code I use to download the Table:
var blob = new Blob(["\uFEFF" + data], {
type: "application/vnd.ms-excel",
encoding: "UTF-8"
});
var link = document.createElement("a");
link.href = window.URL.createObjectURL(blob);
link.download = "subestacao.xls";
link.click();
Solution
After some testing I understand how it works, the only way that I can work through this was with inline CSS, but it's not very intuitive.
Setting the font-size to 6px in HTML, makes the excel set the font size to 5. Setting to 8px makes excel set to 6. And go on:
- 10px -> 8
- 12px -> 9
- 14px -> 11
- 16px -> 12
- 18px -> 14
- 20px -> 15
I didn't understand how it happens, but I find a way to achieve what i want.
Answered By - Pedro da Silva Farias
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.