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);
		}
相关推荐
猿究院_xyz13 小时前
微信小程序与echarts联动安卓真机测试出现黑色阴影
前端·javascript·微信小程序·小程序·echarts
paopaokaka_luck16 小时前
基于SpringBoot+Uniapp的自习室预约小程序(腾讯地图API、Echarts图形化分析、二维码识别)
vue.js·spring boot·后端·spring·echarts
玄魂1 天前
如何查看、生成 github 开源项目star 图表
前端·开源·echarts
哟哟耶耶2 天前
css-Echarts图表tooltip / label文本过长 超出屏幕边缘或容器范围
前端·javascript·echarts
weixin_459548903 天前
QT+Echarts初始示例
qt·echarts
毕设源码-钟学长3 天前
【开题答辩全过程】以 公寓出租系统为例,包含答辩的问题和答案
java·eclipse·echarts
凯小默4 天前
37-实现地图配置项(完结)
echarts·vue3
疯笔码良4 天前
Vue + Echarts 实现科技感数据大屏
vue.js·echarts
凯小默4 天前
36-引入地图
echarts·vue3
@AfeiyuO5 天前
Vue3 旭日图
vue·echarts