{"entities":[{"entity_type":1,"entity_content":{"file":{"file_name":"_附件3:预算绩效申报表(-有数据版.xls","key":"tos-cn-i-ik7evvg4ik/409d15948d344e81b9c017ede0414350.xls","md5":"f4299dc51c0c35db4ac233467caeed18","size":29184,"file_type":1}},"identifier":"ff436630-c1a0-11ef-baf3-9fa7dcb57021","file_parse_state":1}],"text":"private static void readHSSFExcel(HSSFWorkbook workbook) {\n HSSFSheet sheet = workbook.getSheetAt(0);\n for (int i = 0; i <= sheet.getLastRowNum(); i++) {\n HSSFRow row = sheet.getRow(i);\n if (row != null) {\n HSSFCell cellB = row.getCell(1);\n if (cellB != null) {\n String cellBValue = cellB.getStringCellValue().replace("\n", "");\n System.out.println("读取到的B列单元格值: " + cellBValue);\n if (CellType.STRING == cellB.getCellType() && "绩效指标".equals(cellBValue)) {\n for (int j = 2; j < row.getLastCellNum(); j++) {\n HSSFCell rightCell = row.getCell(j);\n if (rightCell != null && isRedDataHSSF(rightCell)) {\n System.out.println("读取到数据: " + getCellValue(rightCell));\n }\n }\n }\n }\n }\n }\n}\n不应该只读取B列的值,我需要读取全部的数据,特别是B列是绩效指标的数据范围,我需要构建类似这样的关系PerformanceIndicator对象:{ private String name; private List<Indicator> outputIndicators; private List<Indicator> benefitIndicators;} Indicator { private String title; private List<SubIndicator> subIndicators;} SubIndicator { private String subTitle; private List<MinSubIndicator> minIndicators;} MinSubIndicator { private String content; private String expectValue;}"}
I'll create a Node.js script that reads all the data from the Excel file, focusing on the "绩效指标" (Performance Indicator) section, and constructs the object structure you've described. We'll use the xlsx library to read the Excel file.
Here's the Node.js script that accomplishes this:
excelParser.js
This script does the following:
MinSubIndicator, SubIndicator, Indicator, and PerformanceIndicator.The readExcel function reads the Excel file and constructs the object structure:
PerformanceIndicator.Indicator objects when it finds a value in column C but not in D.SubIndicator objects when it finds a value in column D but not in E.MinSubIndicator objects when it finds values in both columns E and F.To use this script:
npm install xlsx in your project directory.excelParser.js.node excelParser.js.This script should read all the data from your Excel file and construct the object structure you requested, focusing on the "绩效指标" section and properly categorizing the output and benefit indicators.
I'll provide a modified version of the Excel reader that incorporates the structure and logic from the Word document reader. This solution will use the Apache POI library to read the .xls file and construct the PerformanceIndicator objects as requested.
ExcelPerformanceIndicatorReader.java
This code does the following:
PerformanceIndicator objects.To use this code:
"path/to/your/_附件3:预算绩效申报表(-有数据版.xls" with the actual path to your Excel file.main method to read the Excel file and create the PerformanceIndicator objects.You may need to adjust the isSubIndicator method if there are additional sub-indicator types in your Excel file. Also, you might want to add more error handling and logging as needed for your specific use case.