Example #1
0
        public void TestLoadIR()
        {

            SupBookRecord record = new SupBookRecord(TestcaseRecordInputStream.Create(0x01AE, dataIR));
            Assert.IsTrue(record.IsInternalReferences);             //expected flag
            Assert.AreEqual(0x4, record.NumberOfSheets);    //expected # of sheets

            Assert.AreEqual(8, record.RecordSize);  //sid+size+data
        }
Example #2
0
        public void TestLoadER()
        {

            SupBookRecord record = new SupBookRecord(TestcaseRecordInputStream.Create(0x01AE, dataER));
            Assert.IsTrue(record.IsExternalReferences);             //expected flag
            Assert.AreEqual(0x2, record.NumberOfSheets);    //expected # of sheets

            Assert.AreEqual(34, record.RecordSize);  //sid+size+data

            Assert.AreEqual("testURL", record.URL);
            String[] sheetNames = record.SheetNames;
            Assert.AreEqual(2, sheetNames.Length);
            Assert.AreEqual("Sheet1", sheetNames[0]);
            Assert.AreEqual("Sheet2", sheetNames[1]);
        }
Example #3
0
        public void TestLoadAIF()
        {

            SupBookRecord record = new SupBookRecord(TestcaseRecordInputStream.Create(0x01AE, dataAIF));
            Assert.IsTrue(record.IsAddInFunctions);             //expected flag
            Assert.AreEqual(0x1, record.NumberOfSheets);    //expected # of sheets
            Assert.AreEqual(8, record.RecordSize);  //sid+size+data
        }
Example #4
0
 /**
  * Create a new block for internal references. It is called when constructing a new LinkTable.
  *
  * @see org.apache.poi.hssf.model.LinkTable#LinkTable(int, WorkbookRecordList)
  */
 public ExternalBookBlock(int numberOfSheets)
 {
     _externalBookRecord = SupBookRecord.CreateInternalReferences((short)numberOfSheets);
     _externalNameRecords = new ExternalNameRecord[0];
     _crnBlocks = new CRNBlock[0];
 }
Example #5
0
 /**
 * Create a new block for external references.
 */
 public ExternalBookBlock(String url, String[] sheetNames)
 {
     _externalBookRecord = SupBookRecord.CreateExternalReferences(url, sheetNames);
     _crnBlocks = new CRNBlock[0];
 }
Example #6
0
            public ExternalBookBlock(RecordStream rs)
            {
                _externalBookRecord = (SupBookRecord)rs.GetNext();
                ArrayList temp = new ArrayList();
                while (rs.PeekNextClass() == typeof(ExternalNameRecord))
                {
                    temp.Add(rs.GetNext());
                }
                _externalNameRecords = (ExternalNameRecord[])temp.ToArray(typeof(ExternalNameRecord));

                temp.Clear();

                while (rs.PeekNextClass() == typeof(CRNCountRecord))
                {
                    temp.Add(new CRNBlock(rs));
                }
                _crnBlocks = (CRNBlock[])temp.ToArray(typeof(CRNBlock));
            }
Example #7
0
 /**
  * Create a new block for registering add-in functions
  *
  * @see org.apache.poi.hssf.model.LinkTable#addNameXPtg(String)
  */
 public ExternalBookBlock()
 {
     _externalBookRecord = SupBookRecord.CreateAddInFunctions();
     _externalNameRecords = new ExternalNameRecord[0];
     _crnBlocks = new CRNBlock[0];
 }
        public void TestExternalReferenceUrl()
        {
            String[] sheetNames = new String[] { "SampleSheet" };
            char startMarker = (char)1;

            SupBookRecord record;

            record = new SupBookRecord(startMarker + "test.xls", sheetNames);
            Assert.AreEqual("test.xls", record.URL);

            //UNC path notation
            record = new SupBookRecord(startMarker + "" + SupBookRecord.CH_VOLUME + "@servername" + SupBookRecord.CH_DOWN_DIR + "test.xls", sheetNames);
            Assert.AreEqual("\\\\servername" + SupBookRecord.PATH_SEPERATOR + "test.xls", record.URL);

            //Absolute path notation - different device
            record = new SupBookRecord(startMarker + "" + SupBookRecord.CH_VOLUME + "D" + SupBookRecord.CH_DOWN_DIR + "test.xls", sheetNames);
            Assert.AreEqual("D:" + SupBookRecord.PATH_SEPERATOR + "test.xls", record.URL);

            //Absolute path notation - same device
            record = new SupBookRecord(startMarker + "" + SupBookRecord.CH_SAME_VOLUME + "folder" + SupBookRecord.CH_DOWN_DIR + "test.xls", sheetNames);
            Assert.AreEqual(SupBookRecord.PATH_SEPERATOR + "folder" + SupBookRecord.PATH_SEPERATOR + "test.xls", record.URL);

            //Relative path notation - down
            record = new SupBookRecord(startMarker + "folder" + SupBookRecord.CH_DOWN_DIR + "test.xls", sheetNames);
            Assert.AreEqual("folder" + SupBookRecord.PATH_SEPERATOR + "test.xls", record.URL);

            //Relative path notation - up
            record = new SupBookRecord(startMarker + "" + SupBookRecord.CH_UP_DIR + "test.xls", sheetNames);
            Assert.AreEqual(".." + SupBookRecord.PATH_SEPERATOR + "test.xls", record.URL);

            //Relative path notation - for EXCEL.exe - fallback
            record = new SupBookRecord(startMarker + "" + SupBookRecord.CH_STARTUP_DIR + "test.xls", sheetNames);
            Assert.AreEqual("." + SupBookRecord.PATH_SEPERATOR + "test.xls", record.URL);

            //Relative path notation - for EXCEL lib folder - fallback
            record = new SupBookRecord(startMarker + "" + SupBookRecord.CH_LIB_DIR + "test.xls", sheetNames);
            Assert.AreEqual("." + SupBookRecord.PATH_SEPERATOR + "test.xls", record.URL);

            //Relative path notation - for alternative EXCEL.exe - fallback
            record = new SupBookRecord(startMarker + "" + SupBookRecord.CH_ALT_STARTUP_DIR + "test.xls", sheetNames);
            Assert.AreEqual("." + SupBookRecord.PATH_SEPERATOR + "test.xls", record.URL);
        }