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);
		}
相关推荐
533_1 天前
[echarts] 更新数据
前端·javascript·echarts
在雨夜入睡4 天前
Echarts-实现柱状图单系列图例
echarts
paopaokaka_luck4 天前
婚纱摄影管理系统(发送邮箱、腾讯地图API、物流API、webSocket实时聊天、协同过滤算法、Echarts图形化分析)
vue.js·spring boot·后端·websocket·算法·echarts
码上佳人5 天前
Echarts如何生成没有上下两端线的箱线图
前端·echarts
wow_DG9 天前
【ECharts✨】解决Vue 中 v-show 导致组件 ECharts 样式异常问题
前端·javascript·vue.js·echarts
朝阳399 天前
echarts【实战】饼状图点击高亮,其他区域变暗
echarts
HashTang11 天前
2025年7月份实时最新获取地图边界数据方法,省市区县街道多级联动【文末附实时geoJson数据下载】
echarts·地图·geojson·全国geojson·经纬度·街道geojson·街道边界数据·矢量边界·乡镇geojson·乡镇边界数据·行政边界
全宝12 天前
🗾3分钟学会Echart地图下钻
前端·echarts
paopaokaka_luck15 天前
基于SpringBoot+Vue的汽车租赁系统(协同过滤算法、腾讯地图API、支付宝沙盒支付、WebsSocket实时聊天、ECharts图形化分析)
vue.js·spring boot·后端·websocket·算法·汽车·echarts
隐含15 天前
基于echarts的水球的样式。
前端·javascript·echarts