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());
}
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());
}
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());
}
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);
}
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;
}
Aggregations