Пример #1
0
        public Stream GetExcel(BaseJournalUserControl <TDataContext, TFilterControl, TKey, TTable, TDataSource, TRow, TJournal, TNavigatorControl, TNavigatorValues, TFilter> journalControl, RvsSavedProperties properties)
        {
            var page = new Page();

            _journalControl = journalControl;
            _journalControl.StorageValues = properties.StorageValues;
            _journalControl.InitializeControls(properties);
            page.TemplateControl.Controls.Add(_journalControl);
            var stream       = new MemoryStream();
            var streamWriter = new StreamWriter(stream);

            _writer = new XmlTextWriter(streamWriter)
            {
                Formatting = Formatting.Indented
            };
            _writer.WriteProcessingInstruction("xml", "version=\"1.0\"");
            _writer.WriteProcessingInstruction("mso-application", "progid=\"Excel.Sheet\"");
            _writer.WriteStartElement("Workbook");
            _writer.WriteAttributeString("xmlns", "urn:schemas-microsoft-com:office:spreadsheet");
            _writer.WriteAttributeString("xmlns:o", "urn:schemas-microsoft-com:office:office");
            _writer.WriteAttributeString("xmlns:x", "urn:schemas-microsoft-com:office:excel");
            _writer.WriteAttributeString("xmlns:ss", "urn:schemas-microsoft-com:office:spreadsheet");
            _writer.WriteAttributeString("xmlns:html", "http://www.w3.org/TR/REC-html40");

            RenderDocumentProperties();
            RenderStyles();
            RenderWorksheet();

            _writer.WriteEndElement();
            _writer.Flush();
            streamWriter.Flush();
            stream.Position = 0;
            return(stream);
        }
Пример #2
0
        //// ReSharper restore InconsistentNaming

        public Stream GetExcel(BaseJournalUserControl <TDataContext, TFilterControl, TKey, TTable, TDataSource, TRow, TJournal, TNavigatorControl, TNavigatorValues, TFilter> journalControl, RvsSavedProperties properties)
        {
            if (HttpContext.Current != null)
            {
                foreach (var key in HttpContext.Current.Items.Keys.OfType <string>().ToList().Where(r => r.EndsWith(".FiltersCache")))
                {
                    HttpContext.Current.Items.Remove(key);
                }
            }

            var page = new Page();

            _journalControl = journalControl;
            _journalControl.StorageValues = properties.StorageValues;
            _journalControl.InitializeControls(properties);
            page.TemplateControl.Controls.Add(_journalControl);
            return(GetExcel());
        }