예제 #1
0
        } // CswMainMenu_DataBinding()

        private void _addExportMenuItem(CswNbtView View, ExportOutputFormat Format, CswEnumNbtViewRenderingMode RenderingMode)
        {
            RadMenuItem ExportAsItem = new RadMenuItem();

            ExportAsItem.Text     = Format.ToString();
            ExportAsItem.Value    = "export_" + Format.ToString().ToLower();
            ExportAsItem.CssClass = SubMenuGroupCssClass;
            ExportAsItem.Attributes.Add("onclick", "openExportPopup('sessionviewid=" + _View.SessionViewId + "&format=" + Format.ToString().ToLower() + "&renderingmode=" + RenderingMode.ToString() + "');");
            ExportMenuItem.Items.Add(ExportAsItem);
        }
예제 #2
0
        protected void ExportButton_Click(object sender, EventArgs e)
        {
            StringWriter   sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);

            if (ExportDataSource != null)
            {
                this.AllowPaging = false;
                this.DataSource  = ExportDataSource;
                this.DataBind();
            }

            this.RenderBeginTag(hw);
            this.HeaderRow.RenderControl(hw);
            foreach (GridViewRow row in this.Rows)
            {
                row.RenderControl(hw);
            }
            this.FooterRow.RenderControl(hw);
            this.RenderEndTag(hw);

            string heading = string.IsNullOrEmpty(ExportFileHeading) ? string.Empty : ExportFileHeading;

            string pageSource = "<html><head></head><body>" + heading + sw.ToString() + "</body></html>";

            // Check for license and apply if exists
            if (File.Exists(LicenseFilePath))
            {
                License license = new License();
                license.SetLicense(LicenseFilePath);
            }

            MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(pageSource));
            Document     doc    = new Document(stream);

            WordOutputFormat format;

            if (Enum.TryParse <WordOutputFormat>(ExportOutputFormat.ToString(), out format))
            {
                string extension = ExportOutputFormat.ToString().ToLower();

                if (string.IsNullOrEmpty(extension))
                {
                    extension = "doc";
                }
                string fileName = System.Guid.NewGuid() + "." + extension;

                if (!string.IsNullOrEmpty(ExportOutputPathOnServer) && Directory.Exists(ExportOutputPathOnServer))
                {
                    try
                    {
                        doc.Save(ExportOutputPathOnServer + "\\" + fileName);
                    }
                    catch (Exception) { }
                }

                if (ExportInLandscape)
                {
                    foreach (Section section in doc)
                    {
                        section.PageSetup.Orientation = Orientation.Landscape;
                    }
                }

                doc.Save(HttpContext.Current.Response, fileName, ContentDisposition.Inline, null);
                HttpContext.Current.Response.End();
            }
            else
            {
                HttpContext.Current.Response.Write("Invalid export format, must be one of Doc, Dot, Docx, Docm, Dotx, Dotm, Rtf, Odt, Ott, Txt");
            }
        }
예제 #3
0
        protected void ExportButton_Click(object sender, EventArgs e)
        {
            StringWriter   sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);

            DataPager objDataPager = FindControl <DataPager>(this.Controls);

            if (ExportDataSource != null)
            {
                if (objDataPager != null)
                {
                    if (ExportMaximumRecords == 0)
                    {
                        ExportMaximumRecords = 65000;
                    }
                    objDataPager.Visible  = false;
                    objDataPager.PageSize = ExportMaximumRecords;
                    objDataPager.SetPageProperties(0, ExportMaximumRecords, false);
                    this.DataBind();
                }
            }
            else
            {
                if (objDataPager != null)
                {
                    objDataPager.Visible = false;
                }
            }

            this.Render(hw);

            string heading = string.IsNullOrEmpty(ExportFileHeading) ? string.Empty : ExportFileHeading;

            string pageSource = "<html><head></head><body>" + heading + sw.ToString() + "</body></html>";

            // Check for license and apply if exists
            if (File.Exists(LicenseFilePath))
            {
                License license = new License();
                license.SetLicense(LicenseFilePath);
            }

            MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(pageSource));
            Document     doc    = new Document(stream);

            string extension = ExportOutputFormat.ToString().ToLower();

            if (string.IsNullOrEmpty(extension))
            {
                extension = "doc";
            }
            string fileName = System.Guid.NewGuid() + "." + extension;

            if (!string.IsNullOrEmpty(ExportOutputPathOnServer) && Directory.Exists(ExportOutputPathOnServer))
            {
                try
                {
                    doc.Save(ExportOutputPathOnServer + "\\" + fileName);
                }
                catch (Exception) { }
            }

            if (ExportInLandscape)
            {
                foreach (Section section in doc)
                {
                    section.PageSetup.Orientation = Orientation.Landscape;
                }
            }

            doc.Save(HttpContext.Current.Response, fileName, ContentDisposition.Inline, null);
            HttpContext.Current.Response.End();
        }
        protected void ExportButton_Click(object sender, EventArgs e)
        {
            StringWriter   sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);

            hw.RenderBeginTag("table");

            try
            {
                Control HeaderTemplate = this.Controls[0].Controls[0];
                HeaderTemplate.RenderControl(hw);
            }
            catch (Exception)
            { }

            foreach (RepeaterItem rItem in this.Items)
            {
                rItem.RenderControl(hw);
            }
            hw.RenderEndTag();

            string heading = string.IsNullOrEmpty(ExportFileHeading) ? string.Empty : ExportFileHeading;

            string pageSource = "<html><head></head><body>" + heading + sw.ToString() + "</body></html>";

            // Check for license and apply if exists
            if (File.Exists(LicenseFilePath))
            {
                License license = new License();
                license.SetLicense(LicenseFilePath);
            }

            MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(pageSource));
            Document     doc    = new Document(stream);

            string extension = ExportOutputFormat.ToString().ToLower();

            if (string.IsNullOrEmpty(extension))
            {
                extension = "doc";
            }
            string fileName = System.Guid.NewGuid() + "." + extension;

            if (!string.IsNullOrEmpty(ExportOutputPathOnServer) && Directory.Exists(ExportOutputPathOnServer))
            {
                try
                {
                    doc.Save(ExportOutputPathOnServer + "\\" + fileName);
                }
                catch (Exception) { }
            }

            if (ExportInLandscape)
            {
                foreach (Section section in doc)
                {
                    section.PageSetup.Orientation = Orientation.Landscape;
                }
            }

            doc.Save(HttpContext.Current.Response, fileName, ContentDisposition.Inline, null);
            HttpContext.Current.Response.End();
        }