internal BIFF8Generator(ExcelGeneratorConstants.CreateTempStream createTempStream)
 {
     m_createTempStream = createTempStream;
     m_styleContainer   = new StyleContainer();
     m_worksheetNames.Add(ExcelRenderRes.SheetName.ToUpperInvariant(), 1);
     AddNewWorksheet();
 }
        private XMLStreamsheetModel CreateSheet(string sheetName, ExcelGeneratorConstants.CreateTempStream createTempStream)
        {
            XMLStreamsheetModel xMLStreamsheetModel = new XMLStreamsheetModel((XMLStreambookModel)Workbook, this, Manager, sheetName, createTempStream);

            Worksheets.Add(xMLStreamsheetModel);
            _currentSheet = xMLStreamsheetModel;
            return(xMLStreamsheetModel);
        }
Exemplo n.º 3
0
 public OpenXmlGenerator(ExcelGeneratorConstants.CreateTempStream createTempStream)
 {
     this._createTempStream = createTempStream;
     this._application      = new ExcelApplication();
     this._workbookStream   = this._createTempStream("oxmlWorkbook");
     this._workbook         = this._application.CreateStreaming(this._workbookStream);
     this.CreateNewSheet();
     this._worksheetNames = new Dictionary <string, int>();
     this._worksheetNames.Add(ExcelRenderRes.SheetName.ToUpperInvariant(), 1);
     this._mergedCells                   = new List <MergeInfo>();
     this._hyperlinks                    = new List <LinkInfo>();
     this._bookmarkLinks                 = new List <LinkInfo>();
     this._unresolvedStreamsheets        = new List <UnresolvedStreamsheet>();
     this._bookmarkTargets               = new Dictionary <string, BookmarkTargetInfo>();
     this._cachedstyles                  = new Dictionary <string, Style>();
     this._nextPaletteIndex              = 0;
     this._picturesStartingOnCurrentRow  = new List <Picture>();
     this._picturesToUpdateByEndRow      = new Dictionary <int, List <Picture> >();
     this._picturesToUpdateByStartColumn = new Dictionary <int, List <Picture> >();
     this._picturesToUpdateByEndColumn   = new Dictionary <int, List <Picture> >();
     this._unresolvedPictureBookmarks    = new List <PictureLinkInfo>();
 }
Exemplo n.º 4
0
 public virtual IStreamsheetModel CreateStreamsheet(string sheetName, ExcelGeneratorConstants.CreateTempStream createTempStream)
 {
     throw new FatalException();
 }
Exemplo n.º 5
0
        internal void Write(BinaryWriter writer, bool isFirstPage, ExcelGeneratorConstants.CreateTempStream createTempStream, Stream backgroundImage, ushort backgroundImageWidth, ushort backgroundImageHeight)
        {
            BOFStartOffset = writer.BaseStream.Position;
            RecordFactory.BOF(writer, RecordFactory.BOFSubstreamType.Worksheet);
            RecordFactory.INDEX(writer, RowFirst, RowLast, DBCellOffsets);
            writer.BaseStream.Write(Constants.WORKSHEET1, 0, Constants.WORKSHEET1.Length);
            RecordFactory.GUTS(writer, m_maxRowOutline, m_maxColOutline);
            RecordFactory.WSBOOL(writer, m_summaryRowBelow, m_summaryColumnToRight);
            writer.BaseStream.Write(Constants.WORKSHEET2, 0, Constants.WORKSHEET2.Length);
            RecordFactory.SETUP(writer, (ushort)m_paperSize, m_isPortrait, m_headerMargin, m_footerMargin);
            RecordFactory.MARGINS(writer, m_topMargin, m_bottomMargin, m_leftMargin, m_rightMargin);
            if (backgroundImage != null)
            {
                RecordFactory.BACKGROUNDIMAGE(writer, backgroundImage, backgroundImageWidth, backgroundImageHeight);
            }
            if (HeaderString != null && HeaderString.Length > 0)
            {
                RecordFactory.HEADER(writer, HeaderString);
            }
            if (FooterString != null && FooterString.Length > 0)
            {
                RecordFactory.FOOTER(writer, FooterString);
            }
            for (int i = ColFirst; i <= ColLast; i++)
            {
                ColumnInfo columnInfo = Columns[i];
                if (columnInfo != null)
                {
                    RecordFactory.COLINFO(writer, (ushort)i, columnInfo.Width, columnInfo.OutlineLevel, columnInfo.Collapsed);
                }
                else
                {
                    RecordFactory.COLINFO(writer, (ushort)i, 0.0, 0, collapsed: false);
                }
            }
            RecordFactory.DIMENSIONS(writer, RowFirst, RowLast, ColFirst, ColLast);
            byte[] array = new byte[4096];
            CellData.Seek(0L, SeekOrigin.Begin);
            int count;

            while ((count = CellData.Read(array, 0, array.Length)) > 0)
            {
                writer.BaseStream.Write(array, 0, count);
            }
            CellData.Close();
            CellData = null;
            if (m_drawingContainer != null)
            {
                foreach (ImageCache image in m_images)
                {
                    if (image.HyperlinkURL == null)
                    {
                        m_drawingContainer.AddShape(image.ShapeID, image.Name, image.ClientAnchor, image.RefIndex);
                    }
                    else
                    {
                        m_drawingContainer.AddShape(image.ShapeID, image.Name, image.ClientAnchor, image.RefIndex, image.HyperlinkURL, image.IsBookmark ? Escher.HyperlinkType.BOOKMARK : Escher.HyperlinkType.URL);
                    }
                }
                m_drawingContainer.WriteToStream(writer);
            }
            RecordFactory.WINDOW2(writer, m_rowSplit > 0 || m_columnSplit > 0, isFirstPage);
            if (m_rowSplit > 0 || m_columnSplit > 0)
            {
                RecordFactory.PANE(writer, m_columnSplit, m_rowSplit, m_rowSplit, m_columnSplit, 2);
            }
            writer.BaseStream.Write(Constants.WORKSHEET3, 0, Constants.WORKSHEET3.Length);
            RecordFactory.MERGECELLS(writer, MergeCellAreas);
            foreach (HyperlinkInfo hyperlink in m_hyperlinks)
            {
                RecordFactory.HLINK(writer, hyperlink);
            }
            writer.BaseStream.Write(Constants.WORKSHEET4, 0, Constants.WORKSHEET4.Length);
        }
 public virtual IExcelGenerator CreateExcelGenerator(ExcelGeneratorConstants.CreateTempStream createTempStream)
 {
     return(new BIFF8Generator(createTempStream));
 }
Exemplo n.º 7
0
 internal override IExcelGenerator CreateExcelGenerator(ExcelGeneratorConstants.CreateTempStream createTempStream)
 {
     return(new OpenXmlGenerator(createTempStream));
 }
Exemplo n.º 8
0
        public XMLStreamsheetModel(XMLWorkbookModel workbook, XMLWorksheetsModel sheets, PartManager manager, string name, ExcelGeneratorConstants.CreateTempStream createTempStream)
        {
            _workbookModel   = workbook;
            _worksheetsModel = sheets;
            _manager         = manager;
            _interface       = new Streamsheet(this);
            Relationship    relationship = _manager.AddStreamingPartToTree("application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet", "xl/worksheets/sheet{0}.xml", (XmlPart)_manager.GetPartByContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"));
            List <CT_Sheet> sheet        = ((CT_Workbook)_manager.Workbook.Root).Sheets.Sheet;

            _sheetentry              = new CT_Sheet();
            _sheetentry.Id_Attr      = relationship.RelationshipId;
            _sheetentry.Name_Attr    = name;
            _sheetentry.SheetId_Attr = sheets.NextId;
            sheet.Add(_sheetentry);
            _partName   = relationship.RelatedPart;
            _headStream = createTempStream(string.Format(CultureInfo.InvariantCulture, "streamsheetHead{0}", _sheetentry.SheetId_Attr));
            _tailStream = createTempStream(string.Format(CultureInfo.InvariantCulture, "streamsheetTail{0}", _sheetentry.SheetId_Attr));
            _headWriter = new StreamsheetParser(new StreamWriter(_headStream), startAtPrelude: true);
            _tailWriter = new StreamsheetParser(new StreamWriter(_tailStream), startAtPrelude: false);
            _headWriter.WritePrelude();
        }
Exemplo n.º 9
0
 public Streamsheet CreateStreamsheet(string name, ExcelGeneratorConstants.CreateTempStream createTempStream)
 {
     return(_model.CreateStreamsheet(name, createTempStream).Interface);
 }
 public override IStreamsheetModel CreateStreamsheet(string sheetName, ExcelGeneratorConstants.CreateTempStream createTempStream)
 {
     return(CreateSheet(sheetName, createTempStream));
 }