Area3DPxg area3DPxg = (Area3DPxg) ptg;
if (area3DPxg.getExternalWorkbookNumber() > 0) {
EvaluationWorkbook.ExternalSheet externalSheet = getEvaluationWorkbook().getExternalSheet(area3DPxg.getSheetName(), area3DPxg.getLastSheetName(), area3DPxg.getExternalWorkbookNumber());
+ if (externalSheet != null) {
+ processEvalCell((XSSFEvaluationCell) evalCell, externalSheet, area3DPxg);
+ }
+ }
- XSSFCell xssfCell = ((XSSFEvaluationCell) evalCell).getXSSFCell();
- XSSFWorkbook externalWorkbook = (XSSFWorkbook) xssfCell.getSheet().getWorkbook().getCreationHelper().getReferencedWorkbooks().get(externalSheet.getWorkbookName());
- ExternalLinksTable externalLinksTable = xssfCell.getSheet().getWorkbook().getExternalLinksTable().get(area3DPxg.getExternalWorkbookNumber() - 1);
+ }
+ }
+ }
- int firstSheet = externalWorkbook.getSheetIndex(area3DPxg.getSheetName());
- int lastSheet = firstSheet;
- if (area3DPxg.getLastSheetName() != null) {
- lastSheet = externalWorkbook.getSheetIndex(area3DPxg.getLastSheetName());
- }
+ private static void processEvalCell(XSSFEvaluationCell evalCell,
+ EvaluationWorkbook.ExternalSheet externalSheet, Area3DPxg area3DPxg) {
+ XSSFCell xssfCell = evalCell.getXSSFCell();
+
+ XSSFWorkbook xssfWorkbook = xssfCell.getSheet().getWorkbook();
+ XSSFWorkbook externalWorkbook = (XSSFWorkbook) xssfWorkbook.getCreationHelper()
+ .getReferencedWorkbooks().get(externalSheet.getWorkbookName());
+ ExternalLinksTable externalLinksTable = xssfWorkbook.getExternalLinksTable().get(area3DPxg.getExternalWorkbookNumber() - 1);
- for (int sheetIndex = firstSheet; sheetIndex <= lastSheet; sheetIndex++) {
- XSSFSheet sheet = externalWorkbook.getSheetAt(sheetIndex);
- int firstRow = area3DPxg.getFirstRow();
- int lastRow = area3DPxg.getLastRow();
- for (int rowIndex = firstRow; rowIndex <= lastRow; rowIndex++) {
- XSSFRow row = sheet.getRow(rowIndex);
- int firstColumn = area3DPxg.getFirstColumn();
- int lastColumn = area3DPxg.getLastColumn();
- for (int cellIndex = firstColumn; cellIndex <= lastColumn; cellIndex++) {
- XSSFCell cell = row.getCell(cellIndex);
- String cellValue = cell.getRawValue();
- String cellR = new CellReference(cell).formatAsString(false);
- externalLinksTable.cacheData(sheet.getSheetName(), (long)rowIndex + 1, cellR, cellValue);
- }
- }
+ if (externalWorkbook != null && externalLinksTable != null) {
+ int firstSheet = externalWorkbook.getSheetIndex(area3DPxg.getSheetName());
+ int lastSheet = firstSheet;
+ if (area3DPxg.getLastSheetName() != null) {
+ lastSheet = externalWorkbook.getSheetIndex(area3DPxg.getLastSheetName());
+ }
+ for (int sheetIndex = firstSheet; sheetIndex <= lastSheet; sheetIndex++) {
+ XSSFSheet sheet = externalWorkbook.getSheetAt(sheetIndex);
+ int firstRow = area3DPxg.getFirstRow();
+ int lastRow = area3DPxg.getLastRow();
+ for (int rowIndex = firstRow; rowIndex <= lastRow; rowIndex++) {
+ XSSFRow row = sheet.getRow(rowIndex);
+ int firstColumn = area3DPxg.getFirstColumn();
+ int lastColumn = area3DPxg.getLastColumn();
+ for (int cellIndex = firstColumn; cellIndex <= lastColumn; cellIndex++) {
+ XSSFCell cell = row.getCell(cellIndex);
+ String cellValue = cell.getRawValue();
+ String cellR = new CellReference(cell).formatAsString(false);
+ externalLinksTable.cacheData(sheet.getSheetName(), (long)rowIndex + 1, cellR, cellValue);
}
}
-
}
}
}