- 浏览: 18123 次
- 性别:
- 来自: 广州
最新评论
用poi解析有合并单元格的excel
ProjectExplainExcelUtil.java
ProjectExplain.java
ProjectExplainEnum.java
ProjectExplainExcelUtil.java
package com.concom.imports.project.util; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.List; import java.util.regex.Pattern; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; import org.apache.poi.ss.util.CellRangeAddress; import org.json.JSONObject; import com.concom.imports.project.dto.ProjectExplain; import com.concom.imports.project.enums.ProjectExplainEnum; import com.concom.imports.utils.ReadExcelUtils; import com.concom.lang.helper.StringHelper; /** * 编制说明excel解析帮助类 * @author Cao Zhili * @date 2015年4月23日 */ public class ProjectExplainExcelUtil { private static Pattern pattern = Pattern.compile("\\s*|\t|\r|\n"); private static final String CHECK_SHEETNAME = "编制说明"; private static final String CHECK_BEGINNAME = "工程概况"; private static final String PROJECT_BID = "F-3"; private static final String CHECK_SHEETNAME_CONSTRUCT = "建筑装饰工程概况"; private static final String PROJECT_AMOUNT = "投标总价(小写)"; private static final String PROJECT_AMOUNT2 = "招标控制价"; private static final String PREPARATION_TIME = "编制时间"; private static final String YUAN = "元"; private static final String YEAR = "年"; public static void main(String[] args) { try { //String file = "G:\\DATA\\广州市站工程案例\\土建\\0895\\附件3:《广州市房屋建筑和市政基础设施工程施工招标控制价编制参考范本(2010年)》.xls"; String file = "G:\\DATA\\云造价产品\\GZ-2014-0251大岗绿庭雅苑酒店工程\\预算书\\0.封面.xls"; ProjectExplain projectExplain = readExcel(file); System.out.println(new JSONObject(projectExplain)); System.out.println("编制时间: "+projectExplain.getPreparationtime()); System.out.println("总金额: "+projectExplain.getProjectamount()); System.out.println("areaUnit: "+projectExplain.getAreaUnit()); } catch (Exception e) { e.printStackTrace(); } } public static ProjectExplain readExcel(String filePath) throws IOException{ FileInputStream excelFileStream = null; try { excelFileStream = new FileInputStream(filePath); return readExcel(excelFileStream); } catch (Exception e) { e.printStackTrace(); }finally{ excelFileStream.close(); excelFileStream=null; } return null; } public static ProjectExplain readExcel(File file) throws IOException{ FileInputStream excelFileStream = null; try { excelFileStream = new FileInputStream(file); return readExcel(excelFileStream); } catch (Exception e) { e.printStackTrace(); }finally{ excelFileStream.close(); excelFileStream=null; } return null; } public static ProjectExplain readExcel(InputStream inputStream) throws Exception { ProjectExplain projectExplain = new ProjectExplain(); Sheet sheet = null; Workbook workbook = null; /*if (version == 2003) {// 2003 POIFSFileSystem fs = new POIFSFileSystem(inputStream); workbook = new HSSFWorkbook(fs); } else if (version == 2007) {// 2007 workbook = new XSSFWorkbook(inputStream); } */ workbook = WorkbookFactory.create(inputStream); //POIFSFileSystem excel = new POIFSFileSystem(inputStream); //HSSFWorkbook workbook = new HSSFWorkbook(excel); int sheets = workbook.getNumberOfSheets(); //HSSFSheet sheet = null; int beginRow = 0; int beginCell = 0; for (int i = 0; i < sheets; i++) { sheet = workbook.getSheetAt(i); int lastRowNum = sheet.getLastRowNum(); if(PROJECT_BID.equals(sheet.getSheetName()) || i==0){ //获取项目总金额和编制时间 List<CellRangeAddress> listCombineCell = getCombineCell(sheet); boolean exist = false; for (int j = 0; j <= lastRowNum; j++) { Row row = sheet.getRow(j); if (null == row) { continue; } for (Cell c : row) { if (null == c) { continue; } String cellValue = ReadExcelUtils.getCellValue(c); if (cellValue.startsWith(PROJECT_AMOUNT) || cellValue.startsWith(PROJECT_AMOUNT2)) { Double projectAmount = getNumberValue(listCombineCell, sheet, row, c.getColumnIndex()); projectExplain.setProjectamount(projectAmount); break; } if (cellValue.startsWith(PREPARATION_TIME)) { String preparationTime = getPreparationtimeValue(listCombineCell, sheet, row, c.getColumnIndex()); projectExplain.setPreparationtime(preparationTime); exist = true; break; } } if(exist){ break; } } } if (!sheet.getSheetName().contains(CHECK_SHEETNAME)) { continue; } // 获取工程概况列和行 for (int j = 0; j <= lastRowNum; j++) { Row row = sheet.getRow(j); if (null == row) { continue; } for (Cell c : row) { if (null == c) { continue; } if (CHECK_BEGINNAME.equals(ReadExcelUtils.getCellValue(c))) { beginRow = c.getRowIndex(); beginCell = c.getColumnIndex(); break; } } if (beginRow > 0) { break; } } setProjectValue(projectExplain,sheet,beginRow,beginCell); } sheet = workbook.getSheet(CHECK_SHEETNAME_CONSTRUCT); if(null!=sheet){ setProjectValue(projectExplain,sheet,0,beginCell); } return projectExplain; } public static ProjectExplain readExcel(int version,InputStream inputStream) throws Exception { ProjectExplain projectExplain = new ProjectExplain(); Sheet sheet = null; Workbook workbook = null; /*if (version == 2003) {// 2003 POIFSFileSystem fs = new POIFSFileSystem(inputStream); workbook = new HSSFWorkbook(fs); } else if (version == 2007) {// 2007 workbook = new XSSFWorkbook(inputStream); } */ workbook = WorkbookFactory.create(inputStream); //POIFSFileSystem excel = new POIFSFileSystem(inputStream); //HSSFWorkbook workbook = new HSSFWorkbook(excel); int sheets = workbook.getNumberOfSheets(); //HSSFSheet sheet = null; int beginRow = 0; int beginCell = 0; for (int i = 0; i < sheets; i++) { sheet = workbook.getSheetAt(i); int lastRowNum = sheet.getLastRowNum(); if(PROJECT_BID.equals(sheet.getSheetName())){ //获取项目总金额和编制时间 List<CellRangeAddress> listCombineCell = getCombineCell(sheet); boolean exist = false; for (int j = 0; j <= lastRowNum; j++) { Row row = sheet.getRow(j); if (null == row) { continue; } for (Cell c : row) { if (null == c) { continue; } if (PROJECT_AMOUNT.equals(ReadExcelUtils.getCellValue(c))) { Double projectAmount = getNumberValue(listCombineCell, sheet, row, c.getColumnIndex()); projectExplain.setProjectamount(projectAmount); break; } if (PREPARATION_TIME.equals(ReadExcelUtils.getCellValue(c))) { String preparationTime = getPreparationtimeValue(listCombineCell, sheet, row, c.getColumnIndex()); projectExplain.setPreparationtime(preparationTime); exist = true; break; } } if(exist){ break; } } } if (!sheet.getSheetName().contains(CHECK_SHEETNAME)) { continue; } // 获取工程概况列和行 for (int j = 0; j <= lastRowNum; j++) { Row row = sheet.getRow(j); if (null == row) { continue; } for (Cell c : row) { if (null == c) { continue; } if (CHECK_BEGINNAME.equals(ReadExcelUtils.getCellValue(c))) { beginRow = c.getRowIndex(); beginCell = c.getColumnIndex(); break; } } if (beginRow > 0) { break; } } List<CellRangeAddress> listCombineCell = getCombineCell(sheet); String tempVal = null; String mergeName = null; for (int j = beginRow; j <= lastRowNum; j++) { Row row = sheet.getRow(j); if (null == row) { continue; } String tempName = null; Cell cName = row.getCell(beginCell); if (null == cName) { continue; } tempName = ReadExcelUtils.getCellValue(cName); if (null == tempName) { continue; } Cell cValue = row.getCell(beginCell+1); boolean isMerge = isCombineCell(listCombineCell, cName, sheet); if(isMerge){ tempName = getMergedRegionValue(sheet, row.getRowNum(), cName.getColumnIndex()); String tVal = ReadExcelUtils.getCellValue(cValue).trim(); //System.out.println(tempName+"-->"+tVal); if(null!=tVal && !"".equals(tVal)){ if(null!=mergeName && mergeName.equals(tempName)){ tempVal += ","+tVal; }else{ tempVal = tVal; } } mergeName = tempName; }else{ mergeName = null; tempVal = ReadExcelUtils.getCellValue(cValue).trim(); } for(ProjectExplainEnum tempEnum : ProjectExplainEnum.values()){ if(tempName.startsWith(tempEnum.getName())){ String methodName = getMethodName(tempEnum.name()); if("String".equals(tempEnum.getType())){ if(null!=tempVal){ projectExplain.getClass().getMethod(methodName,String.class).invoke(projectExplain, tempVal); }else{ projectExplain.getClass().getMethod(methodName,String.class).invoke(projectExplain, ""); } }else if("Double".equals(tempEnum.getType())){ if(null!=tempVal && !"".equals(tempVal)){ if(tempVal.contains("%")){ tempVal = tempVal.replaceAll("%", ""); } projectExplain.getClass().getMethod(methodName,Double.class).invoke(projectExplain, Double.parseDouble(tempVal)); }else{ projectExplain.getClass().getMethod(methodName,Double.class).invoke(projectExplain, 0d); } } } } } } return projectExplain; } private static void setProjectValue(ProjectExplain projectExplain,Sheet sheet,int beginRow,int beginCell) throws Exception{ int lastRowNum = sheet.getLastRowNum(); List<CellRangeAddress> listCombineCell = getCombineCell(sheet); String tempVal = null; String mergeName = null; for (int j = beginRow; j <= lastRowNum; j++) { Row row = sheet.getRow(j); if (null == row) { continue; } String tempName = null; Cell cName = row.getCell(beginCell); if (null == cName) { continue; } tempName = ReadExcelUtils.getCellValue(cName); if (null == tempName) { continue; } Cell cValue = row.getCell(beginCell+1); boolean isMerge = isCombineCell(listCombineCell, cName, sheet); if(isMerge){ tempName = getMergedRegionValue(sheet, row.getRowNum(), cName.getColumnIndex()); String tVal = ReadExcelUtils.getCellValue(cValue).trim(); //System.out.println(tempName+"-->"+tVal); if(null!=tVal && !"".equals(tVal)){ if(null!=mergeName && mergeName.equals(tempName)){ tempVal += ","+tVal; }else{ tempVal = tVal; } } mergeName = tempName; }else{ mergeName = null; tempVal = ReadExcelUtils.getCellValue(cValue).trim(); } //System.out.println("tempName: "+tempName); for(ProjectExplainEnum tempEnum : ProjectExplainEnum.values()){ if(tempName.startsWith(tempEnum.getName())){ if(tempName.startsWith(ProjectExplainEnum.constructionArea.getName())){ //获取面积单位 String areaUnit = ReadExcelUtils.getCellValue(row.getCell(beginCell+2)); if(null!=areaUnit && !"".equals(areaUnit)){ projectExplain.setAreaUnit(areaUnit); } } String methodName = getMethodName(tempEnum.name()); if("String".equals(tempEnum.getType())){ if(null!=tempVal){ projectExplain.getClass().getMethod(methodName,String.class).invoke(projectExplain, tempVal); }else{ projectExplain.getClass().getMethod(methodName,String.class).invoke(projectExplain, ""); } }else if("Double".equals(tempEnum.getType())){ if(null!=tempVal && !"".equals(tempVal)){ if(tempVal.contains("%")){ tempVal = tempVal.replaceAll("%", ""); } if(!StringHelper.isNumber(tempVal, true)){ tempVal="0"; } projectExplain.getClass().getMethod(methodName,Double.class).invoke(projectExplain, Double.parseDouble(tempVal)); }else{ projectExplain.getClass().getMethod(methodName,Double.class).invoke(projectExplain, 0d); } }else if("Integer".equals(tempEnum.getType())){ if(null!=tempVal && !"".equals(tempVal)){ projectExplain.getClass().getMethod(methodName,Integer.class).invoke(projectExplain, Integer.parseInt(tempVal)); }else{ projectExplain.getClass().getMethod(methodName,Integer.class).invoke(projectExplain, 0d); } } } } } } /** * 获取项目总金额 * @param listCombineCell * @param sheet * @param row * @param beginIndex * @return * @throws Exception */ private static Double getNumberValue(List<CellRangeAddress> listCombineCell,Sheet sheet,Row row,int beginIndex) throws Exception { Double value = 0d; if (null == row) { return value; } for(int i=beginIndex;i<row.getLastCellNum();i++){ Cell c = row.getCell(i); if (null == c) { continue; } String tempVal = ReadExcelUtils.getCellValue(c); tempVal = tempVal.replaceAll(YUAN, ""); if(isNumeric(tempVal)){ value = Double.parseDouble(tempVal); break; } } return value; } /** * 获取编制时间 * @param listCombineCell * @param sheet * @param row * @param beginIndex * @return * @throws Exception */ private static String getPreparationtimeValue(List<CellRangeAddress> listCombineCell,Sheet sheet,Row row,int beginIndex) throws Exception { String value = ""; if (null == row) { return value; } for(int i=beginIndex;i<row.getLastCellNum();i++){ Cell c = row.getCell(i); if (null == c) { continue; } String tempVal = ReadExcelUtils.getCellValue(c); if(Cell.CELL_TYPE_NUMERIC==c.getCellType()){ tempVal = dayAddition((int)Double.parseDouble(tempVal)); } //System.out.println("tempVal: "+tempVal); if(null!=tempVal && tempVal.contains(YEAR)){ value = tempVal; break; } } return value; } //日期相加天数 public static String dayAddition(int num) throws Exception{ SimpleDateFormat timeformat = new SimpleDateFormat("yyyy年MM月dd日"); java.util.Date date = timeformat.parse("1900年01月01日"); Calendar a = Calendar.getInstance(); a.setTime(date); a.add(Calendar.DATE, (num-2)); return timeformat.format(a.getTime()); } /** * 合并单元格处理,获取合并行 * * @param sheet * @return List<CellRangeAddress> */ private static List<CellRangeAddress> getCombineCell(Sheet sheet) { List<CellRangeAddress> list = new ArrayList<CellRangeAddress>(); // 获得一个 sheet 中合并单元格的数量 int sheetmergerCount = sheet.getNumMergedRegions(); // 遍历合并单元格 for (int i = 0; i < sheetmergerCount; i++) { // 获得合并单元格加入list中 CellRangeAddress ca = sheet.getMergedRegion(i); list.add(ca); } return list; } /** * 判断单元格是否为合并单元格,是的话则将单元格的值返回 * * @param listCombineCell * 存放合并单元格的list * @param cell * 需要判断的单元格 * @param sheet * sheet * @return */ private static boolean isCombineCell(List<CellRangeAddress> listCombineCell, Cell cell, Sheet sheet) throws Exception { int firstC = 0; int lastC = 0; int firstR = 0; int lastR = 0; for (CellRangeAddress ca : listCombineCell) { // 获得合并单元格的起始行, 结束行, 起始列, 结束列 firstC = ca.getFirstColumn(); lastC = ca.getLastColumn(); firstR = ca.getFirstRow(); lastR = ca.getLastRow(); if (cell.getRowIndex() >= firstR && cell.getRowIndex() <= lastR) { if (cell.getColumnIndex() >= firstC && cell.getColumnIndex() <= lastC) { return true; } } } return false; } private static Cell getNextCell(List<CellRangeAddress> listCombineCell, Cell cell, Sheet sheet) throws Exception{ if(isCombineCell(listCombineCell, cell, sheet)){ int mergeCol = getMergeCol(listCombineCell, cell, sheet); cell = sheet.getRow(cell.getRowIndex()).getCell(cell.getColumnIndex()+mergeCol+1); return cell; }else{ return cell; } } private static int getMergeCol(List<CellRangeAddress> listCombineCell, Cell cell, Sheet sheet) throws Exception { int firstC = 0; int lastC = 0; int firstR = 0; int lastR = 0; for (CellRangeAddress ca : listCombineCell) { // 获得合并单元格的起始行, 结束行, 起始列, 结束列 firstC = ca.getFirstColumn(); lastC = ca.getLastColumn(); firstR = ca.getFirstRow(); lastR = ca.getLastRow(); if (cell.getRowIndex() >= firstR && cell.getRowIndex() <= lastR) { if (cell.getColumnIndex() >= firstC && cell.getColumnIndex() <= lastC) { return lastC-firstC; } } } return 0; } /** * 获取合并单元格的值 * * @param sheet * @param row * @param column * @return */ private static String getMergedRegionValue(Sheet sheet, int row, int column) { int sheetMergeCount = sheet.getNumMergedRegions(); for (int i = 0; i < sheetMergeCount; i++) { CellRangeAddress ca = sheet.getMergedRegion(i); int firstColumn = ca.getFirstColumn(); int lastColumn = ca.getLastColumn(); int firstRow = ca.getFirstRow(); int lastRow = ca.getLastRow(); if (row >= firstRow && row <= lastRow) { if (column >= firstColumn && column <= lastColumn) { Row fRow = sheet.getRow(firstRow); Cell fCell = fRow.getCell(firstColumn); return ReadExcelUtils.getCellValue(fCell); } } } return null; } /** * 获取属性get方法 * @param fieldName * @return */ public static String getMethodName(String fieldName){ String firstChar = fieldName.charAt(0)+""; return "set"+firstChar.toUpperCase()+fieldName.substring(1); } /** * 判断是否数值 * * @param str * @return */ public static boolean isNumeric(String str) { Pattern pattern = Pattern.compile("[-]?[0-9]+[.]?[0-9]*"); return pattern.matcher(str).matches(); } }
ProjectExplain.java
package com.concom.imports.project.dto; /** * 编制说明 * * @author Cao Zhili * @date 2015年4月23日 */ public class ProjectExplain { private String projectname;// 工程名称 private String projectaddr;// 工程地点 private Double projectamount;// 项目总金额 private String otherinfo; private String compilationbasis;// 编制依据 private String construnit;// 建设单位 private String costcheckunit;// 编审单位 private String blueprint;// 图纸 private String designdate;// 设计日期 private String designation;// 图纸名称 private String pricingstandard;// 计价规范 private String valuationbasis;// 计价依据 private String pricesdate;// 材料价格取定时间 private String projectphase;// 项目阶段 private String costtype;// 造价类别 private String preparationtime;// 编制时间 private String flieno;// 文号 private String valuationtype;// 计价方式 private String designunit;// 设计单位 private String categoryName;// 项目大类型 private String subcategoryName;// 项目类型 private String projectphaseName;// 项目阶段 // 2015-7-14新增 private String proUse;// 项目用途 private String storeyHeight;// 层高(m) private Double storeyNum;// 层数 private Double eavesHeight;// 檐高(m) private String startWorkDate;// 开工日期 private String endWorkDate;// 竣工日期 private String structureType;// 结构类型 private String seismicIntensity;// 杭震烈度 private String decorateStandard;// 装修标准 private Double constructionArea;// 建筑面积 private Double undergroundArea;// 地下建筑面积 private Double overgroundArea;// 地上建筑面积 private String areaUnit;//建筑面积单位 private String overgroundStoreyNum;//地上层数 private String undergroundStoreyNum;//地下层数 public String getUndergroundStoreyNum() { return undergroundStoreyNum; } public void setUndergroundStoreyNum(String undergroundStoreyNum) { this.undergroundStoreyNum = undergroundStoreyNum; } public String getOvergroundStoreyNum() { return overgroundStoreyNum; } public void setOvergroundStoreyNum(String overgroundStoreyNum) { this.overgroundStoreyNum = overgroundStoreyNum; } public String getProjectname() { return projectname; } public void setProjectname(String projectname) { this.projectname = projectname; } public String getProjectaddr() { return projectaddr; } public void setProjectaddr(String projectaddr) { this.projectaddr = projectaddr; } public Double getProjectamount() { return projectamount; } public void setProjectamount(Double projectamount) { this.projectamount = projectamount; } public String getOtherinfo() { return otherinfo; } public void setOtherinfo(String otherinfo) { this.otherinfo = otherinfo; } public String getCompilationbasis() { return compilationbasis; } public void setCompilationbasis(String compilationbasis) { this.compilationbasis = compilationbasis; } public String getConstrunit() { return construnit; } public void setConstrunit(String construnit) { this.construnit = construnit; } public String getCostcheckunit() { return costcheckunit; } public void setCostcheckunit(String costcheckunit) { this.costcheckunit = costcheckunit; } public String getBlueprint() { return blueprint; } public void setBlueprint(String blueprint) { this.blueprint = blueprint; } public String getDesigndate() { return designdate; } public void setDesigndate(String designdate) { this.designdate = designdate; } public String getDesignation() { return designation; } public void setDesignation(String designation) { this.designation = designation; } public String getPricingstandard() { return pricingstandard; } public void setPricingstandard(String pricingstandard) { this.pricingstandard = pricingstandard; } public String getValuationbasis() { return valuationbasis; } public void setValuationbasis(String valuationbasis) { this.valuationbasis = valuationbasis; } public String getPricesdate() { return pricesdate; } public void setPricesdate(String pricesdate) { this.pricesdate = pricesdate; } public String getProjectphase() { return projectphase; } public void setProjectphase(String projectphase) { this.projectphase = projectphase; } public String getCosttype() { return costtype; } public void setCosttype(String costtype) { this.costtype = costtype; } public String getPreparationtime() { return preparationtime; } public void setPreparationtime(String preparationtime) { this.preparationtime = preparationtime; } public String getFlieno() { return flieno; } public void setFlieno(String flieno) { this.flieno = flieno; } public String getValuationtype() { return valuationtype; } public void setValuationtype(String valuationtype) { this.valuationtype = valuationtype; } public String getDesignunit() { return designunit; } public void setDesignunit(String designunit) { this.designunit = designunit; } public String getCategoryName() { return categoryName; } public void setCategoryName(String categoryName) { this.categoryName = categoryName; } public String getSubcategoryName() { return subcategoryName; } public void setSubcategoryName(String subcategoryName) { this.subcategoryName = subcategoryName; } public String getProjectphaseName() { return projectphaseName; } public void setProjectphaseName(String projectphaseName) { this.projectphaseName = projectphaseName; } public String getProUse() { return proUse; } public void setProUse(String proUse) { this.proUse = proUse; } public String getStoreyHeight() { return storeyHeight; } public void setStoreyHeight(String storeyHeight) { this.storeyHeight = storeyHeight; } public Double getStoreyNum() { return storeyNum; } public void setStoreyNum(Double storeyNum) { this.storeyNum = storeyNum; } public Double getEavesHeight() { return eavesHeight; } public void setEavesHeight(Double eavesHeight) { this.eavesHeight = eavesHeight; } public String getStartWorkDate() { return startWorkDate; } public void setStartWorkDate(String startWorkDate) { this.startWorkDate = startWorkDate; } public String getEndWorkDate() { return endWorkDate; } public void setEndWorkDate(String endWorkDate) { this.endWorkDate = endWorkDate; } public String getStructureType() { return structureType; } public void setStructureType(String structureType) { this.structureType = structureType; } public String getSeismicIntensity() { return seismicIntensity; } public void setSeismicIntensity(String seismicIntensity) { this.seismicIntensity = seismicIntensity; } public String getDecorateStandard() { return decorateStandard; } public void setDecorateStandard(String decorateStandard) { this.decorateStandard = decorateStandard; } public Double getConstructionArea() { return constructionArea; } public void setConstructionArea(Double constructionArea) { this.constructionArea = constructionArea; } public Double getUndergroundArea() { return undergroundArea; } public void setUndergroundArea(Double undergroundArea) { this.undergroundArea = undergroundArea; } public Double getOvergroundArea() { return overgroundArea; } public void setOvergroundArea(Double overgroundArea) { this.overgroundArea = overgroundArea; } public String getAreaUnit() { return areaUnit; } public void setAreaUnit(String areaUnit) { this.areaUnit = areaUnit; } }
ProjectExplainEnum.java
package com.concom.imports.project.enums; /** * 编制说明对应枚举 * @author Cao Zhili * @date 2015年4月23日 */ public enum ProjectExplainEnum { projectname("工程名称","String"),//工程名称 projectaddr("工程地点","String"),//工程地点 otherinfo("其它概况","String"),//工程其它状况 compilationbasis("编制依据","String"),//编制依据 blueprint("图纸","String"),//图纸 designunit("设计单位","String"),//设计单位 designdate("设计日期","String"),//设计日期 designation("图纸名称","String"),//图纸名称 pricingstandard("计价规范","String"),//计价规范 valuationbasis("计价依据","String"),//计价依据 flieno("计价程序表","String"),//计价文件 //2015-7-14新增 proUse("项目用途","String"),//项目用途 storeyHeight("层高(m)","String"), storeyNum("层数:","Double"), overgroundStoreyNum("地上层数:","String"), undergroundStoreyNum("地下层数:","String"), eavesHeight("总高度:","Double"),//檐高 structureType("结构类型","String"), constructionArea("建筑面积","Double"),//建筑面积 undergroundArea("±0.00以上:","Double"),//地下建筑面积 overgroundArea("±0.00以下:","Double");//地上建筑面积 /** * 名称 */ private String name; /** * 类型 */ private String type; /** * 构造方法 * @param name * @param type */ private ProjectExplainEnum(String name, String type){ this.name = name; this.type = type; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getType() { return type; } public void setType(String type) { this.type = type; } }
相关推荐
在我们的场景中,我们将关注如何读取Excel文件,尤其是处理那些合并了单元格的行与列,因为合并单元格在实际工作中往往用于组合或突出显示特定数据。 首先,确保已引入Apache POI库到项目中。在Maven项目中,可以在...
本篇将详细介绍如何使用Apache POI来读取Excel模板,复制工作表(Sheet)以及复制行,并特别关注如何处理合并单元格的情况。 首先,我们需要引入Apache POI的相关依赖库到我们的项目中。在Maven项目中,可以在pom....
本文将详细介绍如何使用Apache POI库来读取含有合并单元格的Excel文件,并将读取到的数据存储为`List`。 #### Apache POI简介 Apache POI是一个用于处理Microsoft Office格式文件的开源Java库。它提供了对Excel、...
在描述中提到的“ poi解析excel的工具类”,通常包含了一些常用的方法,例如打开文件、读取单元格数据、处理合并单元格等。以下是一些可能包含在该工具类中的关键方法: 1. **打开文件**:使用`WorkbookFactory`类...
【标题】"poi解析excel"涉及的是Java编程中使用Apache POI库来处理Microsoft Excel文件的知识。Apache POI是开源项目,提供了API用于读写Microsoft Office格式的文件,特别是Excel。在Java应用中,POI使得开发者能够...
Apache POI 是一个开源项目,专门用于处理 Microsoft Office 格式,如 Excel、Word 和 PowerPoint。在本场景中,我们关注的是如何使用 POI 库将 Excel 文件转换为 HTML 页面,同时保留原始 Excel 的样式信息,这对于...
在探讨“poi读取合并单元格帮助类”的知识点时,我们首先需要理解Apache POI库在Java中的作用以及如何处理Excel文件中的合并单元格。Apache POI是一个开源的API,它允许程序创建、修改和显示Microsoft Office格式的...
在Java编程环境中,Apache POI库是一个非常重要的工具,它允许开发者读取、写入以及修改Microsoft Office格式的文件,包括Excel的.xls和.xlsx格式。标题提到的"poi读取excel文件",指的是使用Apache POI库来处理...
本示例将详细讲解如何使用Java和POI库来解析Excel文档。 首先,我们需要引入Apache POI的相关依赖。如果你使用的是Maven项目,可以在pom.xml文件中添加以下依赖: ```xml <groupId>org.apache.poi <artifactId>...
以上就是关于Apache POI解析Excel所需jar包的基本介绍,通过这个库,你可以轻松地实现对Excel文件的各种操作,包括读取数据、写入数据、格式化单元格、合并单元格等。在实际开发中,根据具体需求,你可能还需要了解...
### NPOI读取模板导出Excel(合并单元格) #### 概述 在实际工作中,经常需要将数据导出到Excel文件中,并且在某些情况下还需要对单元格进行合并处理,以达到美观或者特定需求的目的。NPOI是.NET平台上一个强大的...
6. **高级功能**:POI还支持合并单元格、处理图表、解析公式等功能,可以根据具体需求进行深入研究。 7. **异常处理**:在处理Excel文件时,可能出现文件不存在、格式不正确、内存溢出等问题,需要适当地捕获并处理...
2. **数据分析**:当从 Excel 文件中读取数据进行分析时,确保能够正确识别和处理合并单元格可以帮助避免数据错误。 3. **自动化测试**:在进行 UI 自动化测试时,可能需要验证页面上的表格是否正确显示了 Excel ...
标题和描述提到的"java+poi+excel读取写入等操作所有jar(最新支持excel2013)"指的是使用Java POI库进行Excel文件的各种操作,并且这些操作适用于Excel 2013版本,这表明提供的jar文件应该包含了支持较新Excel格式...
Java 读取 Excel 文件是许多开发任务中的常见需求,Apache POI 是一个广泛使用的开源库,专门用于处理 Microsoft Office 格式的文件,包括 Excel。在本案例中,提供的压缩包 "poi.zip" 包含了两个子文件:poi-bin-...
标题"poi excel解析"指的是使用Apache POI库进行Excel文件的解析操作。 首先,我们需要理解POI的核心组件。HSSF(Horrible Spreadsheet Format)是处理老版本Excel文件的类库,而XSSF则是处理新版本OpenXML格式文件...
在上述代码中,使用Apache POI库来解析Excel 2010文件。以下是对关键知识点的详细说明: 1. **Apache POI**: Apache POI 是一个开源项目,允许Java应用程序创建、修改和显示Microsoft Office格式的文件。对于Excel...
在早期的POI版本中,读取合并单元格可能会导致数据丢失或错误。现在,POI提供了`CellRangeAddress`类,通过`Sheet.getMergedRegion(int index)`方法可以获取合并区域的信息。读取时,我们需要检查每个单元格是否属于...
本示例将详细介绍如何使用Apache POI解析Office Excel 2003和2007,以及Word 2003和2007的文件。 首先,我们来看Excel的解析。Excel 2003使用的是.BOOK文件格式(HSSFWorkbook),而2007及以上版本使用的是.XLSX...
Apache POI是一个开源项目,专为处理Microsoft Office格式的文件而设计,特别...通过学习和使用POI,你不仅可以解析Excel,还可以创建新的Excel文件,执行公式计算,处理图表,甚至合并单元格,从而满足各种业务需求。