Search in sources :

Example 21 with NameRecord

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();
}
Also used : NameRecord(org.apache.poi.hssf.record.NameRecord) Test(org.junit.Test)

Example 22 with NameRecord

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();
}
Also used : NameRecord(org.apache.poi.hssf.record.NameRecord) CellRangeAddress(org.apache.poi.ss.util.CellRangeAddress) InternalSheet(org.apache.poi.hssf.model.InternalSheet) Test(org.junit.Test)

Example 23 with NameRecord

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));
}
Also used : NameRecord(org.apache.poi.hssf.record.NameRecord) UnicodeString(org.apache.poi.hssf.record.common.UnicodeString)

Aggregations

NameRecord (org.apache.poi.hssf.record.NameRecord)23 Area3DPtg (org.apache.poi.ss.formula.ptg.Area3DPtg)9 Test (org.junit.Test)9 Ptg (org.apache.poi.ss.formula.ptg.Ptg)7 InternalWorkbook (org.apache.poi.hssf.model.InternalWorkbook)4 Record (org.apache.poi.hssf.record.Record)3 MemFuncPtg (org.apache.poi.ss.formula.ptg.MemFuncPtg)3 NameXPtg (org.apache.poi.ss.formula.ptg.NameXPtg)3 Ref3DPtg (org.apache.poi.ss.formula.ptg.Ref3DPtg)3 UnionPtg (org.apache.poi.ss.formula.ptg.UnionPtg)3 CellRangeAddress (org.apache.poi.ss.util.CellRangeAddress)3 InternalSheet (org.apache.poi.hssf.model.InternalSheet)2 AutoFilterInfoRecord (org.apache.poi.hssf.record.AutoFilterInfoRecord)2 BOFRecord (org.apache.poi.hssf.record.BOFRecord)2 CommonObjectDataSubRecord (org.apache.poi.hssf.record.CommonObjectDataSubRecord)2 EOFRecord (org.apache.poi.hssf.record.EOFRecord)2 UnicodeString (org.apache.poi.hssf.record.common.UnicodeString)2 HSSFName (org.apache.poi.hssf.usermodel.HSSFName)2 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)2 OperandPtg (org.apache.poi.ss.formula.ptg.OperandPtg)2