public void Write(Stream stream) { FlushSheets(); //Save the template var tmplFile = TempFile.CreateTempFile("poi-sxssf-template", ".xlsx"); try { var os = new FileStream(tmplFile.FullName, FileMode.Open, FileAccess.ReadWrite); try { XssfWorkbook.Write(os); } finally { os.Close(); } //Substitute the template entries with the generated sheet data files InjectData(tmplFile, stream); } finally { tmplFile.Delete(); if (File.Exists(tmplFile.FullName)) { throw new IOException("Could not delete temporary file after processing: " + tmplFile); } } }
public void RemoveSheetAt(int index) { // Get the sheet to be removed var xSheet = (XSSFSheet)XssfWorkbook.GetSheetAt(index); var sxSheet = GetSXSSFSheet(xSheet); // De-register it XssfWorkbook.RemoveSheetAt(index); DeregisterSheetMapping(xSheet); // Clean up temporary resources try { sxSheet.Dispose(); } catch (IOException e) { logger.Log(POILogger.WARN, e); } }
public void Close() { // ensure that any lingering writer is closed foreach (SXSSFSheet sheet in _xFromSxHash.Values) { try { sheet._writer.Close(); } catch (IOException e) { logger.Log(POILogger.WARN, "An exception occurred while closing sheet data writer for sheet " + sheet.SheetName + ".", e); } } // Tell the base workbook to close, does nothing if // it's a newly created one XssfWorkbook.Close(); }
/** * Constructs an workbook from an existing workbook. * <p> * When a new node is created via createRow() and the total number * of unflushed records would exceed the specified value, then the * row with the lowest index value is flushed and cannot be accessed * via getRow() anymore. * </p> * <p> * A value of -1 indicates unlimited access. In this case all * records that have not been flushed by a call to flush() are available * for random access. * </p> * <p> * A value of 0 is not allowed because it would flush any newly created row * without having a chance to specify any cells. * </p> * * @param workbook the template workbook * @param rowAccessWindowSize the number of rows that are kept in memory until flushed out, see above. * @param compressTmpFiles whether to use gzip compression for temporary files * @param useSharedStringsTable whether to use a shared strings table */ /// <summary> /// Currently only supports writing not reading. E.g. the number of rows returned from a worksheet will be wrong etc. /// </summary> /// <param name="workbook"></param> /// <param name="rowAccessWindowSize"></param> /// <param name="compressTmpFiles"></param> /// <param name="useSharedStringsTable"></param> public SXSSFWorkbook(XSSFWorkbook workbook, int rowAccessWindowSize, bool compressTmpFiles, bool useSharedStringsTable) { RandomAccessWindowSize = rowAccessWindowSize; _compressTmpFiles = compressTmpFiles; if (workbook == null) { _wb = new XSSFWorkbook(); _sharedStringSource = useSharedStringsTable ? XssfWorkbook.GetSharedStringSource() : null; } else { _wb = workbook; _sharedStringSource = useSharedStringsTable ? XssfWorkbook.GetSharedStringSource() : null; var numberOfSheets = XssfWorkbook.NumberOfSheets; for (int i = 0; i < numberOfSheets; i++) { XSSFSheet sheet = (XSSFSheet)XssfWorkbook.GetSheetAt(i); CreateAndRegisterSXSSFSheet(sheet); } } }
public void SetPrintArea(int sheetIndex, string reference) { XssfWorkbook.SetPrintArea(sheetIndex, reference); }
public void RemoveName(int index) { XssfWorkbook.RemoveName(index); }
public void RemoveName(string name) { XssfWorkbook.RemoveName(name); }
public ISheet CreateSheet(string sheetname) { return(CreateAndRegisterSXSSFSheet(XssfWorkbook.CreateSheet(sheetname))); }
public int GetNameIndex(string name) { return(XssfWorkbook.GetNameIndex(name)); }
public IFont CreateFont() { return(XssfWorkbook.CreateFont()); }
public void AddToolPack(UDFFinder toopack) { XssfWorkbook.AddToolPack(toopack); }
public void RemovePrintArea(int sheetIndex) { XssfWorkbook.RemovePrintArea(sheetIndex); }
public int AddPicture(byte[] pictureData, PictureType format) { return(XssfWorkbook.AddPicture(pictureData, format)); }
public ICellStyle GetCellStyleAt(int idx) { return(XssfWorkbook.GetCellStyleAt(idx)); }
public ISheet GetSheetAt(int index) { return(GetSXSSFSheet((XSSFSheet)XssfWorkbook.GetSheetAt(index))); }
public ICellStyle CreateCellStyle() { return(XssfWorkbook.CreateCellStyle()); }
public IFont GetFontAt(short idx) { return(XssfWorkbook.GetFontAt(idx)); }
/** * Finds a font that matches the one with the supplied attributes * * @return the font with the matched attributes or <code>null</code> */ public IFont FindFont(bool bold, short color, short fontHeight, String name, bool italic, bool strikeout, FontSuperScript typeOffset, FontUnderlineType underline) { return(XssfWorkbook.FindFont(bold, color, fontHeight, name, italic, strikeout, typeOffset, underline)); }
public void SetPrintArea(int sheetIndex, int startColumn, int endColumn, int startRow, int endRow) { XssfWorkbook.SetPrintArea(sheetIndex, startColumn, endColumn, startRow, endRow); }
public bool IsSheetVeryHidden(int sheetIx) { return(XssfWorkbook.IsSheetVeryHidden(sheetIx)); }
public string GetPrintArea(int sheetIndex) { return(XssfWorkbook.GetPrintArea(sheetIndex)); }
public ISheet GetSheet(string name) { return(GetSXSSFSheet((XSSFSheet)XssfWorkbook.GetSheet(name))); }
public IDataFormat CreateDataFormat() { return(XssfWorkbook.CreateDataFormat()); }
public IName GetName(string name) { return(XssfWorkbook.GetName(name)); }
public IList GetAllPictures() { return(XssfWorkbook.GetAllPictures()); }
/** * Returns all defined names with the given name. * * @param name the name of the defined name * @return a list of the defined names with the specified name. An empty list is returned if none is found. */ public IList <IName> GetNames(String name) { return(XssfWorkbook.GetNames(name)); }
public void SetSheetHidden(int sheetIx, int hidden) { XssfWorkbook.SetSheetHidden(sheetIx, hidden); }
public IName GetNameAt(int nameIndex) { return(XssfWorkbook.GetNameAt(nameIndex)); }
/// <summary> /// Gets a bool value that indicates whether the date systems used in the workbook starts in 1904. /// The default value is false, meaning that the workbook uses the 1900 date system, /// where 1/1/1900 is the first day in the system. /// </summary> /// <returns>True if the date systems used in the workbook starts in 1904</returns> public bool IsDate1904() { return(XssfWorkbook.IsDate1904()); }
public IName CreateName() { return(XssfWorkbook.CreateName()); }