Hi,
I have webgrid that I populate with a csla data source and export to pdf using UltraWebGridDocumentExporter. I try to add a title to the pdf through the BeginExport event of the UltraWebGridDocumentExporter. This event doesnlt seem to be firing. following is the code. Not sure what I am missing:
The End Export event fires but doesnlt seem to add the title as well
BtnRunReport_Click
{
UltraWebGridDocumentExporter1.ExportMode = Infragistics.WebUI.UltraWebGrid.Exporter.ExportMode.InBrowser;
UltraWebGridDocumentExporter1.Export(this.uwgReportGrid);
}
e.Report.Info.Title = "Best Scores";
I alterbatively tried this code in the BeginExport event:
Infragistics.Documents.Report.Text.IText _Title = _Header.AddText(0, 0);
_Title.Caption = "Best Scores";
Thanks,
Himgauri
Hi Richard,
I have now managed to get the Header & Footer added to the pages containing the grid. The example code I was using was implemening a band to the section, and when I took this out and simply added the Header and Footer to the section it worked as required.
Did you manage to get this to work, as I have been trying to accomplish much the same, in that I need a Header & Footer on the pages containing the grid.
So far I have managed to add a cover sheet, I have attempted to create the Header & Footer in an Isection of a report then passed that section to the Document Exporter, however the grid still does not show the header & footer, though the cover page is present. I can only assume that when the grid is passed to the ISection that a new Isection is created containing the grid which overwrites the one given to it?
Himgauri,
You ran into the same problems I did. Basically, you submitted the grid via the .Export method with no parameters. That sent the grid to whatever Infragistics black hole initiates the print stream. Then you created a new section in the _BeginExport event which basically made a new report section which followed the section containing the grid. Not exactly what you were looking for. There are good examples, but it takes some searching.
Here is the basic skinny.
Obviously this cannot be accomplished after you are printing the grid in the default section (ie. the first one)
While many are whining about this tool I am starting to think it is more powerful than even the authors know. For example, you can use the AddContent and AddText methods to create put-it-here form reports. I don't know how to get the results printing yet - but it should not be too hard. I just saw a Publish method. So while Infragistics intended this tool to be used for printing grids, me thinks I can do any type of printing with it. Also, the section and grid management provides me a means of printing multiple grids. And, the thang is fast... I am thinking of dumping Crystal Reports if the ideas in this paragraph bear fruit. And, no, I don't work for Infragistics.
Really bad code follows - but it illustrates the point and the fact that I am still rather ignorant in the use of this tool:
System.Security.Principal.WindowsPrincipal p = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal;
// Create a new report Report report = new Report();report.Info.Title = this.txtGridHdr.Text;report.Info.Author = p.Identity.Name.ToString();report.Info.Subject = "Confidential Report printed by " + p.Identity.Name.ToString();
//Add a Header to the reportInfragistics.Documents.Report.Section.ISection gridSection = report.AddSection();Infragistics.Documents.Report.Section.ISectionHeader header = gridSection.AddHeader();header.Height = 80;ReportText.IText rptHeader = header.AddText(0, 0);ReportText.Style headingStyle = new ReportText.Style(new Font("Tahoma", 16), Brushes.Crimson);rptHeader.AddContent("Client Counseling System (CCS)", headingStyle);rptHeader.AddLineBreak();ReportText.Style headingRptNameStyle = new ReportText.Style(new Font("Tahoma", 14), Brushes.Crimson);rptHeader.AddContent(this.txtGridHdr.Text + " Roster (" + wg.Rows.Count.ToString() + " Personnel)", headingRptNameStyle);rptHeader.AddLineBreak();ReportText.Style captionStyle = new ReportText.Style(new Font("Tahoma", 10), Brushes.Black);rptHeader.AddContent("Security Status: Confidential", captionStyle);rptHeader.AddLineBreak();rptHeader.AddContent("Printed By: " + p.Identity.Name.ToString(), captionStyle);rptHeader.AddLineBreak();rptHeader.AddContent("Print Date: " + System.DateTime.Now.ToString(), captionStyle);rptHeader.AddLineBreak();
//Size the grid columns and print the gridToolBox.WebGrid.SetColumnWidthsByPercentage(wg);RightContent_DocumentExporter.Export(wg, gridSection);