Hi all,in my UltraGrid I have an ultraGridDocumentExporter to export the Grid content in a PDF file. Is it possible to export in a predefinited pdf template (that has, for example, header and footer).
Thanks a lot.
Luigi
Hi Luigi,
Not sure what you mean by predefined. But you can create a report object and add a header to it or anything you want, then export the grid into it, then write a footer or some more text after the grid.
The sample for the DocumentExporter in the WinGrid samples explorer does this.
You mean this code Mike?
// Header Infragistics.Documents.Report.Grid.IGridHeader header = grid.Header; header.Height = new Infragistics.Documents.Report.FixedHeight(35); header.Repeat = true;
Infragistics.Documents.Report.Grid.IGridCell cell = header.AddCell(); cell.ColSpan = 5; cell.Alignment.Vertical = Infragistics.Documents.Report.Alignment.Middle; cell.Borders = new Infragistics.Documents.Report.Borders(Infragistics.Documents.Graphics.Pens.Black); cell.Background = new Infragistics.Documents.Report.Background(new Infragistics.Documents.Graphics.Color(220, 240, 240));
text = cell.AddText(); text.Style = normalStyle; text.Alignment = Infragistics.Documents.Report.TextAlignment.Center; text.AddContent("Grid Header");
// Footer Infragistics.Documents.Report.Grid.IGridFooter footer = grid.Footer; footer.Height = new Infragistics.Documents.Report.FixedHeight(35); footer.Repeat = true;
cell = footer.AddCell(); cell.ColSpan = 5; cell.Alignment.Vertical = Infragistics.Documents.Report.Alignment.Middle; cell.Borders = new Infragistics.Documents.Report.Borders(Infragistics.Documents.Graphics.Pens.Black); cell.Background = new Infragistics.Documents.Report.Background(new Infragistics.Documents.Graphics.Color(220, 220, 240));
text = cell.AddText(); text.Style = normalStyle; text.Alignment = Infragistics.Documents.Report.TextAlignment.Center; text.AddContent("Grid Footer");
Thank you.
I have done.
What you need to do is add a Header to the section and then set Repeat to true:
ISectionHeader header = section.AddHeader();header.Repeat = true;
I have tested the above. But its only appear in the first page. I need this on all the page. Please help me on this.
You don't need to declare a section variable. You want your text to be included in the same section the grid is being exporting into. So just use "e.Section".
I have put an
public ISection section;
declaration at the beginning of my class (after public partial class Form1 : Form.....)
and then modify the BeginExport like so:
private void ultraGridDocumentExporter1_BeginExport(object sender, BeginExportEventArgs e){ IText text = section.AddText(); text.AddContent("My UltraGrid Header"); foreach (UltraGridBand band in e.Layout.Bands) { switch (band.Index) { case 1: band.Hidden = true; break; default: band.Indentation = 0; break; } }}
In this moment I can't test it (I'm out of office, with not database).
Is it sufficent?