Esempio n. 1
0
        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);
                }
            }
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
        /**
         * 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);
                }
            }
        }
Esempio n. 5
0
 public void SetPrintArea(int sheetIndex, string reference)
 {
     XssfWorkbook.SetPrintArea(sheetIndex, reference);
 }
Esempio n. 6
0
 public void RemoveName(int index)
 {
     XssfWorkbook.RemoveName(index);
 }
Esempio n. 7
0
 public void RemoveName(string name)
 {
     XssfWorkbook.RemoveName(name);
 }
Esempio n. 8
0
 public ISheet CreateSheet(string sheetname)
 {
     return(CreateAndRegisterSXSSFSheet(XssfWorkbook.CreateSheet(sheetname)));
 }
Esempio n. 9
0
 public int GetNameIndex(string name)
 {
     return(XssfWorkbook.GetNameIndex(name));
 }
Esempio n. 10
0
 public IFont CreateFont()
 {
     return(XssfWorkbook.CreateFont());
 }
Esempio n. 11
0
 public void AddToolPack(UDFFinder toopack)
 {
     XssfWorkbook.AddToolPack(toopack);
 }
Esempio n. 12
0
 public void RemovePrintArea(int sheetIndex)
 {
     XssfWorkbook.RemovePrintArea(sheetIndex);
 }
Esempio n. 13
0
 public int AddPicture(byte[] pictureData, PictureType format)
 {
     return(XssfWorkbook.AddPicture(pictureData, format));
 }
Esempio n. 14
0
 public ICellStyle GetCellStyleAt(int idx)
 {
     return(XssfWorkbook.GetCellStyleAt(idx));
 }
Esempio n. 15
0
 public ISheet GetSheetAt(int index)
 {
     return(GetSXSSFSheet((XSSFSheet)XssfWorkbook.GetSheetAt(index)));
 }
Esempio n. 16
0
 public ICellStyle CreateCellStyle()
 {
     return(XssfWorkbook.CreateCellStyle());
 }
Esempio n. 17
0
 public IFont GetFontAt(short idx)
 {
     return(XssfWorkbook.GetFontAt(idx));
 }
Esempio n. 18
0
 /**
  * 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));
 }
Esempio n. 19
0
 public void SetPrintArea(int sheetIndex, int startColumn, int endColumn, int startRow, int endRow)
 {
     XssfWorkbook.SetPrintArea(sheetIndex, startColumn, endColumn, startRow, endRow);
 }
Esempio n. 20
0
 public bool IsSheetVeryHidden(int sheetIx)
 {
     return(XssfWorkbook.IsSheetVeryHidden(sheetIx));
 }
Esempio n. 21
0
 public string GetPrintArea(int sheetIndex)
 {
     return(XssfWorkbook.GetPrintArea(sheetIndex));
 }
Esempio n. 22
0
 public ISheet GetSheet(string name)
 {
     return(GetSXSSFSheet((XSSFSheet)XssfWorkbook.GetSheet(name)));
 }
Esempio n. 23
0
 public IDataFormat CreateDataFormat()
 {
     return(XssfWorkbook.CreateDataFormat());
 }
Esempio n. 24
0
 public IName GetName(string name)
 {
     return(XssfWorkbook.GetName(name));
 }
Esempio n. 25
0
 public IList GetAllPictures()
 {
     return(XssfWorkbook.GetAllPictures());
 }
Esempio n. 26
0
 /**
  * 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));
 }
Esempio n. 27
0
 public void SetSheetHidden(int sheetIx, int hidden)
 {
     XssfWorkbook.SetSheetHidden(sheetIx, hidden);
 }
Esempio n. 28
0
 public IName GetNameAt(int nameIndex)
 {
     return(XssfWorkbook.GetNameAt(nameIndex));
 }
Esempio n. 29
0
 /// <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());
 }
Esempio n. 30
0
 public IName CreateName()
 {
     return(XssfWorkbook.CreateName());
 }