Search in sources :

Example 6 with SupBookRecord

use of org.apache.poi.hssf.record.SupBookRecord in project poi by apache.

the class TestSupBookRecord method testStoreAIF.

public void testStoreAIF() {
    SupBookRecord record = SupBookRecord.createAddInFunctions();
    assertEquals(1, record.getNumberOfSheets());
    assertTrue(record.isAddInFunctions());
    TestcaseRecordInputStream.confirmRecordEncoding(0x01AE, dataAIF, record.serialize());
}
Also used : SupBookRecord(org.apache.poi.hssf.record.SupBookRecord)

Example 7 with SupBookRecord

use of org.apache.poi.hssf.record.SupBookRecord in project poi by apache.

the class TestSupBookRecord method testExternalReferenceUrl.

public void testExternalReferenceUrl() {
    String[] sheetNames = new String[] { "SampleSheet" };
    final char startMarker = (char) 1;
    SupBookRecord record;
    record = new SupBookRecord(startMarker + "test.xls", sheetNames);
    assertEquals("test.xls", record.getURL());
    //UNC path notation
    record = new SupBookRecord(startMarker + "" + CH_VOLUME + "@servername" + CH_DOWN_DIR + "test.xls", sheetNames);
    assertEquals("\\\\servername" + PATH_SEPERATOR + "test.xls", record.getURL());
    //Absolute path notation - different device
    record = new SupBookRecord(startMarker + "" + CH_VOLUME + "D" + CH_DOWN_DIR + "test.xls", sheetNames);
    assertEquals("D:" + PATH_SEPERATOR + "test.xls", record.getURL());
    //Absolute path notation - same device
    record = new SupBookRecord(startMarker + "" + CH_SAME_VOLUME + "folder" + CH_DOWN_DIR + "test.xls", sheetNames);
    assertEquals(PATH_SEPERATOR + "folder" + PATH_SEPERATOR + "test.xls", record.getURL());
    //Relative path notation - down
    record = new SupBookRecord(startMarker + "folder" + CH_DOWN_DIR + "test.xls", sheetNames);
    assertEquals("folder" + PATH_SEPERATOR + "test.xls", record.getURL());
    //Relative path notation - up
    record = new SupBookRecord(startMarker + "" + CH_UP_DIR + "test.xls", sheetNames);
    assertEquals(".." + PATH_SEPERATOR + "test.xls", record.getURL());
    //Relative path notation - for EXCEL.exe - fallback
    record = new SupBookRecord(startMarker + "" + CH_STARTUP_DIR + "test.xls", sheetNames);
    assertEquals("." + PATH_SEPERATOR + "test.xls", record.getURL());
    //Relative path notation - for EXCEL lib folder - fallback
    record = new SupBookRecord(startMarker + "" + CH_LIB_DIR + "test.xls", sheetNames);
    assertEquals("." + PATH_SEPERATOR + "test.xls", record.getURL());
    //Relative path notation - for alternative EXCEL.exe - fallback
    record = new SupBookRecord(startMarker + "" + CH_ALT_STARTUP_DIR + "test.xls", sheetNames);
    assertEquals("." + PATH_SEPERATOR + "test.xls", record.getURL());
}
Also used : SupBookRecord(org.apache.poi.hssf.record.SupBookRecord)

Example 8 with SupBookRecord

use of org.apache.poi.hssf.record.SupBookRecord in project poi by apache.

the class TestSupBookRecord method testStoreIR.

/**
     * Tests that we can store the record
     *
     */
public void testStoreIR() {
    SupBookRecord record = SupBookRecord.createInternalReferences((short) 4);
    TestcaseRecordInputStream.confirmRecordEncoding(0x01AE, dataIR, record.serialize());
}
Also used : SupBookRecord(org.apache.poi.hssf.record.SupBookRecord)

Example 9 with SupBookRecord

use of org.apache.poi.hssf.record.SupBookRecord in project poi by apache.

the class LinkTable method checkExternSheet.

public int checkExternSheet(int firstSheetIndex, int lastSheetIndex) {
    // this is probably always zero
    int thisWbIndex = -1;
    for (int i = 0; i < _externalBookBlocks.length; i++) {
        SupBookRecord ebr = _externalBookBlocks[i].getExternalBookRecord();
        if (ebr.isInternalReferences()) {
            thisWbIndex = i;
            break;
        }
    }
    if (thisWbIndex < 0) {
        throw new RuntimeException("Could not find 'internal references' EXTERNALBOOK");
    }
    //Trying to find reference to this sheet
    int i = _externSheetRecord.getRefIxForSheet(thisWbIndex, firstSheetIndex, lastSheetIndex);
    if (i >= 0) {
        return i;
    }
    //We haven't found reference to this sheet
    return _externSheetRecord.addRef(thisWbIndex, firstSheetIndex, lastSheetIndex);
}
Also used : SupBookRecord(org.apache.poi.hssf.record.SupBookRecord)

Example 10 with SupBookRecord

use of org.apache.poi.hssf.record.SupBookRecord in project poi by apache.

the class LinkTable method getExternalSheetIndex.

public int getExternalSheetIndex(String workbookName, String firstSheetName, String lastSheetName) {
    int externalBookIndex = getExternalWorkbookIndex(workbookName);
    if (externalBookIndex == -1) {
        throw new RuntimeException("No external workbook with name '" + workbookName + "'");
    }
    SupBookRecord ebrTarget = _externalBookBlocks[externalBookIndex].getExternalBookRecord();
    int firstSheetIndex = getSheetIndex(ebrTarget.getSheetNames(), firstSheetName);
    int lastSheetIndex = getSheetIndex(ebrTarget.getSheetNames(), lastSheetName);
    // Find or add the external sheet record definition for this
    int result = _externSheetRecord.getRefIxForSheet(externalBookIndex, firstSheetIndex, lastSheetIndex);
    if (result < 0) {
        result = _externSheetRecord.addRef(externalBookIndex, firstSheetIndex, lastSheetIndex);
    }
    return result;
}
Also used : SupBookRecord(org.apache.poi.hssf.record.SupBookRecord)

Aggregations

SupBookRecord (org.apache.poi.hssf.record.SupBookRecord)13 ExternSheetRecord (org.apache.poi.hssf.record.ExternSheetRecord)3 CountryRecord (org.apache.poi.hssf.record.CountryRecord)2 EOFRecord (org.apache.poi.hssf.record.EOFRecord)2 ExternalNameRecord (org.apache.poi.hssf.record.ExternalNameRecord)2 Record (org.apache.poi.hssf.record.Record)2 NameXPtg (org.apache.poi.ss.formula.ptg.NameXPtg)2 ArrayList (java.util.ArrayList)1 BOFRecord (org.apache.poi.hssf.record.BOFRecord)1 BoundSheetRecord (org.apache.poi.hssf.record.BoundSheetRecord)1 CRNCountRecord (org.apache.poi.hssf.record.CRNCountRecord)1 CRNRecord (org.apache.poi.hssf.record.CRNRecord)1 NameCommentRecord (org.apache.poi.hssf.record.NameCommentRecord)1 NameRecord (org.apache.poi.hssf.record.NameRecord)1 SSTRecord (org.apache.poi.hssf.record.SSTRecord)1