word poi-tl 图表功能增强,插入图表折线图、柱状图、饼状图

目录

    • 问题
      • 解决问题
      • poi-tl介绍
    • 功能实现
      • 引入依赖
      • 功能介绍
    • 功能实例
      • 饼图
        • 模版
        • 代码
        • 效果图
      • 雷达图(模版同饼图)
        • 代码
        • 效果图
      • 柱状图(模版同饼图)
        • 代码
        • 效果图
    • 附加
      • CustomCharts 工具类
      • CustomChartSingleSeriesRenderData 数据对象
      • CustomChartRenderPolicy 插件类

问题

由于在开发功能需求中,word文档需要根据数据动态生成图表,不同的数据类型生成不同的图表信息,而word模版引擎原有功能只能做替换,不满足需求;

解决问题

  • 目前选择的poi-tl的模版引擎,在原有的基础上新增自定义插件来实现功能

poi-tl介绍

poi-tl 是一个基于Apache POI的Word模板引擎,也是一个免费开源的Java类库,你可以非常方便的加入到你的项目中;

Word模板引擎功能描述
文本将标签渲染为文本
图片将标签渲染为图片
表格将标签渲染为表格
图表条形图(3D条形图)、柱形图(3D柱形图)、面积图(3D面积图)、折线图(3D折线图)、雷达图、饼图(3D饼图)、散点图等图表渲染
If Condition判断根据条件隐藏或者显示某些文档内容(包括文本、段落、图片、表格、列表、图表等)
Foreach Loop循环根据集合循环某些文档内容(包括文本、段落、图片、表格、列表、图表等)
Loop表格行循环复制渲染表格的某一行
Loop表格列循环复制渲染表格的某一列
Loop有序列表支持有序列表的循环,同时支持多级列表
Highlight代码高亮word中代码块高亮展示,支持26种语言和上百种着色样式
Markdown将Markdown渲染为word文档
Word批注完整的批注功能,创建批注、修改批注等
Word附件Word中插入附件
SDT内容控件内容控件内标签支持
Textbox文本框文本框内标签支持
图片替换将原有图片替换成另一张图片
书签、锚点、超链接支持设置书签,文档内锚点和超链接功能
Expression Language完全支持SpringEL表达式,可以扩展更多的表达式:OGNL, MVEL
样式支持有序列表的循环,同时支持多级列表
模板嵌套模板包含子模板,子模板再包含子模板
模板嵌套模板包含子模板,子模板再包含子模板
合并Word合并Merge,也可以在指定位置进行合并
用户自定义函数(插件)插件化设计,在文档任何位置执行函数

功能实现

引入依赖

		<dependency><groupId>com.deepoove</groupId><artifactId>poi-tl</artifactId><version>1.12.2</version></dependency><dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml-full</artifactId><version>5.2.5</version></dependency><dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>5.2.5</version></dependency><dependency><groupId>org.apache.poi</groupId><artifactId>poi</artifactId><version>5.2.5</version></dependency><dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>5.8.25</version></dependency><!-- spring el表达式 --><dependency><groupId>org.springframework</groupId><artifactId>spring-expression</artifactId><version>5.3.18</version></dependency>

功能介绍

  • 目前支持的图表类型有饼图、柱形图、面积图、折线图、雷达图等
  • 同时支持添加到表格一起渲染

功能实例

饼图

模版

![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/53b227ba4eca4923871b3f526f6784dd.png

代码
    @Testpublic void test() throws Exception {Configure config = Configure.builder().addPlugin('&',new CustomChartRenderPolicy()).useSpringEL(false).build();Map<String,Object> dataMap = new HashMap<String, Object>();CustomChartSingleSeriesRenderData chartSingleSeriesRenderData = CustomCharts.ofPie("日期", new String[]{"2024-01", "2024-02", "2024-03", "2024-04", "2024-05", "2024-06","2024-07", "2024-08", "2024-09", "2024-10", "2024-11", "2024-12"}).series("数值", new Integer[]{10, 35, 21, 46, 79, 55,39, 32, 71, 28, 22, 11}).setWidthAndHeight(10,10).create();dataMap.put("testChars", chartSingleSeriesRenderData);ClassPathResource classPathResource = new ClassPathResource("static/word/template.docx");try (InputStream resourceInputStream = classPathResource.getInputStream();XWPFTemplate template = XWPFTemplate.compile(resourceInputStream,config);){template.render(dataMap);template.writeAndClose(new FileOutputStream("output.docx"));} catch (Exception e) {e.printStackTrace();}}
效果图

在这里插入图片描述

雷达图(模版同饼图)

代码
 @Testpublic void test() throws Exception {Configure config = Configure.builder().addPlugin('&',new CustomChartRenderPolicy()).useSpringEL(false).build();Map<String,Object> dataMap = new HashMap<String, Object>();CustomChartSingleSeriesRenderData chartSingleSeriesRenderData = CustomCharts.ofRadar("日期", new String[]{"2024-01", "2024-02", "2024-03", "2024-04", "2024-05", "2024-06","2024-07", "2024-08", "2024-09", "2024-10", "2024-11", "2024-12"}).series("数值", new Integer[]{10, 35, 21, 46, 79, 55,39, 32, 71, 28, 22, 11}).setWidthAndHeight(10,10).create();dataMap.put("testChars", chartSingleSeriesRenderData);ClassPathResource classPathResource = new ClassPathResource("static/word/template.docx");try (InputStream resourceInputStream = classPathResource.getInputStream();XWPFTemplate template = XWPFTemplate.compile(resourceInputStream,config);){template.render(dataMap);template.writeAndClose(new FileOutputStream("output.docx"));} catch (Exception e) {e.printStackTrace();}}
效果图

在这里插入图片描述

柱状图(模版同饼图)

代码
 @Testpublic void test() throws Exception {Configure config = Configure.builder().addPlugin('&',new CustomChartRenderPolicy()).useSpringEL(false).build();Map<String,Object> dataMap = new HashMap<String, Object>();CustomChartSingleSeriesRenderData chartSingleSeriesRenderData = CustomCharts.ofBar("日期", new String[]{"2024-01", "2024-02", "2024-03", "2024-04", "2024-05", "2024-06","2024-07", "2024-08", "2024-09", "2024-10", "2024-11", "2024-12"}).series("数值", new Integer[]{10, 35, 21, 46, 79, 55,39, 32, 71, 28, 22, 11}).setWidthAndHeight(10,10).create();dataMap.put("testChars", chartSingleSeriesRenderData);ClassPathResource classPathResource = new ClassPathResource("static/word/template.docx");try (InputStream resourceInputStream = classPathResource.getInputStream();XWPFTemplate template = XWPFTemplate.compile(resourceInputStream,config);){template.render(dataMap);template.writeAndClose(new FileOutputStream("output.docx"));} catch (Exception e) {e.printStackTrace();}}
效果图

在这里插入图片描述

附加

CustomCharts 工具类


import com.deepoove.poi.data.RenderData;
import com.deepoove.poi.data.RenderDataBuilder;
import com.deepoove.poi.data.SeriesRenderData;
import org.apache.poi.xddf.usermodel.chart.ChartTypes;public class CustomCharts {public static CustomCharts.ChartSingles ofArea(String chartTitle, String[] categories) {return ofSingleSeries(chartTitle, categories, ChartTypes.AREA);}public static CustomCharts.ChartSingles ofRadar(String chartTitle, String[] categories) {return ofSingleSeries(chartTitle, categories, ChartTypes.RADAR);}public static CustomCharts.ChartSingles ofLine(String chartTitle, String[] categories) {return ofSingleSeries(chartTitle, categories, ChartTypes.LINE);}public static CustomCharts.ChartSingles ofBar(String chartTitle, String[] categories) {return ofSingleSeries(chartTitle, categories, ChartTypes.BAR);}public static CustomCharts.ChartSingles ofPie(String chartTitle, String[] categories) {return ofSingleSeries(chartTitle, categories, ChartTypes.PIE);}public static CustomCharts.ChartSingles ofPie3D(String chartTitle, String[] categories) {return ofSingleSeries(chartTitle, categories, ChartTypes.PIE3D);}public static CustomCharts.ChartSingles ofDoughnut(String chartTitle, String[] categories) {return ofSingleSeries(chartTitle, categories, ChartTypes.DOUGHNUT);}public static CustomCharts.ChartSingles ofSingleSeries(String chartTitle, String[] categories, ChartTypes chartTypes) {return new CustomCharts.ChartSingles(chartTitle, categories, chartTypes);}public static interface ChartSetting<T extends RenderData> {CustomCharts.ChartBuilder<T> setxAsixTitle(String xAxisTitle);CustomCharts.ChartBuilder<T> setyAsixTitle(String yAxisTitle);}public static abstract class ChartBuilder<T extends RenderData> implements RenderDataBuilder<T>, CustomCharts.ChartSetting<T> {protected String chartTitle;protected String xAxisTitle;protected String yAxisTitle;protected String[] categories;protected ChartTypes chartTypes;protected ChartBuilder(String chartTitle, String[] categories, ChartTypes chartTypes) {this.chartTitle = chartTitle;this.categories = categories;this.chartTypes = chartTypes;}protected void checkLengh(int length) {if (categories.length != length) {throw new IllegalArgumentException("The length of categories and series values in chart must be the same!");}}public CustomCharts.ChartBuilder<T> setxAsixTitle(String xAxisTitle) {this.xAxisTitle = xAxisTitle;return this;}public CustomCharts.ChartBuilder<T> setyAsixTitle(String yAxisTitle) {this.yAxisTitle = yAxisTitle;return this;}}/*** builder to build single series chart*/public static class ChartSingles extends CustomCharts.ChartBuilder<CustomChartSingleSeriesRenderData> {private SeriesRenderData series;/*** 宽度*/private Integer width = 10;/*** 高度*/private Integer height = 6;private ChartSingles(String chartTitle, String[] categories, ChartTypes chartTypes) {super(chartTitle, categories, chartTypes);}public CustomCharts.ChartSingles series(String name, Number[] value) {checkLengh(value.length);series = new SeriesRenderData(name, value);return this;}public CustomCharts.ChartSingles setWidthAndHeight(Integer width, Integer height) {this.width = width;this.height = height;return this;}@Overridepublic CustomChartSingleSeriesRenderData create() {CustomChartSingleSeriesRenderData data = new CustomChartSingleSeriesRenderData();data.setChartTitle(chartTitle);data.setxAxisTitle(xAxisTitle);data.setyAxisTitle(yAxisTitle);data.setCategories(categories);data.setSeriesData(series);data.setChartTypes(chartTypes);data.setWidth(width);data.setHeight(height);return data;}}
}

CustomChartSingleSeriesRenderData 数据对象

import com.deepoove.poi.data.ChartSingleSeriesRenderData;
import lombok.Data;
import org.apache.poi.xddf.usermodel.chart.ChartTypes;@Data
public class CustomChartSingleSeriesRenderData extends ChartSingleSeriesRenderData {private ChartTypes chartTypes;/*** 宽度*/private Integer width;/*** 高度*/private Integer height;
}

CustomChartRenderPolicy 插件类

import cn.hutool.core.util.StrUtil;
import com.deepoove.poi.data.SeriesRenderData;
import com.deepoove.poi.policy.AbstractRenderPolicy;
import com.deepoove.poi.render.RenderContext;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.Units;
import org.apache.poi.xddf.usermodel.PresetColor;
import org.apache.poi.xddf.usermodel.XDDFColor;
import org.apache.poi.xddf.usermodel.XDDFShapeProperties;
import org.apache.poi.xddf.usermodel.XDDFSolidFillProperties;
import org.apache.poi.xddf.usermodel.chart.AxisCrosses;
import org.apache.poi.xddf.usermodel.chart.AxisPosition;
import org.apache.poi.xddf.usermodel.chart.BarDirection;
import org.apache.poi.xddf.usermodel.chart.ChartTypes;
import org.apache.poi.xddf.usermodel.chart.LegendPosition;
import org.apache.poi.xddf.usermodel.chart.MarkerStyle;
import org.apache.poi.xddf.usermodel.chart.RadarStyle;
import org.apache.poi.xddf.usermodel.chart.XDDFBarChartData;
import org.apache.poi.xddf.usermodel.chart.XDDFCategoryAxis;
import org.apache.poi.xddf.usermodel.chart.XDDFCategoryDataSource;
import org.apache.poi.xddf.usermodel.chart.XDDFChartAxis;
import org.apache.poi.xddf.usermodel.chart.XDDFChartData;
import org.apache.poi.xddf.usermodel.chart.XDDFChartLegend;
import org.apache.poi.xddf.usermodel.chart.XDDFDataSource;
import org.apache.poi.xddf.usermodel.chart.XDDFDataSourcesFactory;
import org.apache.poi.xddf.usermodel.chart.XDDFLineChartData;
import org.apache.poi.xddf.usermodel.chart.XDDFNumericalDataSource;
import org.apache.poi.xddf.usermodel.chart.XDDFPieChartData;
import org.apache.poi.xddf.usermodel.chart.XDDFRadarChartData;
import org.apache.poi.xddf.usermodel.chart.XDDFValueAxis;
import org.apache.poi.xwpf.usermodel.XWPFChart;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFRun;
import org.openxmlformats.schemas.drawingml.x2006.chart.CTPieSer;import java.util.ArrayList;
import java.util.List;
import java.util.Objects;public class CustomChartRenderPolicy extends AbstractRenderPolicy<CustomChartSingleSeriesRenderData> {private Boolean titleOverlayCode;public CustomChartRenderPolicy() {this(false);}public CustomChartRenderPolicy(Boolean titleOverlayCode) {this.titleOverlayCode = titleOverlayCode;}@Overrideprotected void afterRender(RenderContext<CustomChartSingleSeriesRenderData> context) {//清空标签 clearParagraph 为true 存在表外的图表渲染不了clearPlaceholder(context, false);}@Overridepublic void doRender(RenderContext<CustomChartSingleSeriesRenderData> context) throws Exception {XWPFRun run = context.getRun();XWPFDocument xwpfDocument = (XWPFDocument)context.getXWPFDocument();CustomChartSingleSeriesRenderData singleSeriesRenderData = context.getData();if (Objects.isNull(singleSeriesRenderData)) {return;}Integer height = singleSeriesRenderData.getHeight();Integer width = singleSeriesRenderData.getWidth();//在标签位置创建chart图表对象XWPFChart chart = xwpfDocument.createChart(run, width * Units.EMU_PER_CENTIMETER, height * Units.EMU_PER_CENTIMETER);SeriesRenderData seriesData = singleSeriesRenderData.getSeriesData();//图例是否覆盖标题chart.setTitleOverlay(this.titleOverlayCode);String[] xAxisData = singleSeriesRenderData.getCategories();Number[] yAxisData = seriesData.getValues();ChartTypes chartTypes = singleSeriesRenderData.getChartTypes();//创建图表对象execChartData(chart, chartTypes, singleSeriesRenderData, xAxisData, yAxisData);//图表相关设置//图表标题if (StrUtil.isNotEmpty(singleSeriesRenderData.getChartTitle())) {chart.setTitleText(singleSeriesRenderData.getChartTitle());} else {chart.removeTitle();chart.deleteLegend();}}private static void solidFillSeries(XDDFChartData.Series series, PresetColor color) {XDDFSolidFillProperties fill = new XDDFSolidFillProperties(XDDFColor.from(color));XDDFShapeProperties properties = series.getShapeProperties();if (properties == null) {properties = new XDDFShapeProperties();}properties.setFillProperties(fill);series.setShapeProperties(properties);}private void execChartData(XWPFChart chart, ChartTypes chartType, CustomChartSingleSeriesRenderData singleSeriesRenderData, String[] xAxisData, Number[] yAxisData) {XDDFChartData xddfChartData = null;switch (chartType) {case AREA:break;case AREA3D:break;case BAR:xddfChartData = performBarRendering(chart, chartType, singleSeriesRenderData, xAxisData, yAxisData);break;case BAR3D:break;case DOUGHNUT:break;case LINE:xddfChartData = performLineRendering(chart, chartType, singleSeriesRenderData, xAxisData, yAxisData);break;case LINE3D:break;case PIE:xddfChartData = performPieRendering(chart, chartType, singleSeriesRenderData, xAxisData, yAxisData);break;case PIE3D:break;case RADAR:performRadarRendering(chart, chartType, singleSeriesRenderData, xAxisData, yAxisData);break;case SCATTER:break;case SURFACE:break;case SURFACE3D:break;default:break;}//在标签位置绘制折线图if (Objects.nonNull(xddfChartData)) {chart.plot(xddfChartData);}}/*** PIE** @param chart* @param chartType* @param xAxisData* @param yAxisData* @return*/private XDDFChartData performPieRendering(XWPFChart chart, ChartTypes chartType, CustomChartSingleSeriesRenderData singleSeriesRenderData, String[] xAxisData, Number[] yAxisData) {// 图例位置XDDFChartLegend legend = chart.getOrAddLegend();legend.setPosition(LegendPosition.TOP_RIGHT);//设置X轴数据XDDFCategoryDataSource xAxisSource = XDDFDataSourcesFactory.fromArray(xAxisData);//设置Y轴数据XDDFNumericalDataSource<Number> yAxisSource = XDDFDataSourcesFactory.fromArray(yAxisData);//创建对象// 将数据源绑定到饼图上XDDFChartData xddfPieChartData = chart.createData(ChartTypes.PIE, null, null);XDDFPieChartData.Series series = (XDDFPieChartData.Series)xddfPieChartData.addSeries(xAxisSource, yAxisSource);series.setTitle(null,null);// 为了在饼图上显示百分比等信息,需要调用下面的方法series.setShowLeaderLines(true);if (StrUtil.isEmpty(singleSeriesRenderData.getChartTitle())) {// 隐藏图例标识、系列名称、分类名称和数值CTPieSer ctPieSer = series.getCTPieSer();showCateName(ctPieSer, false);showVal(ctPieSer, false);showLegendKey(ctPieSer, false);showSerName(ctPieSer, false);}return xddfPieChartData;}public void showCateName(CTPieSer series, boolean val) {if (series.getDLbls().isSetShowCatName()) {series.getDLbls().getShowCatName().setVal(val);} else {series.getDLbls().addNewShowCatName().setVal(val);}}public void showVal(CTPieSer series, boolean val) {if (series.getDLbls().isSetShowVal()) {series.getDLbls().getShowVal().setVal(val);} else {series.getDLbls().addNewShowVal().setVal(val);}}public void showSerName(CTPieSer series, boolean val) {if (series.getDLbls().isSetShowSerName()) {series.getDLbls().getShowSerName().setVal(val);} else {series.getDLbls().addNewShowSerName().setVal(val);}}public void showLegendKey(CTPieSer series, boolean val) {if (series.getDLbls().isSetShowLegendKey()) {series.getDLbls().getShowLegendKey().setVal(val);} else {series.getDLbls().addNewShowLegendKey().setVal(val);}}private XDDFChartData performBarRendering(XWPFChart chart, ChartTypes chartType, CustomChartSingleSeriesRenderData singleSeriesRenderData, String[] xAxisData, Number[] yAxisData) {// 定义类别轴和数值轴XDDFCategoryAxis bottomAxis = chart.createCategoryAxis(AxisPosition.BOTTOM);XDDFValueAxis leftAxis = chart.createValueAxis(AxisPosition.LEFT);leftAxis.setCrosses(AxisCrosses.AUTO_ZERO);//设置X轴数据XDDFCategoryDataSource catSource = XDDFDataSourcesFactory.fromArray(xAxisData);//设置Y轴数据XDDFNumericalDataSource<Number> valSource = XDDFDataSourcesFactory.fromArray(yAxisData);// 创建柱状图数据系列XDDFBarChartData barChartData = (XDDFBarChartData) chart.createData(chartType, bottomAxis, leftAxis);XDDFBarChartData.Series series1 = (XDDFBarChartData.Series) barChartData.addSeries(catSource, valSource);series1.setTitle("示例系列", null); // 设置系列标题// 设置柱状图样式barChartData.setBarDirection(BarDirection.COL);return barChartData;}private XDDFChartData performRadarRendering(XWPFChart chart, ChartTypes chartType, CustomChartSingleSeriesRenderData singleSeriesRenderData, String[] xAxisData, Number[] yAxisData) {List<Number[]> list = new ArrayList<>();list.add(yAxisData);setRadarData(chart, new String[]{"系列一"}, xAxisData, list);return null;}private void setRadarData(XWPFChart chart, String[] series, String[] categories,List<Number[]> list) {XDDFChartAxis bottomAxis = chart.createCategoryAxis(AxisPosition.BOTTOM);XDDFValueAxis leftAxis = chart.createValueAxis(AxisPosition.LEFT);leftAxis.setCrosses(AxisCrosses.AUTO_ZERO);XDDFRadarChartData radar = (XDDFRadarChartData) chart.createData(org.apache.poi.xddf.usermodel.chart.ChartTypes.RADAR, bottomAxis, leftAxis);final int numOfPoints = categories.length;final String categoryDataRange = chart.formatRange(new CellRangeAddress(1, numOfPoints, 0, 0));final XDDFDataSource<?> categoriesData = XDDFDataSourcesFactory.fromArray(categories, categoryDataRange, 0);for (int i = 0; i < list.size(); i++) {final String valuesDataRange = chart.formatRange(new CellRangeAddress(1, numOfPoints, i + 1, i + 1));final XDDFNumericalDataSource<? extends Number> valuesData = XDDFDataSourcesFactory.fromArray(list.get(i),valuesDataRange, i);XDDFChartData.Series s = radar.addSeries(categoriesData, valuesData);s.setTitle(series[i], chart.setSheetTitle(series[i], i));}radar.setStyle(RadarStyle.STANDARD);chart.plot(radar);if (list.size() > 1) {XDDFChartLegend legend = chart.getOrAddLegend();legend.setPosition(LegendPosition.BOTTOM);legend.setOverlay(false);}}/*** LINE 渲染*/private XDDFChartData performLineRendering(XWPFChart chart, ChartTypes chartType, CustomChartSingleSeriesRenderData singleSeriesRenderData, String[] xAxisData, Number[] yAxisData) {//图例设置XDDFChartLegend legend = chart.getOrAddLegend();//图例位置:上下左右legend.setPosition(LegendPosition.TOP);//X轴(分类轴)相关设置//创建X轴,并且指定位置XDDFCategoryAxis xAxis = chart.createCategoryAxis(AxisPosition.BOTTOM);String xAxisTitle = singleSeriesRenderData.getxAxisTitle();//x轴标题if (StrUtil.isNotEmpty(xAxisTitle)) {xAxis.setTitle(xAxisTitle);}//Y轴(值轴)相关设置XDDFValueAxis yAxis = chart.createValueAxis(AxisPosition.LEFT); // 创建Y轴,指定位置if (StrUtil.isNotEmpty(singleSeriesRenderData.getyAxisTitle())) {yAxis.setTitle(singleSeriesRenderData.getyAxisTitle()); // Y轴标题}//创建折线图对象XDDFLineChartData customChartData = (XDDFLineChartData) chart.createData(chartType, xAxis, yAxis);//设置X轴数据XDDFCategoryDataSource xAxisSource = XDDFDataSourcesFactory.fromArray(xAxisData);//设置Y轴数据XDDFNumericalDataSource<Number> yAxisSource = XDDFDataSourcesFactory.fromArray(yAxisData);//加载折线图数据集XDDFLineChartData.Series lineSeries = (XDDFLineChartData.Series) customChartData.addSeries(xAxisSource, yAxisSource);//线条样式:true平滑曲线,false折线lineSeries.setSmooth(false);// 标记点样式lineSeries.setMarkerStyle(MarkerStyle.CIRCLE);//lineSeries.setMarkerSize((short) 5);return customChartData;}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/487424.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

树莓集团是如何链接政、产、企、校四个板块的?

树莓集团作为数字影像行业的积极探索者与推动者&#xff0c;我们通过多维度、深层次的战略举措&#xff0c;将政、产、企、校四个关键板块紧密链接在一起&#xff0c;实现了资源的高效整合与协同发展&#xff0c;共同为数字影像产业的繁荣贡献力量。 与政府的深度合作政府在产业…

SQL 计算字段:算术计算

计算字段的一种常见用途是对检索出的数据进行算术计算。举个例子&#xff0c;假设 Orders 表记录了所有订单信息&#xff0c;而 OrderItems 表则记录了每个订单中的物品详情。以下 SQL 语句查询订单号为 20008 的所有物品&#xff1a; SELECT prod_id, quantity, item_price …

Apache-HertzBeat 开源监控默认口令登录

0x01 产品描述: HertzBeat(赫兹跳动) 是一个开源实时监控系统,无需Agent,性能集群,兼容Prometheus,自定义监控和状态页构建能力。HertzBeat 的强大自定义,多类型支持,高性能,易扩展,希望能帮助用户快速构建自有监控系统。0x02 漏洞描述: HertzBeat(赫兹跳动) 开源实时…

反向代理-缓存篇

文章目录 强缓存一、Expires(http1.0 规范)二、cache-control(http1.1 出现的 header 信息)Cache-Control 的常用选项Cache-Control 常用选项的选择三、弊端协商缓存一、ETag二、If-None-Match三、Last-modified四、If-Modified-Since浏览器的三种刷新方式静态资源部署策略…

element Plus中 el-table表头宽度自适应,不换行

在工作中&#xff0c;使用el-table表格进行开发后&#xff0c;遇到了小屏幕显示器上显示表头文字会出现换行展示&#xff0c;比较影响美观&#xff0c;因此需要让表头的宽度变为不换行&#xff0c;且由内容自动撑开。 以下是作为工作记录&#xff0c;用于demo演示教程 先贴个…

从单体到微服务:如何借助 Spring Cloud 实现架构转型

一、Spring Cloud简介 Spring Cloud 是一套基于 Spring 框架的微服务架构解决方案&#xff0c;它提供了一系列的工具和组件&#xff0c;帮助开发者快速构建分布式系统&#xff0c;尤其是微服务架构。 Spring Cloud 提供了诸如服务发现、配置管理、负载均衡、断路器、消息总线…

PostgreSQL 安装部署系列:使用YUM 方式在Centos 7.9 安装指定 PostgreSQL -15版本数据库

一、前言 千里之行始于足下&#xff0c;想学习一门数据库&#xff0c;首先要从安装部署开始&#xff0c;先拥有一套属于自己的学习测试库。为了更好的学习该数据库&#xff0c;可以选择一个在企业界使用率比较普及的操作系统&#xff0c;选择稳定版本的操作系统&#xff1b;如果…

Mac上基于pyenv管理Python多版本的最佳实践

首先声明&#xff0c;你可以选择使用 Homebrew 来安装pyenv。我这里主要是想和我 Linux 设备上一致&#xff0c;所以选择使用脚本来安装pyenv。 准备安装脚本 这个安装的脚本来源于官方的的github仓库。 关于安装脚本的解读请看《pyenv 安装脚本解读》。 pyenv-installer.sh …

创建型设计模式

一、设计模式介绍 1.设计模式是什么 设计模式是指在软件开发中&#xff0c;经过验证的&#xff0c;用于解决在特定环境下&#xff0c;重复出现的&#xff0c;特定问题的解决方案&#xff1b; 2.设计模式怎么来的&#xff1f; 满足设计原则后&#xff0c;慢慢迭代出来的。 3.设…

Linux系统下常用资源查看

一、查看CPU使用率 top 命令 top命令可以看到总体的系统运行状态和cpu的使用率 。 %us&#xff1a;表示用户空间程序的cpu使用率&#xff08;没有通过nice调度&#xff09; %sy&#xff1a;表示系统空间的cpu使用率&#xff0c;主要是内核程序。 %ni&#xff1a;表示用户空间且…

java+ssm+mysql学生信息管理系统

项目介绍&#xff1a; 使用javassmmysql开发的学生信息管理系统&#xff0c;系统包含超级管理员&#xff0c;系统管理员、教师、学生角色&#xff0c;功能如下&#xff1a; 超级管理员&#xff1a;管理员管理&#xff08;可以新增管理员&#xff09;&#xff1b;专业管理&…

OSI模型及各层缺陷

1&#xff0e;TCP/IP概述 &#xff08;1&#xff09;TCP/IP基本结构 TCP/IP是一组Internet协议&#xff0c;不但包括TCP和IP两个关键协议&#xff0c;还包括其他协议&#xff0c;如UDP、ARP、ICMP、Telnet和FTP等。TCP/IP的设计目标是使不同的网络互相连接&#xff0c;即实现互…

pyenv 安装脚本解读

pyenv 安装脚本 curl https://pyenv.run | bash执行上面这一行脚本就可以安装pyenv来满足你对 Python 多版本共存以及切换的支持。 pyenv搭配virtualenv可以满足你对Python虚拟环境版本的支持。个人感觉pyenv比conda更轻量&#xff0c;更推荐使用。 那么上面的脚本到底干了什…

Redis 内存管理

Redis 给缓存数据设置过期时间有什么用&#xff1f; 一般情况下&#xff0c;我们设置保存的缓存数据的时候都会设置一个过期时间。为什么呢&#xff1f; 内存是有限且珍贵的&#xff0c;如果不对缓存数据设置过期时间&#xff0c;那内存占用就会一直增长&#xff0c;最终可能…

Day2——需求分析与设计

教师端签到应用软件的需求分析&#xff1b; 产品经理如何写好产品需求文档&#xff08;附模板&#xff09; 需求分析是软件开发过程中的关键步骤&#xff0c;它确保了开发的软件能够满足用户的需求。以下是进行需求分析的具体步骤&#xff1a; 1. 确定分析目标 明确教师端签到…

Python爬虫——HTML中Xpath定位

Xpath是一种路径查询语言。利用一个路径表达式从html文档中找到我们需要的数据位置&#xff0c;进而将其写入到本地或者数据库中。 学习Xpath爬虫&#xff0c;我们首先学习一下python中lxml库 关于库 lxml 终端下载Xpath需要用到的模块 pip install lxml 关于HTML 超文本标…

AI如何让PPT制作变得轻松与智能?用一键生成ppt!

谁还愿意把时间浪费在PPT的设计和内容排版上&#xff1f;尤其是对于那些需要频繁制作演示文稿的人来说&#xff0c;一份看起来专业的PPT往往会让人陷入“做与不做”的困境。但随着科技的飞速发展&#xff0c;传统的PPT制作方法正逐渐被更为高效的工具所取代&#xff0c;尤其是智…

树莓派 PICO RP2040 MACOS 使用

文章参考&#xff1a; Developing in C on the RP2040: macOS | Wellys Dev 这里会提示报错&#xff1a;ln: /bin/picotool: Operation not permitted 参考&#xff1a;Mac ln命令报错&#xff1a;Operation not permitted_ln operation not permitted-CSDN博客 放在 usr/lo…

React第十七章(useRef)

useRef 当你在React中需要处理DOM元素或需要在组件渲染之间保持持久性数据时&#xff0c;便可以使用useRef。 import { useRef } from react; const refValue useRef(initialValue) refValue.current // 访问ref的值 类似于vue的ref,Vue的ref是.value&#xff0c;其次就是vu…

xtu oj 制药

文章目录 回顾前言代码思路 回顾 AB III问题 H: 三角数问题 G: 3个数等式 数组下标查询&#xff0c;降低时间复杂度1405 问题 E: 世界杯xtu 数码串xtu oj 神经网络xtu oj 1167 逆序数&#xff08;大数据&#xff09;xtu oj 原根xtu oj 不定方程的正整数解xtu oj 最多的可变换字…