我使用javascript导出html表。
我需要更改xls的生成边距。默认边距是普通类型。
在表格中设置页边距不起作用。
function download_xls() {
var xls="";
xls+='<table style="width:100%" margin:"0" border="0" padding="5"
cellspacing="0" cellpadding="0"><tr height="20"px; style="border:0px;" >\
<td style="height:20px; width: 90px; border-top: solid 1px #000000; border-
bottom: solid 1px #000000; border-right: solid 1px #000000; border-left:
solid 1px #000000; font-size: 10px; font-family:Arial; color:#000000; text-
align: left; ">IDENTIFICATION;N</td>\
<td style="height:20px; width: 97px; border-top: solid 1px #000000; border-
bottom: solid 1px #000000; border-right: solid 1px #000000; border-left:
solid 1px #000000; font-size: 10px; font-family:Arial; color:#000000; font-
weight: bold; text-align: left; ">TAG</td>\
<td style="height:20px; width: 99px; border-top: solid 1px #000000; border-
bottom: solid 1px #000000; border-right: solid 1px #000000; border-left:
solid 1px #000000; font-size: 10px; font-family:Arial; color:#000000; font-
weight: bold; text-align: left; "></td>\
<td style="height:20px; width: 27px; border-top: solid 1px #000000; border-
bottom: solid 1px #000000; border-right: solid 1px #000000; border-left:
solid 1px #000000; font-size: 10px; font-family:Arial; color:#000000; text-
align: center; ">REV</td>\
</tr>\
</table>'
var hiddenElement = document.createElement('a');
hiddenElement.href = 'data:application/vnd.ms-excel,' + escape(xls);
hiddenElement.target = '_blank';
hiddenElement.download = 'PT.xls';
hiddenElement.click();
}
download_xls();