mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
[bug-66607] perf issue processing array formulas
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1909934 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4ec360b006
commit
60d5336f7c
@ -113,7 +113,8 @@ public class XSSFImportFromXML {
|
||||
String textContent = result.getTextContent();
|
||||
LOG.atDebug().log("Extracting with xpath {} : value is '{}'", xpathString, textContent);
|
||||
XSSFCell cell = singleXmlCell.getReferencedCell();
|
||||
LOG.atDebug().log("Setting '{}' to cell {}-{} in sheet {}", textContent, box(cell.getColumnIndex()),box(cell.getRowIndex()),cell.getSheet().getSheetName());
|
||||
LOG.atDebug().log("Setting '{}' to cell {}-{} in sheet {}", textContent,
|
||||
box(cell.getColumnIndex()), box(cell.getRowIndex()), cell.getSheet().getSheetName());
|
||||
setCellValue(textContent, cell, xmlDataType);
|
||||
}
|
||||
}
|
||||
@ -158,7 +159,8 @@ public class XSSFImportFromXML {
|
||||
if (cell == null) {
|
||||
cell = row.createCell(columnId);
|
||||
}
|
||||
LOG.atDebug().log("Setting '{}' to cell {}-{} in sheet {}", value, box(cell.getColumnIndex()),box(cell.getRowIndex()),table.getXSSFSheet().getSheetName());
|
||||
LOG.atDebug().log("Setting '{}' to cell {}-{} in sheet {}", value,
|
||||
box(cell.getColumnIndex()), box(cell.getRowIndex()), table.getXSSFSheet().getSheetName());
|
||||
setCellValue(value, cell, xmlColumnPr.getXmlDataType());
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ public final class XSSFEvaluationWorkbook extends BaseXSSFEvaluationWorkbook {
|
||||
public Ptg[] getFormulaTokens(EvaluationCell evalCell) {
|
||||
final XSSFCell cell = ((XSSFEvaluationCell)evalCell).getXSSFCell();
|
||||
final int sheetIndex = _uBook.getSheetIndex(cell.getSheet());
|
||||
final int rowIndex = cell.getRowIndex();
|
||||
return FormulaParser.parse(cell.getCellFormula(this), this, FormulaType.CELL, sheetIndex, rowIndex);
|
||||
return FormulaParser.parse(cell.getCellFormula(this), this,
|
||||
FormulaType.CELL, sheetIndex, cell.getRowIndex());
|
||||
}
|
||||
}
|
||||
|
||||
@ -4171,8 +4171,10 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet, OoxmlSheetEx
|
||||
}
|
||||
|
||||
/* package */ boolean isCellInArrayFormulaContext(XSSFCell cell) {
|
||||
final int rowIndex = cell.getRowIndex();
|
||||
final int columnIndex = cell.getColumnIndex();
|
||||
for (CellRangeAddress range : arrayFormulas) {
|
||||
if (range.isInRange(cell.getRowIndex(), cell.getColumnIndex())) {
|
||||
if (range.isInRange(rowIndex, columnIndex)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -4180,8 +4182,10 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet, OoxmlSheetEx
|
||||
}
|
||||
|
||||
/* package */ XSSFCell getFirstCellInArrayFormula(XSSFCell cell) {
|
||||
final int rowIndex = cell.getRowIndex();
|
||||
final int columnIndex = cell.getColumnIndex();
|
||||
for (CellRangeAddress range : arrayFormulas) {
|
||||
if (range.isInRange(cell.getRowIndex(), cell.getColumnIndex())) {
|
||||
if (range.isInRange(rowIndex, columnIndex)) {
|
||||
return getRow(range.getFirstRow()).getCell(range.getFirstColumn());
|
||||
}
|
||||
}
|
||||
@ -4868,18 +4872,19 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet, OoxmlSheetEx
|
||||
* @param cell The cell that is removed
|
||||
* @param evalWb BaseXSSFEvaluationWorkbook in use, if one exists
|
||||
*/
|
||||
protected void onDeleteFormula(XSSFCell cell, BaseXSSFEvaluationWorkbook evalWb){
|
||||
|
||||
protected void onDeleteFormula(final XSSFCell cell, final BaseXSSFEvaluationWorkbook evalWb) {
|
||||
final int rowIndex = cell.getRowIndex();
|
||||
final int columnIndex = cell.getColumnIndex();
|
||||
CTCellFormula f = cell.getCTCell().getF();
|
||||
if (f != null && f.getT() == STCellFormulaType.SHARED && f.isSetRef() && f.getStringValue() != null) {
|
||||
|
||||
CellRangeAddress ref = CellRangeAddress.valueOf(f.getRef());
|
||||
if(ref.getNumberOfCells() > 1){
|
||||
DONE:
|
||||
for(int i = cell.getRowIndex(); i <= ref.getLastRow(); i++){
|
||||
for(int i = rowIndex; i <= ref.getLastRow(); i++){
|
||||
XSSFRow row = getRow(i);
|
||||
if(row != null) {
|
||||
for(int j = cell.getColumnIndex(); j <= ref.getLastColumn(); j++){
|
||||
for(int j = columnIndex; j <= ref.getLastColumn(); j++){
|
||||
XSSFCell nextCell = row.getCell(j);
|
||||
if(nextCell != null && nextCell != cell && nextCell.getCellType() == CellType.FORMULA) {
|
||||
CTCellFormula nextF = nextCell.getCTCell().getF();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user