public void SaveSpreadsheet(Stream outputStream, Stream backgroundImage, ushort backgroundImageWidth, ushort backgroundImageHeight)
        {
            this.CompleteCurrentWorksheet();
            this.m_worksheet    = null;
            this.m_worksheetOut = null;
            Stream       stream       = this.m_createTempStream("Workbook");
            BinaryWriter binaryWriter = new BinaryWriter(stream, Encoding.Unicode);
            List <long>  list         = this.WriteGlobalStream(binaryWriter);
            bool         isFirstPage  = true;

            for (int i = 0; i < this.m_worksheets.Count; i++)
            {
                WorksheetInfo worksheetInfo = this.m_worksheets[i];
                worksheetInfo.ResolveCellReferences(this.m_bookmarks);
                worksheetInfo.Write(binaryWriter, isFirstPage, this.m_createTempStream, backgroundImage, backgroundImageWidth, backgroundImageHeight);
                isFirstPage = false;
            }
            for (int j = 0; j < list.Count; j++)
            {
                stream.Seek(list[j] + 4, SeekOrigin.Begin);
                binaryWriter.Write((uint)this.m_worksheets[j].BOFStartOffset);
            }
            this.m_worksheets = null;
            stream.Flush();
            stream.Seek(0L, SeekOrigin.Begin);
            StructuredStorage.CreateSingleStreamFile(stream, "Workbook", "00020820-0000-0000-c000-000000000046", outputStream, false);
            stream.Close();
            stream = null;
            outputStream.Flush();
        }
 private void AdjustWorksheetName(string reportName, WorksheetInfo workSheet)
 {
     if (!string.IsNullOrEmpty(reportName))
     {
         if (reportName.Length <= 31)
         {
             workSheet.SheetName = reportName;
         }
         else
         {
             workSheet.SheetName = reportName.Substring(0, 31);
         }
     }
 }
 private void AddNewWorksheet()
 {
     this.m_worksheet            = new WorksheetInfo(this.m_createTempStream("Page" + this.m_worksheets.Count + 1), ExcelRenderRes.SheetName + (this.m_worksheets.Count + 1));
     this.m_worksheet.SheetIndex = this.m_worksheets.Count;
     this.m_worksheets.Add(this.m_worksheet);
     this.m_worksheetOut     = new BinaryWriter(this.m_worksheet.CellData, Encoding.Unicode);
     this.m_numRowsThisBlock = 0;
     this.m_rowHandler       = null;
     this.m_column           = -1;
     this.m_cellValue        = null;
     this.m_cellValueType    = TypeCode.String;
     this.m_checkForRotatedEastAsianChars = false;
     this.m_startOfBlock         = -1L;
     this.m_rowIndexStartOfBlock = 0;
     this.m_startOfFirstCellData = 0L;
     this.m_lastDataCheckPoint   = -1L;
     this.m_styleContainer.Reset();
 }