/// <summary> /// Create a new Excel workbook with 1 sheet named 'Sheet1' in memory. /// Use save to persist your changes. /// </summary> public void Create() { xlWorkbook = new HSSFWorkbook(); CreateSheet("Sheet1"); styleCache = new CellStyleCache(xlWorkbook); fontCache = new FontCache((HSSFWorkbook)xlWorkbook); }
/// <summary> /// Read an excel workbook from a stream. The first sheet will be selected. The stream will be closed. /// </summary> /// <param name="xlsStream">The stream to read an excel workbook from</param> public void Open(Stream xlsStream) { try { xlWorkbook = new HSSFWorkbook(xlsStream); xlSheet = xlWorkbook.GetSheetAt(0); styleCache = new CellStyleCache(xlWorkbook); fontCache = new FontCache((HSSFWorkbook)xlWorkbook); } finally { if (xlsStream != null) xlsStream.Close(); } }