protected void lnkLeftPanelSectionExport_Click(object sender, EventArgs e) { // Get the full path of the current session's report definition file. string fileName = HttpContext.Current.Session["ReportDefinition"].ToString(); // Create a new report definition by the file. ReportDefinition reportDefinition = new ReportDefinition( Global.Core, fileName, Global.HierarchyFilters[fileName] ); DisplayType displayType = reportDefinition.Settings.DisplayType; reportDefinition.Settings.DisplayType = DisplayType.Crosstable; reportDefinition.Save(); Crosstables.Classes.Crosstable crosstable = new Crosstables.Classes.Crosstable( Global.Core, fileName ); crosstable.IsExport = true; //crosstable.AsynchRender = true; crosstable.Render(); ColorSchemeStylesheet colorScheme = new ColorSchemeStylesheet(); colorScheme.Render(); StringBuilder style = new StringBuilder(); style.Append("<style type=\"text/css\">"); style.Append(colorScheme.InnerHtml.Split(new string[] { "##### Scroll bar styles #####" }, StringSplitOptions.None)[0]); style.Append(File.ReadAllText(Path.Combine( Request.PhysicalApplicationPath, "Stylesheets", "Modules", "Crosstables.css" ))); style.Append("</style>"); Crosstables.Classes.Exporter exporter = new Crosstables.Classes.Exporter( crosstable.Table, style.ToString(), reportDefinition ); reportDefinition.Settings.DisplayType = displayType; reportDefinition.Save(); string fName = exporter.Export(); base.WriteFileToResponse(fName, "Export.xlsx", "application/msexcel", true); }
public override void Render(StringBuilder writer) { if (this.Node.XmlNode.Attributes["Source"] == null || File.Exists(this.Node.XmlNode.Attributes["Source"].Value) == false) { RenderNoChartMessage(writer); return; } try { Crosstables.Classes.Crosstable crosstable = new Crosstables.Classes.Crosstable( this.Node.Owner.Core, this.Node.XmlNode.Attributes["Source"].Value ); DisplayType displayType = crosstable.ReportDefinition.Settings.DisplayType; if (displayType == DisplayType.Crosstable) { crosstable.ReportDefinition.Settings.DisplayType = DisplayType.Pie; } if (this.Node.XmlNode.Attributes["DisplayType"] != null) { crosstable.ReportDefinition.Settings.DisplayType = (DisplayType)Enum.Parse( typeof(DisplayType), this.Node.XmlNode.Attributes["DisplayType"].Value ); } crosstable.Render(); crosstable.Style.Add("HeightScript", this.Node.Height); writer.Append(crosstable.ToHtml()); crosstable.ReportDefinition.Settings.DisplayType = displayType; crosstable.ReportDefinition.Save(); } catch (Exception ex) { RenderNoChartMessage(writer); } }