功能介绍:需要做一个xls导出功能,可以把页面上的自定义样式(居中、合并、背景颜色、字体大小、加粗等)一起导入到excel表格中!
自定义一个table表格
<table border="1" cellpadding="15">
<tr>
<th height="35" colspan="6" style="font-size:20px; background:red">辞职信</th>
</tr>
<tr>
<td height="35" >姓名</td>
<td height="35" width="200">张三</td>
<td height="35">部门</div></td>
<td height="35" width="200">技术部</td>
<td height="35">职务</td>
<td height="35" width="200">大佬</td>
</tr>
<tr>
<td height="35">理由</td>
<td height="35" colspan="5">世界这么大,我想去看看!</td>
</tr>
<tr>
<td height="35" colspan="5" align="right">领导签名</td>
<td height="35"> </td>
</tr>
</table>
excel表格导出代码
var tableHTML = document.querySelector("table").outerHTML;
var xlsContent= `<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="ProgId" content="Excel.Sheet" />
</head>
<body>${tableHTML}</body>
</html>`;
var blob = new Blob([xlsContent], { type: "application/vnd.ms-excel" });
var link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = "下载.xls";
link.innerHTML = "下载xls"
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
TableConvert官网入口,一个免费且强大的在线表格转换工具
FormX.ai:支持发票/收据/身份证/合同/银行对账单等多种文档类型
匡优Excel:一款智能的Excel分析工具,只需上传文件即可获取图表
Excel小技巧:如何快速分析Excel表格中的数据(图表步骤介绍)
上面是“纯js根据table页面样式导出excel表格(包括居中,合并,自定义样式)”的全面内容,想了解更多关于 js 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_2667.html
workflows工作流
令人着迷的一只老虎ComfyUI工作流
一杯咖啡蒸汽形成云ComfyUI工作流
一颗巨型的木星ComfyUI工作流
一个熙熙攘攘的市场场景,里面摆满了南瓜
树上挂着一只快乐的小樱桃
葡萄庄园白葡萄酒ComfyUI工作流
一颗柔和的水晶金字塔ComfyUI工作流
一只巨大的古代乌龟后面建有一座城市的超现实场景
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

canvas空间文本射线
canvas黑洞漩涡(canvas+js)
纯html+css做一个3d统计效果
jquery鼠标滑过图片边框特效(jquery.focus-follow插件)
javascript如何利用draggable实现一个拖拽效果
2023年程序猿如何给自己开启一场烟花盛会
纯css3绘制的小鸟
html5如何3D立方体旋转特效














