/** * given a POI POIFSFileSystem object, and a specific directory * within it, read in its Workbook and populate the high and * low level models. If you're reading in a workbook...start here. * * @param directory the POI filesystem directory to process from * @param preserveNodes whether to preseve other nodes, such as * macros. This takes more memory, so only say yes if you * need to. If set, will store all of the POIFSFileSystem * in memory * @see org.apache.poi.poifs.filesystem.POIFSFileSystem * @exception IOException if the stream cannot be read */ public HSSFWorkbook(DirectoryNode directory, bool preserveNodes):base(directory) { String workbookName = GetWorkbookDirEntryName(directory); this.preserveNodes = preserveNodes; // If we're not preserving nodes, don't track the // POIFS any more if (!preserveNodes) { this.directory = null; } _sheets = new List<HSSFSheet>(INITIAL_CAPACITY); names = new List<HSSFName>(INITIAL_CAPACITY); // Grab the data from the workbook stream, however // it happens to be spelled. Stream stream = directory.CreatePOIFSDocumentReader(workbookName); List<Record> records = RecordFactory.CreateRecords(stream); workbook = InternalWorkbook.CreateWorkbook(records); SetPropertiesFromWorkbook(workbook); int recOffset = workbook.NumRecords; // Convert all LabelRecord records to LabelSSTRecord ConvertLabelRecords(records, recOffset); RecordStream rs = new RecordStream(records, recOffset); while (rs.HasNext()) { InternalSheet sheet = InternalSheet.CreateSheet(rs); _sheets.Add(new HSSFSheet(this, sheet)); } for (int i = 0; i < workbook.NumNames; ++i) { NameRecord nameRecord = workbook.GetNameRecord(i); HSSFName name = new HSSFName(this, workbook.GetNameRecord(i), workbook.GetNameCommentRecord(nameRecord)); names.Add(name); } }