git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1899091 13f79535-47bb-0310-9956-ffa450edef68tags/REL_5_2_3
safeGetProtectionField().setSelectUnlockedCells(enabled); | safeGetProtectionField().setSelectUnlockedCells(enabled); | ||||
} | } | ||||
/** | |||||
* Reads the dimensions of the sheet data | |||||
* @return dimensions of the sheet data as a Cell Range (can be null) | |||||
* @since POI 5.2.3 | |||||
*/ | |||||
public CellRangeAddress getDimension() { | |||||
CTSheetDimension ctSheetDimension = worksheet.getDimension(); | |||||
String ref = ctSheetDimension == null ? null : ctSheetDimension.getRef(); | |||||
if (ref != null) { | |||||
return CellRangeAddress.valueOf(ref); | |||||
} | |||||
return null; | |||||
} | |||||
private CTSheetProtection safeGetProtectionField() { | private CTSheetProtection safeGetProtectionField() { | ||||
if (!isSheetProtectionEnabled()) { | if (!isSheetProtectionEnabled()) { | ||||
return worksheet.addNewSheetProtection(); | return worksheet.addNewSheetProtection(); |
assertTrue(row2.getZeroHeight()); | assertTrue(row2.getZeroHeight()); | ||||
} | } | ||||
} | } | ||||
@Test | |||||
void testBug64536() throws IOException { | |||||
try ( | |||||
XSSFWorkbook xssfWorkbook = (XSSFWorkbook) _testDataProvider.openSampleWorkbook("1_NoIden.xlsx"); | |||||
UnsynchronizedByteArrayOutputStream bos = new UnsynchronizedByteArrayOutputStream() | |||||
) { | |||||
XSSFSheet fileSheet = xssfWorkbook.getSheetAt(0); | |||||
assertEquals(CellRangeAddress.valueOf("B1:D9"), fileSheet.getDimension()); | |||||
// Create Row and Cell, Then Set a Value | |||||
// 5, 2, 4 is just random number for test | |||||
Row fileRow = fileSheet.createRow(5); | |||||
Cell fileCell = fileRow.createCell(2, CellType.STRING); | |||||
fileCell.setCellValue("TEST VALUE"); | |||||
xssfWorkbook.write(bos); | |||||
try (XSSFWorkbook xssfWorkbook2 = new XSSFWorkbook(bos.toInputStream())) { | |||||
XSSFSheet xssfSheet = xssfWorkbook2.getSheetAt(0); | |||||
assertEquals(CellRangeAddress.valueOf("B1:F9"), xssfSheet.getDimension()); | |||||
} | |||||
} | |||||
} | |||||
} | } |