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);
		}
相关推荐
艾斯特_2 天前
Echarts常用配置项及解释
前端·javascript·echarts
winfredzhang2 天前
从零构建:基于 Node.js 与 ECharts 的量化交易策略模拟系统
前端·node.js·echarts·股票·策略
叫我辉哥e13 天前
新手进阶Python:办公看板集成多数据源+ECharts高级可视化
开发语言·python·echarts
weixin_462446233 天前
用 Python Tornado + Vue3 + ECharts 搭建 Docker 实时监控 WebSocket 仪表盘
python·echarts·tornado
叫我:松哥5 天前
基于神经网络算法的多模态内容分析系统,采用Flask + Bootstrap + ECharts + LSTM-CNN + 注意力机制
前端·神经网络·算法·机器学习·flask·bootstrap·echarts
tianxinw9 天前
uniapp x + vue3 实现echarts图表
前端·uni-app·vue·echarts
前端_Danny10 天前
用 ECharts markLine 实现节假日标注
前端·信息可视化·echarts
叫我:松哥10 天前
基于Flask+ECharts+Bootstrap构建的微博智能数据分析大屏
人工智能·python·信息可视化·数据分析·flask·bootstrap·echarts
Cherry的跨界思维13 天前
【AI测试全栈:Vue核心】22、从零到一:Vue3+ECharts构建企业级AI测试可视化仪表盘项目实战
vue.js·人工智能·echarts·vue3·ai全栈·测试全栈·ai测试全栈
该用户加载中13 天前
echarts柱状图实现斜切以及label展示
echarts