Echarts图表Java后端生成Base64图片格式,POI写入Base64图片到Word中

Echarts图表Java后端生成请看上篇,此篇为Base64图片插入Word文档中
Java后台生成ECharts图片,并以Base64字符串返回_青冘的博客-CSDN博客

java 复制代码
		
try {
			XWPFParagraph xwpfParagraphimage = doc.createParagraph(); // 创建图片段落
			xwpfParagraphimage.setAlignment(ParagraphAlignment.CENTER);
			XWPFRun xwpfRunimage = xwpfParagraphimage.createRun(); // 创建段落文本
			String jsonData = echartsOption.getJsonDataZCRLQK();//获取OPT的Json配置
			EchartData echartData = new Gson().fromJson(EchartData2Base64.echartToBase64(jsonData), EchartData.class);
			if (echartData.getCode() == 1) {
//   依赖包sun.misc.BASE64Decoder
				BASE64Decoder decoder = new BASE64Decoder();
				byte[] decoderBytes = decoder.decodeBuffer(echartData.getData());
				InputStream imageis = new ByteArrayInputStream(decoderBytes);
				BufferedImage imagebi = ImageIO.read(new ByteArrayInputStream(decoderBytes));
				xwpfRunimage.addPicture(imageis, Document.PICTURE_TYPE_PNG, "",
					Units.pixelToEMU(Math.min(imagebi.getWidth(), 360)), Units.pixelToEMU(Math.min(imagebi.getHeight(), 240)));
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
相关推荐
那些免费的砖3 小时前
Uni ECharts - 基于 ECharts 开发的 uni-app 跨端图表解决方案,和 Vue ECharts 用法几乎一致
vue.js·uni-app·echarts
那个村的李富贵2 天前
用MySQL玩转数据可视化
mysql·信息可视化·echarts
Yaru112 天前
伪3D地图和3D饼图实现
前端·3d·echarts
计算机学姐4 天前
基于SpringBoot的校园跑腿系统【数据可视化统计+原创精品】
java·vue.js·spring boot·后端·mysql·信息可视化·echarts
徐小夕@趣谈前端5 天前
NO-CRM 2.0正式上线,Vue3+Echarts+NestJS实现的全栈CRM系统,用AI重新定义和实现客户管理系统
前端·javascript·人工智能·开源·编辑器·echarts
艾斯特_9 天前
Echarts常用配置项及解释
前端·javascript·echarts
winfredzhang9 天前
从零构建:基于 Node.js 与 ECharts 的量化交易策略模拟系统
前端·node.js·echarts·股票·策略
叫我辉哥e110 天前
新手进阶Python:办公看板集成多数据源+ECharts高级可视化
开发语言·python·echarts
weixin_4624462310 天前
用 Python Tornado + Vue3 + ECharts 搭建 Docker 实时监控 WebSocket 仪表盘
python·echarts·tornado
叫我:松哥12 天前
基于神经网络算法的多模态内容分析系统,采用Flask + Bootstrap + ECharts + LSTM-CNN + 注意力机制
前端·神经网络·算法·机器学习·flask·bootstrap·echarts