use of org.apache.poi.hssf.record.NameRecord in project poi by apache.
the class TestHSSFSheet method setRepeatingRowsAndColumnsBug29747.
/**
* Test for Bugzilla #29747.
* Moved from TestHSSFWorkbook#testSetRepeatingRowsAndColumns().
*/
@Test
public void setRepeatingRowsAndColumnsBug29747() throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
wb.createSheet();
wb.createSheet();
HSSFSheet sheet2 = wb.createSheet();
sheet2.setRepeatingRows(CellRangeAddress.valueOf("1:2"));
NameRecord nameRecord = wb.getWorkbook().getNameRecord(0);
assertEquals(3, nameRecord.getSheetNumber());
wb.close();
}
use of org.apache.poi.hssf.record.NameRecord in project poi by apache.
the class TestHSSFSheet method bug55723b.
@Test
public void bug55723b() throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet();
// stored with a special name
assertNull(wb.getWorkbook().getSpecificBuiltinRecord(NameRecord.BUILTIN_FILTER_DB, 1));
CellRangeAddress range = CellRangeAddress.valueOf("A:B");
AutoFilter filter = sheet.setAutoFilter(range);
assertNotNull(filter);
// stored with a special name
NameRecord record = wb.getWorkbook().getSpecificBuiltinRecord(NameRecord.BUILTIN_FILTER_DB, 1);
assertNotNull(record);
wb.close();
}
use of org.apache.poi.hssf.record.NameRecord in project poi by apache.
the class HSSFWorkbook method setPrintArea.
/**
* Sets the printarea for the sheet provided
* <p>
* i.e. Reference = $A$1:$B$2
* @param sheetIndex Zero-based sheet index (0 Represents the first sheet to keep consistent with java)
* @param reference Valid name Reference for the Print Area
*/
@Override
public void setPrintArea(int sheetIndex, String reference) {
NameRecord name = workbook.getSpecificBuiltinRecord(NameRecord.BUILTIN_PRINT_AREA, sheetIndex + 1);
if (name == null) {
name = workbook.createBuiltInName(NameRecord.BUILTIN_PRINT_AREA, sheetIndex + 1);
// adding one here because 0 indicates a global named region; doesn't make sense for print areas
}
String[] parts = COMMA_PATTERN.split(reference);
StringBuffer sb = new StringBuffer(32);
for (int i = 0; i < parts.length; i++) {
if (i > 0) {
sb.append(",");
}
SheetNameFormatter.appendFormat(sb, getSheetName(sheetIndex));
sb.append("!");
sb.append(parts[i]);
}
name.setNameDefinition(HSSFFormulaParser.parse(sb.toString(), this, FormulaType.NAMEDRANGE, sheetIndex));
}
Aggregations