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

前端导出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.dtcms.com/a/28161.html

相关文章:

  • 影刀RPA中级证书-Excel进阶-开票清单
  • 开放表格式和对象存储架构指南
  • MySQL系列之身份鉴别(安全)
  • 分巧克力(二分查找)
  • flutter在安卓模拟器上运行
  • ECMAScript6------数组扩展
  • 某手sig3-ios算法 Chomper黑盒调用
  • DeepSeek_部署
  • 单例模式【C++设计模式】
  • Python time模块和datatime模块的区别
  • 谷粒商城—分布式高级②.md
  • 文字识别软件cnocr学习笔记
  • AATWS: gnome下无敌的应用切换器
  • 在Ubutu18.04下搭建nfs服务器
  • 【设计模式精讲】创建型模式之工厂方法模式(简单工厂、工厂方法)
  • Windows 快速搭建C++开发环境,安装C++、CMake、QT、Visual Studio、Setup Factory
  • (网络安全)渗透测试
  • 高并发内存池项目介绍
  • [NKU]C++基础课(四)补充:继承
  • 项目管理的核心是什么?
  • XUnity.AutoTranslator-Gemini——调用Google的Gemini API, 实现Unity游戏中日文文本的自动翻译
  • 案例-22.配置文件-@ConfigurationProperties
  • 【探寻C++之旅】第五章:模板
  • 解决华硕主板的Boot界面无法设置M.2的系统启动盘问题
  • Kafka Connect 数据格式转换器
  • Python装饰器根本写法
  • leetcode_位运算 190.颠倒二进制位
  • 8 SpringBootWeb案例(上): 查询【分页功能(分页插件)】、删除、新增、修改
  • 第三章 组件(6)- 事件处理
  • 设计模式 之 工厂模式(简单工厂模式、工厂方法模式、抽象工厂模式)(C++)