(VB.NET - 2008) I create a report add a header/footer and then when I try and export a grid I can't get it to fit nicely on the page - either too small or will run over to the next page. Also if the grid has a couple of more columns it throws off the formatting.
I generate anywhere from 1 to 10 grids in the PDF
The grid has 16 columns and 33 rows (including header and summary row)
How can I have it take up the width of the page and maximize the space between the header and footer so the grid is readable and doesn't overlap into another page?
Dim report As Infragistics.Documents.Report.Report = New Report()
Dim
section1 As Infragistics.Documents.Report.Section.ISection = report.AddSection()
Dim sectionHeader As Infragistics.Documents.Report.Section.ISectionHeader = section1.AddHeader()
sectionHeader.Repeat = True
sectionHeader.Height = 20
'Header Text
Dim sectionHeaderText As Infragistics.Documents.Report.Text.IText = sectionHeader.AddText(0, 0)
Dim headerStyle As New Text.Style(New Font("Arial", 12, FontStyle.Bold), Brushes.Maroon)
sectionHeaderText.Style = headerStyle
sectionHeaderText.Paddings.All = 0
sectionHeaderText.Alignment =
New TextAlignment(Alignment.Center, Alignment.Top)
sectionHeaderText.Background =
New Background(Brushes.LightGray)
sectionHeaderText.AddContent("Header 1 info")
sectionHeaderText.AddLineBreak()
sectionHeaderText.AddContent(
'SET UP THE FOOTER
Dim sectionFooter As Infragistics.Documents.Report.Section.ISectionFooter = section1.AddFooter()
sectionFooter.Repeat =
True
sectionFooter.Height = 40
'Footer Text/Image
Dim sectionFooterText As Infragistics.Documents.Report.Text.IText = sectionFooter.AddText(0, 0)
Dim img As New Image(My.Resources.VanguardShipIcon)
Dim s As New Size(80, 40)
sectionFooterText.AddContent(img, s, ImageAlignment.Right)
"Header 2 info")
'Add some line breaks between header and the grid
text = section1.AddText()
text.AddLineBreak()
Me.UltraGridDocumentExporterDetailGrid.TargetPaperSize = Infragistics.Documents.Report.PageSizes.Legal
Me.UltraGridDocumentExporterDetailGrid.AutoSize = DocumentExport.AutoSize.None
Me.UltraGridDocumentExporterDetailGrid.TargetPaperOrientation = PageOrientation.Landscape
Me.UltraGridDocumentExporterDetailGrid.Export(Me.ugPortfolioReport, section1)
Hello,
Have you been able to take a look at the mentioned sample ?
If you still have any questions or concerns please do not hesitate to ask.
Hi,
I found the sample and followd the pattern, but create a PDF with header/title and grids is very fragile. I had to tweak all kinds of things from grid columns to PDF page parms to Report parms to get it to work.
It was not as easy as I would have like:
Create a header for every page - the header text would change for each page.
Create a footer with the company logo on every page
Create page number on every page
Export a grid and have it fit nicely on the page - the number of columns would vary in the grid as well as the data values
Problems:
1. I could not get the header or footer to be at the very top and bottom of the page (there was always about a 1 inch magin at the top and bottom of the page)
2. Page numbers worked
3. Fitting an image into a footer - guess and hope until you get it right.
4. The grid was a whole story in itself -
The page size would change in the PDF depending on the grid columns
The grid would only take up 1/2 the page (sometimes) - meaning that the header would come out, A text tile and then the grid, then bunch of white space, then the footer. The grid would not fill in the white space to the footer.
The grid would sometimes run into the next page (I have 30 rows + 1 summary rows and either 10, 13 or 16 columns of mostly formatted numbers) and for some data if would have 27 grid rows on one page and the last 4 on the next.
4. Summary: I am scared to touch anything now since it works - but I had to create a different header for the Grid pages, remove the footer on the grid pages, set the page size to legal/landscape, play around with other properties, Try all different thing with the Initialize_Layout of the grid (performAutoSize...) and also BeginExport event do a bunch of things.
FEATURE REQUEST: Create a design-time Report Designer UI where you can put the Wingrid on it (Like Crystal or Visual Studio Report)
If you want to remove the Margins than you should handle the PageMargin property of the desired section like:
section.PageMargins.Top = 0 section.PageMargins.Left = 0
This should help you to achieve what you are looking for.
About the Image in the footer you probably should handle the Images something like the following:
Dim section As ISection = report.AddSection()
Dim footer As ISectionFooter = section.AddFooter() footer.AddImage(....)
In the AddImage method there are two overloads which might help you to position your Image.
I am not sure how the report will handle the rows of the grid when their are "less" than the available space between the header and the footer but I will research it further and will let you know.
Please let me know if you have any other questions.
e.Layout.Override.MinRowHeight = 5
For Each row As UltraGridRow In e.Layout.Rows row.Height = 10 Next
do you have the similar thing for ultrawebgridview ???
Since there is no e.layout.override.manual in for net.advantage asp.net
Hello Gerry,
Please do not hesitate to contact us if you have any other questions.
Thanks Danko,
I will give it a try.
I am not sure that you could "autofit" the rows into the section.
One thing that you could try is to resize the rows in order to try to achieve what you are looking for.
In the BeginExport event you are able to access the copy of the real layout through the event arguments like e.Layout and try to modify the rows height. You could try to suggestion below :
Please let me know if you have any other question on this matter.
Thanks Danko - that worked.
My next problem is that the grid doesn't export to one page anymore since I made the column header a little higher (I added another line of text to some column headers so its height is bigger). It nows outputs to the PDF 32 rows on one page and 2 rows on the next.
How can I get the grid to fit within the secion on 1 page.
Thanks, Gerry