标签:ORC ati 错误 代码 ast 类型 使用 astar erro
// 数据开始行,列 String startDataCell = "A2"; CellReference cellReference = new CellReference(startDataCell); int dataStartRow = cellReference.getRow(); int dataStartCol = cellReference.getCol();
int numMergedRegions = sheet.getNumMergedRegions(); for (int i = 0; i < numMergedRegions; i++) { CellRangeAddress mergedRegion = sourceSheet.getMergedRegion(i); int firstRow = mergedRegion.getFirstRow(); int firstColumn = mergedRegion.getFirstColumn(); int lastRow = mergedRegion.getLastRow(); int lastColumn = mergedRegion.getLastColumn(); // 根据坐标,创建新的合并区域 CellRangeAddress cellRangeAddress = new CellRangeAddress(firstRow, lastRow, firstColumn, lastColumn); targetSheet.addMergedRegion(cellRangeAddress); }
// 将源单元格的格式 赋值到 目标单元格中 CellStyle sourceCellStyle = sourceCell.getCellStyle(); /* 此处由于是新建了workbook对象,只能新建 CellStyle对象,然后clone,再赋值; 直接赋值 源CellStyle对象 会报不是同源异常 */ CellStyle targetCellStyle = targetWorkBook.createCellStyle(); targetCellStyle.cloneStyleFrom(sourceCellStyle); targetCell.setCellStyle(targetCellStyle);
// 获取单元格类型,处理公式单元格 CellType cellTypeEnum = sourceCell.getCellTypeEnum(); switch (cellTypeEnum) { case STRING: targetCell.setCellValue(sourceCell.getStringCellValue()); break; case NUMERIC: if (DateUtil.isCellDateFormatted(sourceCell)) { // 日期格式的值 targetCell.setCellValue(sourceCell.getDateCellValue()); } else { targetCell.setCellValue(sourceCell.getNumericCellValue()); } break; case BOOLEAN: targetCell.setCellValue(sourceCell.getBooleanCellValue()); break; case FORMULA: // ***为公式的情况下获取的是单元格的数值 try { targetCell.setCellValue(sourceCell.getNumericCellValue()); } catch (IllegalStateException e) { LOGGER.error("单元格公式计算错误:公式为" + sourceCell.getCellFormula()); targetCell.setCellValue("单元格计算出错"); } break; case BLANK: break; case ERROR: targetCell.setCellValue(sourceCell.getErrorCellValue()); break; case _NONE: break; default: }
// 获取计算器 FormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator(); // 计算所有的单元格的值 formulaEvaluator.evaluateAll();
//Excel依赖计算集合 Map<String, FormulaEvaluator> workbooks = new HashMap<>(); //放入依赖的计算器 workbooks.put(v.getModelFileName(),targetWorkbook.getCreationHelper().createFormulaEvaluator()); //给当前计算器设置依赖的计算器 FormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator(); formulaEvaluator.setupReferencedWorkbooks(workbooks); // 计算器计算 formulaEvaluator.evaluateAll();
标签:ORC ati 错误 代码 ast 类型 使用 astar erro
原文地址:https://www.cnblogs.com/rensheng/p/12217284.html