当前位置: 首页 > news >正文

java动态生成excel并且需要合并单元格

java动态生成excel并且需要合并单元格

先上图看一下预期效果

请添加图片描述

集成poi

<dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-base</artifactId><version>4.0.0</version>
</dependency>
<dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-web</artifactId><version>4.0.0</version>
</dependency>
<dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-annotation</artifactId><version>4.0.0</version>
</dependency>
<dependency><groupId>com.alibaba</groupId><artifactId>easyexcel</artifactId><version>2.2.6</version>
</dependency>
<dependency><groupId>org.apache.poi</groupId><artifactId>poi</artifactId><version>4.1.2</version>
</dependency>
<dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>4.1.2</version>
</dependency>
<dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml-schemas</artifactId><version>4.1.2</version>
</dependency>
<dependency><groupId>org.apache.poi</groupId><artifactId>ooxml-schemas</artifactId><version>1.4</version>
</dependency>

通过poi手动制作excel

Workbook workbook = exportMoreSheetByTemplate(request, overviewId);
if (Func.isEmpty(workbook)) {return R.fail("生成清册报告失败");
}
Sheet sheet = workbook.createSheet();
//sheet.setRandomAccessWindowSize(SpreadsheetVersion.EXCEL2007.getMaxRows());
workbook.setSheetName(2, "表3排放量汇总");
sheet.setDefaultRowHeight((short) 380);
//sheet.trackAllColumnsForAutoSizing();
// 手动创建sheet页相关内容
//样式
Font font = workbook.createFont();
font.setBold(true);
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setFont(font);
cellStyle.setBorderLeft(BorderStyle.THIN);
cellStyle.setBorderRight(BorderStyle.THIN);
cellStyle.setBorderBottom(BorderStyle.THIN);
cellStyle.setBorderTop(BorderStyle.THIN);
cellStyle.setAlignment(HorizontalAlignment.CENTER);
//创建第一行
createRow1(workbook, sheet, cellStyle);
// 保存年限 10年 企业名称    测试企业    盘查时间	填表日期	2023-07-06 09:56:28
createRow2(request, workbook, sheet, cellStyle);
createRow3(workbook, sheet, cellStyle);
createMergeRow(workbook, sheet, cellStyle);List<ConfigSourceDetailDTO> excelInfos = accountingConfigMapper.getExcelInfosByOverviewId(overviewId);
for (ConfigSourceDetailDTO excelInfo : excelInfos) {excelInfo.setGroupKey(excelInfo.getGroupKey(excelInfo.getNameDisplay(), excelInfo.getSourceName(), excelInfo.getFormula()));
}
List<ExcelDataDTO> excelDataDtoS = new ArrayList<>();
Map<String, List<ConfigSourceDetailDTO>> excelInfoMap = excelInfos.stream().collect(Collectors.groupingBy(ConfigSourceDetailDTO::getGroupKey));
Set<Map.Entry<String, List<ConfigSourceDetailDTO>>> excelInfoEntrySets = excelInfoMap.entrySet();for (Map.Entry<String, List<ConfigSourceDetailDTO>> excelInfoEntrySet : excelInfoEntrySets) {String key = excelInfoEntrySet.getKey();List<String> keyList = Splitter.on(",").splitToList(key);List<ConfigSourceDetailDTO> excelInfoEntrySetValues = excelInfoEntrySet.getValue();ExcelDataDTO excelDataDTO = new ExcelDataDTO();excelDataDTO.setNameDisplay(keyList.get(0));excelDataDTO.setSourceName(keyList.get(1));excelDataDTO.setFormula(keyList.get(2));List<String> emissionCodes = new ArrayList<>();List<String> emissionNames = new ArrayList<>();List<String> emissionCodeTypes = new ArrayList<>();List<String> emissionUnits = new ArrayList<>();List<String> dataSources = new ArrayList<>();List<String> datas = new ArrayList<>();List<String> factoryDatas = new ArrayList<>();// todo 风险因子数据取值for (ConfigSourceDetailDTO excelInfoEntrySetValue : excelInfoEntrySetValues) {var emissionCode = excelInfoEntrySetValue.getEmissionCode();var obtainingMethod = excelInfoEntrySetValue.getObtainingMethod();var sourceId = excelInfoEntrySetValue.getSourceId();if ("计算值".equals(obtainingMethod)) {//SELECT * FROM g_Inventory_details d WHERE d.is_deleted =0 AND d.obtaining_method = '计算值' and source_id = 1681199756105396225;List<InventoryDetails> inventoryDetails = inventoryDetailsMapper.selectList(new LambdaQueryWrapper<>(InventoryDetails.class).eq(InventoryDetails::getIsDeleted, 0).eq(InventoryDetails::getObtainingMethod, obtainingMethod).eq(InventoryDetails::getSourceId, sourceId));for (InventoryDetails inventoryDetail : inventoryDetails) {// 计算年月或者季度总和datas.add(Func.toStr(BigDecimalUtils.add(Func.isEmpty(inventoryDetail.getJanuary()) ? new BigDecimal(0) : new BigDecimal(inventoryDetail.getJanuary()), Func.isEmpty(inventoryDetail.getFebruary()) ? new BigDecimal(0) : new BigDecimal(inventoryDetail.getFebruary())).add(Func.isEmpty(inventoryDetail.getMarch()) ? new BigDecimal(0) : new BigDecimal(inventoryDetail.getMarch())).add(Func.isEmpty(inventoryDetail.getApril()) ? new BigDecimal(0) : new BigDecimal(inventoryDetail.getApril())).add(Func.isEmpty(inventoryDetail.getMay()) ? new BigDecimal(0) : new BigDecimal(inventoryDetail.getMay())).add(Func.isEmpty(inventoryDetail.getJune()) ? new BigDecimal(0) : new BigDecimal(inventoryDetail.getJune())).add(Func.isEmpty(inventoryDetail.getJuly()) ? new BigDecimal(0) : new BigDecimal(inventoryDetail.getJuly())).add(Func.isEmpty(inventoryDetail.getAugust()) ? new BigDecimal(0) : new BigDecimal(inventoryDetail.getAugust())).add(Func.isEmpty(inventoryDetail.getSeptember()) ? new BigDecimal(0) : new BigDecimal(inventoryDetail.getSeptember())).add(Func.isEmpty(inventoryDetail.getOctober()) ? new BigDecimal(0) : new BigDecimal(inventoryDetail.getOctober())).add(Func.isEmpty(inventoryDetail.getNovember()) ? new BigDecimal(0) : new BigDecimal(inventoryDetail.getNovember())).add(Func.isEmpty(inventoryDetail.getDecember()) ? new BigDecimal(0) : new BigDecimal(inventoryDetail.getDecember()))));}}var formula = excelDataDTO.getFormula();if (Func.isNotEmpty(formula)) {String[] splits = formula.split("=");if (Func.isNotEmpty(emissionCode)) {if (emissionCode.equals(splits[0].replace(" ", ""))) {continue;}}}emissionCodes.add(emissionCode);emissionNames.add(excelInfoEntrySetValue.getEmissionName());emissionCodeTypes.add(excelInfoEntrySetValue.getEmissionCodeType());emissionUnits.add(excelInfoEntrySetValue.getEmissionUnit());dataSources.add(excelInfoEntrySetValue.getDataSource());var factorId = excelInfoEntrySetValue.getFactorId();// 获取公式对应的数据,通过查询风险因子表的JSON字段getFactorDatas(factoryDatas, emissionCode, sourceId, factorId, overviewId);}excelDataDTO.setEmissionCode(emissionCodes);excelDataDTO.setEmissionName(emissionNames);excelDataDTO.setDataSource(dataSources);excelDataDTO.setData(factoryDatas);excelDataDTO.setEmissionUnit(emissionUnits);excelDataDTO.setEmissionCodeType(emissionCodeTypes);excelDataDTO.setTotalData(datas.stream().reduce((d, d1) -> Func.toStr(BigDecimalUtils.add(new BigDecimal(d), new BigDecimal(d)))).orElse("0"));excelDataDtoS.add(excelDataDTO);
}InventoryOverview queryEntity = new InventoryOverview();
queryEntity.setEnterpriseId(Func.toStr(request.getBusinessParam().get("unitId")));
String[] reportYears = Func.toStr(request.getBusinessParam().get("unitReportYear")).split("年");
if (Func.isNotEmpty(reportYears[0])) {queryEntity.setTimeInventory(reportYears[0]);if (reportYears.length > 1) {queryEntity.setTimeUnit(reportYears[1]);}
}
InventoryOverview detail = null;
try {detail = inventoryOverviewMapper.selectById(overviewId);
} catch (Exception e) {log.error("根据inventoryOverviewMapper.selectById查询信息失败" + e);
}
log.info("需要动态生成 excel 的组合对象是:{},传入的参数是:{}", JSONObject.toJSONString(excelDataDtoS), overviewId);
// 动态生成sheet
int tempRow = daynamicCreateRow(workbook, sheet, excelDataDtoS);
Row row7 = this.buildRow(sheet, tempRow, workbook, 12);
CellRangeAddress region7 = new CellRangeAddress(tempRow, tempRow, 0, 9);
sheet.addMergedRegion(region7);
row7.getCell(0).setCellValue("总排放量");
Row row8 = this.buildRow(sheet, tempRow + 1, workbook, 12);
CellRangeAddress region8 = new CellRangeAddress(tempRow + 1, tempRow + 1, 0, 9);
sheet.addMergedRegion(region8);
row8.getCell(0).setCellValue("直接排放量");
CellRangeAddress region9 = new CellRangeAddress(tempRow + 2, tempRow + 2, 0, 9);
sheet.addMergedRegion(region9);
Row row9 = this.buildRow(sheet, tempRow + 2, workbook, 12);
row9.getCell(0).setCellValue("间接排放量");
if (Func.isNotEmpty(detail)) {row7.getCell(10).setCellValue(Func.toStr(detail.getInventoryTotal()));row7.getCell(11).setCellValue(Func.toStr(detail.getInventoryTotal()));row8.getCell(10).setCellValue(Func.toStr(detail.getInventoryFirst()));row8.getCell(11).setCellValue(Func.toStr(detail.getInventoryFirst()));row9.getCell(10).setCellValue(Func.toStr(detail.getInventorySecond()));row9.getCell(11).setCellValue(Func.toStr(detail.getInventorySecond()));
} else {row7.getCell(10).setCellValue(0);row7.getCell(11).setCellValue(0);row8.getCell(10).setCellValue(0);row8.getCell(11).setCellValue(0);row9.getCell(10).setCellValue(0);row9.getCell(11).setCellValue(0);
}
//将sheet写入文件
//将文件保存到指定的位置
try (FileOutputStream outputStream = new FileOutputStream(file)) {workbook.write(outputStream);
}
//上传文件
MultipartFile multipartFile = FileUtil.fileToMultipartFile(file);
GoldNetFileVO goldNetFileVO = fileService.uploadFile(multipartFile);
file.delete();
if (Objects.nonNull(goldNetFileVO)) {log.info("生产文件ID:{},toLink:{}", goldNetFileVO.getFileId(), goldNetFileVO.getFileLink());return R.data(goldNetFileVO.getFileId());
}
/*** 4和5合并单元格** @param workbook* @param sheet* @param cellStyle*/
private void createMergeRow(Workbook workbook, Sheet sheet, CellStyle cellStyle) {Row row4 = this.buildRow(sheet, 3, workbook, 12);Row row5 = this.buildRow(sheet, 4, workbook, 12);CellRangeAddress region4_1 = new CellRangeAddress(3, 4, 0, 0);sheet.addMergedRegion(region4_1);CellRangeAddress region4_2 = new CellRangeAddress(3, 4, 1, 1);sheet.addMergedRegion(region4_2);CellRangeAddress region4_3 = new CellRangeAddress(3, 4, 2, 2);sheet.addMergedRegion(region4_3);// 编号	对应活动/设施	排放源row4.getCell(0).setCellValue("编号");row4.getCell(0).setCellStyle(cellStyle);row4.getCell(1).setCellValue("对应活动/设施");row4.getCell(1).setCellStyle(cellStyle);row4.getCell(2).setCellValue("排放源");row4.getCell(2).setCellStyle(cellStyle);CellRangeAddress region4_4 = new CellRangeAddress(3, 3, 3, 11);sheet.addMergedRegion(region4_4);row4.getCell(3).setCellValue("CO2");row4.getCell(3).setCellStyle(cellStyle);// 计算公式	参数	类别	名称	数值	单位	来源	年排放量	年CO2当量row5.getCell(3).setCellValue("计算公式");row5.getCell(3).setCellStyle(cellStyle);row5.getCell(4).setCellValue("参数");row5.getCell(4).setCellStyle(cellStyle);row5.getCell(5).setCellValue("类别");row5.getCell(5).setCellStyle(cellStyle);row5.getCell(6).setCellValue("名称");row5.getCell(6).setCellStyle(cellStyle);row5.getCell(7).setCellValue("数值");row5.getCell(7).setCellStyle(cellStyle);row5.getCell(8).setCellValue("单位");row5.getCell(8).setCellStyle(cellStyle);row5.getCell(9).setCellValue("来源");row5.getCell(9).setCellStyle(cellStyle);row5.getCell(10).setCellValue("年排放量");row5.getCell(10).setCellStyle(cellStyle);row5.getCell(11).setCellValue("年CO2当量");row5.getCell(11).setCellStyle(cellStyle);
}/*** 创建第三行** @param workbook* @param sheet* @param cellStyle*/
private void createRow3(Workbook workbook, Sheet sheet, CellStyle cellStyle) {Row row3 = this.buildRow(sheet, 2, workbook, 12);CellRangeAddress region3_1 = new CellRangeAddress(2, 2, 0, 2);sheet.addMergedRegion(region3_1);row3.getCell(0).setCellValue("基本数据");row3.getCell(0).setCellStyle(cellStyle);
}/*** 创建第二行** @param request* @param workbook* @param sheet* @param cellStyle*/
private void createRow2(CreateStatementRequest request, Workbook workbook, Sheet sheet, CellStyle cellStyle) {Row row2 = this.buildRow(sheet, 1, workbook, 12);CellRangeAddress region2_1 = new CellRangeAddress(1, 1, 0, 1);sheet.addMergedRegion(region2_1);CellRangeAddress region2_2 = new CellRangeAddress(1, 1, 4, 5);sheet.addMergedRegion(region2_2);CellRangeAddress region2_3 = new CellRangeAddress(1, 1, 6, 7);sheet.addMergedRegion(region2_3);CellRangeAddress region2_4 = new CellRangeAddress(1, 1, 9, 10);sheet.addMergedRegion(region2_4);row2.getCell(0).setCellValue("保存年限");row2.getCell(0).setCellStyle(cellStyle);row2.getCell(2).setCellValue("10年");row2.getCell(2).setCellStyle(cellStyle);row2.getCell(3).setCellValue("企业名称");row2.getCell(3).setCellStyle(cellStyle);row2.getCell(4).setCellValue(Func.toStr(request.getBusinessParam().get("unitName")));row2.getCell(4).setCellStyle(cellStyle);row2.getCell(6).setCellValue("盘查时间");row2.getCell(6).setCellStyle(cellStyle);row2.getCell(8).setCellValue(Func.toStr(request.getBusinessParam().get("timeInventoryText")));row2.getCell(8).setCellStyle(cellStyle);row2.getCell(9).setCellValue("填表日期");row2.getCell(9).setCellStyle(cellStyle);row2.getCell(11).setCellValue(DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME));row2.getCell(11).setCellStyle(cellStyle);
}/*** 动态生成row和col** @param workbook* @param sheet* @param excelDataDTOS*/
private int daynamicCreateRow(Workbook workbook, Sheet sheet, List<ExcelDataDTO> excelDataDTOS) {int temp = 4;// 代表从第几行开始合并int rowTemp = 5;// tempNum 代表序号int tempNum = 1;for (int i = 0; i < excelDataDTOS.size(); i++) {ExcelDataDTO excelDataDTO = excelDataDTOS.get(i);List<String> emissionCodes = excelDataDTO.getEmissionCode();List<String> emissionCodeTypes = excelDataDTO.getEmissionCodeType();List<String> emissionNames = excelDataDTO.getEmissionName();List<String> dataList = excelDataDTO.getData();List<String> emissionUnits = excelDataDTO.getEmissionUnit();List<String> dataSources = excelDataDTO.getDataSource();for (int j = 0; j < emissionCodes.size(); j++) {Row row6 = null;// temp + j + 1 代表从第几行开始创建rowrow6 = this.buildRow(sheet, temp + j + 1, workbook, 12);row6.getCell(0).setCellValue(tempNum + j);row6.getCell(1).setCellValue(excelDataDTO.getNameDisplay());row6.getCell(2).setCellValue(excelDataDTO.getSourceName());String formula = excelDataDTO.getFormula();if (Func.isNotEmpty(formula)) {formula = ExpressParseUtil.parseInLatexExpression(formula);formula = formula.replaceAll("\\{/}", "/");}row6.getCell(3).setCellValue(formula);row6.getCell(4).setCellValue(emissionCodes.get(j));row6.getCell(5).setCellValue(emissionCodeTypes.get(j));row6.getCell(6).setCellValue(emissionNames.get(j));// 这个地方放入 g_emission_factor 的 json 中 的data_content 中的 dataif (j < dataList.size()) {row6.getCell(7).setCellValue(dataList.get(j));} else {row6.getCell(7).setCellValue("0");}row6.getCell(8).setCellValue(emissionUnits.get(j));row6.getCell(9).setCellValue(dataSources.get(j));row6.getCell(10).setCellValue(excelDataDTO.getTotalData());row6.getCell(11).setCellValue(excelDataDTO.getTotalData());}tempNum += 1;temp += emissionCodes.size();if (emissionCodes.size() > 1) {CellRangeAddress region0 = new CellRangeAddress(rowTemp, rowTemp + emissionCodes.size() - 1, 0, 0);CellRangeAddress region1 = new CellRangeAddress(rowTemp, rowTemp + emissionCodes.size() - 1, 1, 1);CellRangeAddress region2 = new CellRangeAddress(rowTemp, rowTemp + emissionCodes.size() - 1, 2, 2);CellRangeAddress region3 = new CellRangeAddress(rowTemp, rowTemp + emissionCodes.size() - 1, 3, 3);CellRangeAddress region10 = new CellRangeAddress(rowTemp, rowTemp + emissionCodes.size() - 1, 10, 10);CellRangeAddress region11 = new CellRangeAddress(rowTemp, rowTemp + emissionCodes.size() - 1, 11, 11);sheet.addMergedRegion(region0);sheet.addMergedRegion(region1);sheet.addMergedRegion(region2);sheet.addMergedRegion(region3);sheet.addMergedRegion(region10);sheet.addMergedRegion(region11);}rowTemp += emissionCodes.size();}return rowTemp;
}/*** 创建第一行** @param workbook* @param sheet* @param cellStyle*/
private void createRow1(Workbook workbook, Sheet sheet, CellStyle cellStyle) {Row row1 = this.buildRow(sheet, 0, workbook, 12);CellRangeAddress region1 = new CellRangeAddress(0, 0, 0, 11);sheet.addMergedRegion(region1);row1.getCell(0).setCellStyle(cellStyle);row1.getCell(0).setCellValue("排放量汇总");
}// 创建行
private Row buildRow(Sheet sheet, int row, Workbook workbook, int rowLength) {CellStyle cellStyle = workbook.createCellStyle();cellStyle.setBorderLeft(BorderStyle.THIN);cellStyle.setBorderRight(BorderStyle.THIN);cellStyle.setBorderBottom(BorderStyle.THIN);cellStyle.setBorderTop(BorderStyle.THIN);Row row4 = sheet.createRow(row);for (int i = 0; i < rowLength; i++) {row4.createCell(i).setCellStyle(cellStyle);sheet.setColumnWidth(i, 12 * 256);}return row4;
}// 根据模版生成sheet
public Workbook exportMoreSheetByTemplate(CreateStatementRequest request, Long overviewId) throws IOException {// 用这个map填充数据 sheet1 sheet2 sheet3 都会使用这个map进行传递Map<String, Object> map = doEnterpriseInfo(request);List<InventoryReportDTO> inventoryReportDTOList = new ArrayList<>(doInventoryInfo(overviewId));map.put("inventoryReports", inventoryReportDTOList);// 设置导出配置// 获取导出excel指定模版String fileCode = "inventoryTemplateDownload";var vo = new ConfTemplateFileVO();vo.setTenantCode("000000");vo.setTemplateCode(fileCode);var confTemplateFileRet = confTemplateFileClient.getConfTemplateFile(vo);String filePath = "";if (confTemplateFileRet.isSuccess()) {filePath = confTemplateFileRet.getData().getTemplateFileLink();} else {throw new RuntimeException("查询清册模版信息失败");}TemplateExportParams templatePath = new TemplateExportParams(filePath, true);log.info("templatePath" + templatePath + ",map:" + JSONObject.toJSONString(map));// 导出exceltry {return ExcelExportUtil.exportExcel(templatePath, map);} catch (Exception e) {log.error("ExcelExportUtil.exportExcel", e);}return null;
}

相关文章:

java动态生成excel并且需要合并单元格

java动态生成excel并且需要合并单元格 先上图看一下预期效果 集成poi <dependency><groupId>cn.afterturn</groupId><artifactId>easypoi-base</artifactId><version>4.0.0</version> </dependency> <dependency><…...

JMeter启动时常见的错误

很多小伙伴在学工具这一块时&#xff0c;安装也是很吃力的一个问题&#xff0c;之前记得有说过怎么安装jmeter这个工具。那么你要启动jmeter的时候&#xff0c;一些粉丝就会碰到如下几个问题。 1.解压下载好的jmeter安装&#xff0c;Windows 平台&#xff0c;双击 jmeter/bin …...

python pandas 排序

Series的排序&#xff1a; Series.sort_values(ascendingTrue, inplaceFalse) 参数说明&#xff1a; ascending&#xff1a;默认为True升序排序&#xff0c;为False降序排序inplace&#xff1a;是否修改原始Series DataFrame的排序&#xff1a; DataFrame.sort_values(by, as…...

前后端分离式项目架构流程复盘之宿舍管理系统

文章目录 &#x1f412;个人主页&#x1f3c5;JavaEE系列专栏&#x1f4d6;前言&#xff1a;【&#x1f387;前端】先创建Vue-cli项目&#xff08;版本2.6.10&#xff0c;仅包含babel&#xff09;&#xff0c;请选择此项目并创建 【整理简化项目模板】【&#x1f380;创建路由】…...

Linux nohup 命令详解

nohup是Linux/Unix系统中非常有用的命令之一。它允许您在后台运行命令或脚本&#xff0c;并且在退出终端会话后仍然保持运行。这对于长时间运行的任务或进程非常有用&#xff0c;特别是当您需要离开终端但希望任务继续运行时。 nohup命令语法 nohup命令的基本语法如下&#x…...

VoxWeekly|The Sandbox 生态周报|20230731

欢迎来到由 The Sandbox 发布的《VoxWeekly》。我们会在每周发布&#xff0c;对上一周 The Sandbox 生态系统所发生的事情进行总结。 如果你喜欢我们内容&#xff0c;欢迎与朋友和家人分享。请订阅我们的 Medium 、关注我们的 Twitter&#xff0c;并加入 Discord 社区&#xf…...

编程导航算法村第九关 | 二分查找

编程导航算法村第九关 | 二分查找 LeetCode852.这个题的要求有点啰嗦&#xff0c;核心意思就是在数组中的某位位置i开始&#xff0c;从0到i是递增的&#xff0c;从i1 到数组最后是递减的&#xff0c;让你找到这个最高点。 详细要求是&#xff1a;符合下列属性的数组 arr 称为山…...

linux 下安装部署flask项目

FlaskDemo 命名为test.py # codingutf-8 from flask import Flaskapp Flask(__name__)app.route("/") def index():return "test"if __name__ __main__:app.debug True# 这里host一定要写0.0.0.0 写127.0.0.1的无法访问 ——_——app.run(host"0.…...

在Vue里,将当前窗口截图,并将数据base64转为png格式传给服务器

目录 前言 1、将当前窗口截图&#xff0c;并将数据存储下来 2、定义将base64转png的方法 3、完整代码 总结 前言 记录来源于需求 1、将当前窗口截图&#xff0c;并将数据存储下来 export default { data() {return {image: // 存储数据} }mounted() {setTimeout(() >…...

Echarts图表Java后端生成Base64图片格式,POI写入Base64图片到Word中

Echarts图表Java后端生成请看上篇&#xff0c;此篇为Base64图片插入Word文档中Java后台生成ECharts图片,并以Base64字符串返回_青冘的博客-CSDN博客 try {XWPFParagraph xwpfParagraphimage doc.createParagraph(); // 创建图片段落xwpfParagraphimage.setAlignment(Paragraph…...

【AI】《动手学-深度学习-PyTorch版》笔记(十二):从零开始实现softmax回归

AI学习目录汇总 1、什么是特征? 对于图像算法,每个像素可以视为一个特征,例如图像的分辨率为28x28,则有784个特征。而且常常将二维的图像像素矩阵展开为长度为784的向量。 2、权重和偏置的规模 本例中,将使用Fashion-MNIST数据集,它是一个服装分类数据集,可以将服装…...

汽车用功率电感器

支持车载用被动元件的可靠性认证测试标准“AEC-Q200”的绕线铁氧体功率电感器 LCXH 系列实现商品化&#xff0c;推出了“LCXHF3030QK”等 6 个尺寸的 64 款商品。 这些商品均是用于汽车车身类及信息娱乐等信息类的电源电路用扼流线圈及噪音滤波器的功率电感器。 LCXH 系列与民生…...

上传图片视频

分布式文件系统MinIo MinIO提供多个语言版本SDK的支持&#xff0c;下边找到java版本的文档&#xff1a; 地址&#xff1a;https://docs.min.io/docs/java-client-quickstart-guide.html MinIO测试&#xff08;上传、删除、下载&#xff09; public class MinioTest {MinioC…...

【UE5】UE5与Python Socket通信中文数据接收不全

最近在使用UE的Socket模块与Python服务器进行通信时遇到了一些坑&#xff0c;特此记录一下。 先来复现一下问题&#xff0c;这里只截取关键代码。 UE端&#xff1a; bool ASoc::SendMsg(const FString& Msg) {TSharedRef<FInternetAddr> TargetAddr ISocketSubsy…...

一些有难度的c++题目思路讲解--第一期2023/8/8 小Q的修炼与旷野大计算

说明: 本期博客将分为10篇讲解一些有点挑战的题目,第一期是所有人都可以看到,但后面的关注我才能看到哦!有望大家的支持!谢谢! 题目链接(按顺序) [NOI2013] 小Q的修炼 - 洛谷 小Q的修炼[NOI2013] 小Q的修炼 - 洛谷 [NOI2016] 旷野大计算 - 洛谷旷野大计算[NOI2016] 旷野…...

Node.js:path文件路径操作模块

path 用于文件路径操作 官方文档 https://nodejs.org/api/path.html 一个不错的解释 ┌─────────────────────┬────────────┐│ dir │ base │├──────┬ ├──────┬─────┤│ ro…...

基于 CentOS 7 构建 LVS-DR 群集

文章目录 一、LVS-DR集群介绍1.LVS的基本工作原理2. LVS-DR模式工作原理 二、 LVS-DR模式应用特点三、LVS – DR 模式集群构建1.前期环境准备2.配置LVS3.配置RS 一、LVS-DR集群介绍 1.LVS的基本工作原理 当用户向负载均衡调度器&#xff08;Director Server&#xff09;发起请…...

机器学习笔记 - 使用 Tensorflow 从头开始​​构建您自己的对象检测器

一、简述 之前的文章是利用了VGG16的预训练模型,然后构造完全连接的层标头以输出预测的边界框坐标,但是不包含对象标签的分类。 机器学习笔记 - 使用Keras、TensorFlow框架进行自定义数据集目标检测训练_keras 制作 目标检测 数据集_坐望云起的博客-CSDN博客学习如何训练自定…...

IELAB-网络工程师的路由答疑10问(2)

各位小伙伴们&#xff0c;接下来的问题可能有些难度&#xff0c;你们做好准备了吗&#xff1f; 7. 动态路由协议做了啥&#xff1f; 这次咱们先解决第一个比较棘手的问题--路由协议&#xff0c;相信初学的同学对于路由协议的学习总是或多或少有些问题&#xff0c;呐&#xff…...

聚观早报|iPhone 15预计9月22日上市;一加Open渲染图曝光

【聚观365】8月7日消息 iPhone 15预计9月22日上市一加Open渲染图曝光Redmi K60至尊版细节曝光小米14 Pro屏幕细节曝光vivo V3正式发布&#xff0c;执着自研“影像芯片” iPhone 15预计9月22日上市 上周有多位消息人士透露&#xff0c;多家合作的电信运营商已要求员工不要在9月…...

CMake基础:构建流程详解

目录 1.CMake构建过程的基本流程 2.CMake构建的具体步骤 2.1.创建构建目录 2.2.使用 CMake 生成构建文件 2.3.编译和构建 2.4.清理构建文件 2.5.重新配置和构建 3.跨平台构建示例 4.工具链与交叉编译 5.CMake构建后的项目结构解析 5.1.CMake构建后的目录结构 5.2.构…...

DIY|Mac 搭建 ESP-IDF 开发环境及编译小智 AI

前一阵子在百度 AI 开发者大会上&#xff0c;看到基于小智 AI DIY 玩具的演示&#xff0c;感觉有点意思&#xff0c;想着自己也来试试。 如果只是想烧录现成的固件&#xff0c;乐鑫官方除了提供了 Windows 版本的 Flash 下载工具 之外&#xff0c;还提供了基于网页版的 ESP LA…...

Spring Boot+Neo4j知识图谱实战:3步搭建智能关系网络!

一、引言 在数据驱动的背景下&#xff0c;知识图谱凭借其高效的信息组织能力&#xff0c;正逐步成为各行业应用的关键技术。本文聚焦 Spring Boot与Neo4j图数据库的技术结合&#xff0c;探讨知识图谱开发的实现细节&#xff0c;帮助读者掌握该技术栈在实际项目中的落地方法。 …...

Maven 概述、安装、配置、仓库、私服详解

目录 1、Maven 概述 1.1 Maven 的定义 1.2 Maven 解决的问题 1.3 Maven 的核心特性与优势 2、Maven 安装 2.1 下载 Maven 2.2 安装配置 Maven 2.3 测试安装 2.4 修改 Maven 本地仓库的默认路径 3、Maven 配置 3.1 配置本地仓库 3.2 配置 JDK 3.3 IDEA 配置本地 Ma…...

MySQL:分区的基本使用

目录 一、什么是分区二、有什么作用三、分类四、创建分区五、删除分区 一、什么是分区 MySQL 分区&#xff08;Partitioning&#xff09;是一种将单张表的数据逻辑上拆分成多个物理部分的技术。这些物理部分&#xff08;分区&#xff09;可以独立存储、管理和优化&#xff0c;…...

数据结构:递归的种类(Types of Recursion)

目录 尾递归&#xff08;Tail Recursion&#xff09; 什么是 Loop&#xff08;循环&#xff09;&#xff1f; 复杂度分析 头递归&#xff08;Head Recursion&#xff09; 树形递归&#xff08;Tree Recursion&#xff09; 线性递归&#xff08;Linear Recursion&#xff09;…...

大模型真的像人一样“思考”和“理解”吗?​

Yann LeCun 新研究的核心探讨&#xff1a;大语言模型&#xff08;LLM&#xff09;的“理解”和“思考”方式与人类认知的根本差异。 核心问题&#xff1a;大模型真的像人一样“思考”和“理解”吗&#xff1f; 人类的思考方式&#xff1a; 你的大脑是个超级整理师。面对海量信…...

从0开始学习R语言--Day17--Cox回归

Cox回归 在用医疗数据作分析时&#xff0c;最常见的是去预测某类病的患者的死亡率或预测他们的结局。但是我们得到的病人数据&#xff0c;往往会有很多的协变量&#xff0c;即使我们通过计算来减少指标对结果的影响&#xff0c;我们的数据中依然会有很多的协变量&#xff0c;且…...

智能照明系统:具备认知能力的“光神经网络”

智能照明系统是物联网技术与传统照明深度融合的产物&#xff0c;其本质是通过感知环境、解析需求、自主决策的闭环控制&#xff0c;重构光与人、空间、环境的关系。这一系统由智能光源、多维传感器、边缘计算单元及云端管理平台构成&#xff0c;形成具备认知能力的“光神经网络…...

CKA考试知识点分享(2)---ingress

CKA 版本&#xff1a;1.32 第二题是涉及ingress相关。本文不是题目&#xff0c;只是为了学习相关知识点做的实验。 1. 环境准备 需要准备一套K8S集群。 1.1 安装ingress-nginx 下载deploy文件&#xff1a; wget -O controller-v1.12.2.yaml https://raw.githubusercontent…...