当前位置: 首页 > article >正文

前端导出word文件,并包含导出Echarts图表等

 基础导出模板

    const html = `<html>
    <head>
      <style>
        body {
          font-family: 'Times New Roman';
        }
    
        h1 {
          text-align: center;
        }
    
        table {
          border-collapse: collapse;
          width: 100%;
          color: '#1118FF';
          font-weight: 600;
        }
    
        th,
        td {
          border: 1px solid black;
          padding: 8px;
          text-align: left;
        }
      </style>
    </head>
    
    <body>
      <div style="font-size: 20px;font-weight: 600;margin-bottom: 20px;margin-left: 15px;">
        附件:孜然卷测试问题主要问题汇总
      </div>
      <table>
        <thead>
          <tr>
            <th>科室</th>
            <th>住院号</th>
            <th>问题</th>
            <th>管床医生</th>
            <th>扣分</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <th>孜然卷科室test1</th>
            <th>住院号test1</th>
            <th>问题test1</th>
            <th>管床医生test1</th>
            <th>扣分test1</th>
          </tr>
        </tbody>
      </table>
    </body>
    
    </html>`;
    const blob = new Blob([html], {
      type: 'application/msword',
    });
    const link = document.createElement('a');
    link.download = `2025年2月导出.doc`;
    link.href = URL.createObjectURL(blob);
    link.click();

其中如果要加入Echarts图表,则需在创建Echarts图表时,将其myChartWord保存

在需要引用图片时 使用上面保存的myChartWord的getDataURL()函数
<img src=${this.state.myChartWord.getDataURL({ pixelRatio: 2, backgroundColor: '#fff' })}/>


http://www.kler.cn/a/555044.html

相关文章:

  • phpmyadmin 文件包含(CVE-2014-8959)
  • 微信小程序实现拉卡拉支付
  • 《鸿蒙开发-答案之书》获取视频第一帧和视频时间
  • 深度学习-4.优化与正则化
  • 亲测可用,IDEA中使用满血版DeepSeek R1!支持深度思考!免费!免配置!
  • 第1章大型互联网公司的基础架构——1.11 消息中间件技术
  • android 使用 zstd算法压缩文件
  • 数仓搭建(hive):DWS层(服务数据层)
  • Ubuntu 20.04源码安装opencv 4.5.0
  • 视频图像质量评价开源算法介绍【持续更新】
  • 有向图的强连通分量: Kosaraju算法和Tarjan算法详解
  • MapReduce理论知识与实践
  • ESXI 8.0 linux vSphere Client service has stopped working.手动启动服务
  • BS架构网络安全 网络安全架构分析
  • UI学习备忘
  • 第1章 快速认识线程
  • 用deepseek学大模型05逻辑回归
  • 在 Python 中操作 Excel 文件
  • 将RocketMQ集成到了Spring Boot项目中,实现站内信功能
  • Java中Map循环安全的删除数据的4中方法