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);
		}
相关推荐
Highcharts.js2 天前
基于Highcharts开发的OHLC 股票K线图完全指南
javascript·信息可视化·echarts·数据可视化·highcharts·ohlc
脾气有点小暴2 天前
ECharts 伪 3D 柱状图完整注释 + 实现原理说明
前端·3d·信息可视化·vue·echarts
李昊哲小课2 天前
FastAPI + Echarts 构建可交互数据仪表板
信息可视化·echarts·fastapi
Smile_ping4 天前
tooltip在真机上出现图形阴影?
echarts·tooltip图形阴影设置
金融小白数据分析之路4 天前
绍兴市镇街echarts 制作
前端·数据库·echarts
shmily麻瓜小菜鸡5 天前
浏览器在请求外部图片(403 Forbidden)问题
vue.js·vscode·echarts·angular.js
paopaokaka_luck5 天前
基于Springboot3+Vue3的高校选课系统(AI选课助手、协同过滤算法、分享到微博、扣扣、Echarts图形化分析)
网络·spring boot·网络协议·echarts
张人玉5 天前
基于 Vue 3 + ECharts + Express + SQLite 构建的新能源汽车销量数据分析与可视化平台——新能源汽车销量数据分析系统
数据库·vue.js·sqlite·echarts
想你依然心痛5 天前
让数据会说话,Vue 结合 ECharts 打造电力可视化大屏
echarts·vue3·数据大屏·电力可视化
张人玉5 天前
基于 Vue 3 + ECharts + Express + SQLite 构—— LDA 模型的新闻舆论主题识别与情感分析系统
vue.js·echarts·express