Bug 56644: Fix adding cells if MissingCellPolicy is set to NULL_FOR_BLANK and the last column in a row is empty
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1647291 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
181de5f6e5
commit
0b6867d1d5
@ -37,6 +37,7 @@ import org.apache.poi.ss.usermodel.DateUtil;
|
||||
import org.apache.poi.ss.usermodel.FormulaError;
|
||||
import org.apache.poi.ss.usermodel.Hyperlink;
|
||||
import org.apache.poi.ss.usermodel.RichTextString;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.ss.util.CellReference;
|
||||
import org.apache.poi.util.Internal;
|
||||
@ -107,7 +108,7 @@ public final class XSSFCell implements Cell {
|
||||
} else {
|
||||
int prevNum = row.getLastCellNum();
|
||||
if(prevNum != -1){
|
||||
_cellNum = row.getCell(prevNum-1).getColumnIndex() + 1;
|
||||
_cellNum = row.getCell(prevNum-1, Row.RETURN_NULL_AND_BLANK).getColumnIndex() + 1;
|
||||
}
|
||||
}
|
||||
_sharedStringSource = row.getSheet().getWorkbook().getSharedStringSource();
|
||||
|
@ -407,4 +407,40 @@ public final class TestXSSFCell extends BaseTestCell {
|
||||
|
||||
XSSFTestDataSamples.writeOutAndReadBack(wb);
|
||||
}
|
||||
|
||||
public void testBug56644ReturnNull() throws IOException {
|
||||
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("56644.xlsx");
|
||||
try {
|
||||
wb.setMissingCellPolicy(Row.RETURN_BLANK_AS_NULL);
|
||||
Sheet sheet = wb.getSheet("samplelist");
|
||||
Row row = sheet.getRow(20);
|
||||
row.createCell(2);
|
||||
} finally {
|
||||
wb.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void testBug56644ReturnBlank() throws IOException {
|
||||
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("56644.xlsx");
|
||||
try {
|
||||
wb.setMissingCellPolicy(Row.RETURN_NULL_AND_BLANK);
|
||||
Sheet sheet = wb.getSheet("samplelist");
|
||||
Row row = sheet.getRow(20);
|
||||
row.createCell(2);
|
||||
} finally {
|
||||
wb.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void testBug56644CreateBlank() throws IOException {
|
||||
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("56644.xlsx");
|
||||
try {
|
||||
wb.setMissingCellPolicy(Row.CREATE_NULL_AS_BLANK);
|
||||
Sheet sheet = wb.getSheet("samplelist");
|
||||
Row row = sheet.getRow(20);
|
||||
row.createCell(2);
|
||||
} finally {
|
||||
wb.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
BIN
test-data/spreadsheet/56644.xlsx
Normal file
BIN
test-data/spreadsheet/56644.xlsx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user