Hello all,
I have 2 charts on a pdf page. They appear one after the other.
I would like them to appear side by side on the page?
Not seeing a way to do this. Any help would be appreciated.
Thanks
Deasun
{vb.net :) }
Hello Deasun,
You can place charts side by side within a PDF document by positioning canvases within the PDF page, then rendering each chart to a canvas. This technique is explained in this walkthrough. I have attached a sample of the final product of the walkthrough if you'd like to see the code in action. Let me know if you have any questions.
Thanks,
Chris
thanks very much for the reply.
Question can this be used with sections?
Currently I have; Dim section1 As ISection = report.AddSection()
then I add a Header and Footer section and set the page number section
I export a wingrid to Section 1 using the griddocexporter.
Then for the charts I do;
Dim canvas As ICanvas = section1.AddCanvascanvas.Width = New FixedWidth(2000)canvas.Height = New FixedHeight(500)Dim g As Drawing.Graphics = canvas.CreateGraphics()uwCht_HidChartView.RenderPdfFriendlyGraphics(g)
and the 2nd chart gets:
Dim canvas2 As ICanvas = section1.AddCanvascanvas2.Width = New FixedWidth(2000)canvas2.Height = New FixedHeight(500)Dim g2 As Drawing.Graphics = canvas2.CreateGraphics()uwCht_HidChartView.RenderPdfFriendlyGraphics(g2)
Guess how does that page object work with the sections?
I may have come at this from wrong direction and missed something.
There is no built in way to tell the exported grid to autosize to fill the width of the page. From reading some other posts on this subject, it seems the best solution is increase the width of each (or just the last) column to reach the desired page width.
Try something like the following:
Private Sub UltraGridDocumentExporter1_ExportStarted(sender As Object, e As Infragistics.Win.UltraWinGrid.DocumentExport.ExportStartedEventArgs) Handles UltraGridDocumentExporter1.ExportStarted ' Determine the difference between the pageSize and the size of the grid. Dim widthDifference As Integer = e.Section.PageSize.Width - e.Layout.Bands(0).GetExtent() If widthDifference > 0 Then Dim columnWidthIncrease As Integer = widthDifference / e.Layout.Bands(0).Columns.Count For Each column As UltraGridColumn In e.Layout.Bands(0).Columns column.Width = column.Width + columnWidthIncrease Next End If End Sub
' Determine the difference between the pageSize and the size of the grid. Dim widthDifference As Integer = e.Section.PageSize.Width - e.Layout.Bands(0).GetExtent()
If widthDifference > 0 Then Dim columnWidthIncrease As Integer = widthDifference / e.Layout.Bands(0).Columns.Count For Each column As UltraGridColumn In e.Layout.Bands(0).Columns column.Width = column.Width + columnWidthIncrease Next End If End Sub
Make sure to set the PageSize on the section prior to each export. Hopefully this helps.
Me again.
My boss, John Carling, is now talking to Alan at infragistics on this issue.
We are sending over a zip file of a test project that is doing the same issue.
they asked me to make this post to keep u in the loop.
Code below:
#Region " Area: Imports "Imports System.IOImports Infragistics.Documents.Reports.Report.SectionImports Infragistics.Documents.ReportsImports System.Drawing.PrintingImports Infragistics.Documents.Reports.ReportImports Infragistics.Documents.Reports.Report.Flow#End Region
Public Class Form1
Dim mds As New DataSet Dim mdvLineCount As New Data.DataView Dim mdvLCs_Chart1 As New Data.DataView Dim mdvLCs_Chart2 As New Data.DataView
Dim mdvTotCharges As New Data.DataView Dim mdvTCs_Chart1 As New Data.DataView Dim mdvTCs_Chart2 As New Data.DataView
Dim mdvSummary As New Data.DataView Dim mdvSum_Chart1 As New Data.DataView Dim mdvSum_Chart2 As New Data.DataView Dim mdvSum_Chart3 As New Data.DataView
Private Sub btnDoIT_Click(sender As Object, e As EventArgs) Handles btnDoIT.Click Dim strDefaultSaveAsPath As String = "C:\" Dim strFileName As String = "" Dim strSaveFileAs As String = "" Dim strDataTitle As String = "" Try 'Step 1] Create the dummy dataviews do_CreateDVs("btnDoIT_Click")
'Step 2] Create the PDF doc 'File Name strDataTitle = "Games Monthly-Summary" strFileName = "Rpt_" & strDataTitle & "_RunBy_THRUD.pdf" strFileName = strFileName.Replace(" ", "_") If (strDataTitle.Length > 31) Then strDataTitle = strDataTitle.Substring(0, 31) End If Try If (File.Exists(strDefaultSaveAsPath & strFileName) = True) Then File.Delete(strDefaultSaveAsPath & strFileName) End If Catch ex As Exception strFileName = "Rpt_" & strDataTitle & "_RunBy_THRUD_dupe.pdf" End Try strSaveFileAs = strDefaultSaveAsPath & strFileName
' Create a report Dim objReport As New Infragistics.Documents.Reports.Report.Report() objReport.Preferences.Printing.FitToMargins = True Dim objRptSection As ISection = objReport.AddSection() objRptSection.PageSize = New PageSize(800, 800) objRptSection.PageOrientation = PageOrientation.Portrait
Dim uwCht_HidChartView As New Infragistics.Win.UltraWinChart.UltraChart Dim uwGrid_HiddenObj As New Infragistics.Win.UltraWinGrid.UltraGrid Dim uwGridDocExporter As New Infragistics.Win.UltraWinGrid.DocumentExport.UltraGridDocumentExporter
objRptSection = SetRptSection(objRptSection, "Game Count", "btnDoIT_Click") 'Game Counts - page1 If (mdvLineCount.Count > 0) Then 'Grid With uwGrid_HiddenObj .BindingContext = New BindingContext .DataSource = Nothing .DataSource = mdvLineCount .SetDataBinding(mdvLineCount, "") .DisplayLayout.Appearance.FontData.SizeInPoints = 12 .DisplayLayout.Bands(0).Override.HeaderAppearance.BackColor = Color.Khaki .DisplayLayout.Bands(0).Columns("ID").Hidden = True .DisplayLayout.Bands(0).Columns(1).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right .DisplayLayout.Bands(0).Columns(2).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Center .DisplayLayout.Bands(0).Columns(3).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right .DisplayLayout.Bands(0).Columns(4).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right .DisplayLayout.Bands(0).Columns(5).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right .DisplayLayout.Bands(0).Columns(6).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right End With 'Putting Grid on page With uwGridDocExporter .Export(uwGrid_HiddenObj, objRptSection) End With Dim chartWidth As Integer = ((objRptSection.PageSize.Width - (objRptSection.PageMargins.Left + objRptSection.PageMargins.Right) - 5) / 2) Dim chartHeight As Integer = (objRptSection.PageSize.Height * 0.65) - (uwGrid_HiddenObj.Height + 25) Dim flow As IFlow = objRptSection.AddFlow() flow.Alignment.Horizontal = Alignment.Center 'Chart 1 With uwCht_HidChartView .DataSource = Nothing .ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.LineChart .Legend.Location = Infragistics.UltraChart.Shared.Styles.LegendLocation.Bottom .Legend.Visible = True .TitleBottom.Visible = False .TitleTop.Text = "Game Counts " .TitleTop.HorizontalAlign = StringAlignment.Center .Tooltips.FormatString = "<DATA_VALUE:0>"
.Axis.X.Labels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.Horizontal .Axis.X.Labels.ItemFormatString = "<ITEM_LABEL>" .Axis.Y.Labels.ItemFormatString = "<DATA_VALUE:0>"
.Axis.Y.TickmarkStyle = Infragistics.UltraChart.Shared.Styles.AxisTickStyle.Smart .ColorModel.ModelStyle = Infragistics.UltraChart.Shared.Styles.ColorModels.PureRandom .ColorModel.Scaling = Infragistics.UltraChart.Shared.Styles.ColorScaling.Random
Dim cta As New Infragistics.UltraChart.Resources.Appearance.ChartTextAppearance cta.ItemFormatString = "<DATA_VALUE:0>" .LineChart.ChartText.Add(cta)
.Border.Thickness = 0
.DataSource = mdvLCs_Chart1 .DataBind() End With 'Putting chart1 on page Dim canvas As ICanvas = flow.AddCanvas canvas.Paddings.All = 5 canvas.Width = New FixedWidth(chartWidth) canvas.Height = New FixedHeight(chartHeight) Dim g As Drawing.Graphics = canvas.CreateGraphics() uwCht_HidChartView.Width = chartWidth uwCht_HidChartView.Height = chartHeight uwCht_HidChartView.RenderPdfFriendlyGraphics(g) 'Putting chart2 on page With uwCht_HidChartView .DataSource = Nothing .TitleTop.Text = "Game Counts: X-Wwing" .DataSource = mdvLCs_Chart2 .DataBind() End With canvas = flow.AddCanvas canvas.Paddings.All = 5 canvas.Width = New FixedWidth(chartWidth) canvas.Height = New FixedHeight(chartHeight) g = canvas.CreateGraphics() uwCht_HidChartView.Width = chartWidth uwCht_HidChartView.Height = chartHeight uwCht_HidChartView.RenderPdfFriendlyGraphics(g)
End If
'Total Charges - page2 Dim section2 As ISection = objReport.AddSection() section2.PageOrientation = PageOrientation.Portrait Dim strSectionType2 As String = "Total Current Charges" section2 = SetRptSection(section2, (strSectionType2), "btnDoIT_Click") If (mdvTotCharges.Count > 0) Then objRptSection = SetRptSection(objRptSection, "Total Current Charges", "btnDoIT_Click") With uwGrid_HiddenObj .BindingContext = New BindingContext .DataSource = Nothing .DataSource = mdvTotCharges .SetDataBinding(mdvTotCharges, "") .DisplayLayout.Appearance.FontData.SizeInPoints = 12 .DisplayLayout.Bands(0).Override.HeaderAppearance.BackColor = Color.Khaki .DisplayLayout.Bands(0).Columns("ID").Hidden = True .DisplayLayout.Bands(0).Columns(1).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right .DisplayLayout.Bands(0).Columns(2).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Center .DisplayLayout.Bands(0).Columns(3).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right .DisplayLayout.Bands(0).Columns(4).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right .DisplayLayout.Bands(0).Columns(5).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right .DisplayLayout.Bands(0).Columns(6).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right End With With uwGridDocExporter .Export(uwGrid_HiddenObj, section2) End With
Dim chartWidth As Integer = ((objRptSection.PageSize.Width - (objRptSection.PageMargins.Left + objRptSection.PageMargins.Right) - 5) / 2) Dim chartHeight As Integer = (objRptSection.PageSize.Height * 0.65) - (uwGrid_HiddenObj.Height + 25) Dim flow As IFlow = section2.AddFlow() flow.Alignment.Horizontal = Alignment.Center With uwCht_HidChartView .DataSource = Nothing .ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.LineChart .Legend.Location = Infragistics.UltraChart.Shared.Styles.LegendLocation.Bottom .Legend.Visible = True .TitleBottom.Visible = False .TitleTop.Text = "Total Current Charges " .TitleTop.HorizontalAlign = StringAlignment.Center .Tooltips.FormatString = "<DATA_VALUE:0.00>"
.Axis.X.Labels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.Horizontal .Axis.X.Labels.ItemFormatString = "<ITEM_LABEL>" .Axis.Y.Labels.ItemFormatString = "<DATA_VALUE:0.00>"
'Should put label formatted on chart data points Dim cta As New Infragistics.UltraChart.Resources.Appearance.ChartTextAppearance cta.ItemFormatString = "<DATA_VALUE:0.00>" .LineChart.ChartText.Add(cta)
.DataSource = mdvTCs_Chart1 .DataBind() End With 'chart1 Dim canvas As ICanvas = flow.AddCanvas canvas.Paddings.All = 5 canvas.Width = New FixedWidth(chartWidth) canvas.Height = New FixedHeight(chartHeight) Dim g As Drawing.Graphics = canvas.CreateGraphics() uwCht_HidChartView.Width = chartWidth uwCht_HidChartView.Height = chartHeight uwCht_HidChartView.RenderPdfFriendlyGraphics(g) 'chart 2 With uwCht_HidChartView .DataSource = Nothing .TitleTop.Text = "Total Current Charges: X-Wing" .DataSource = mdvTCs_Chart2 .DataBind() End With canvas = flow.AddCanvas canvas.Paddings.All = 5 canvas.Width = New FixedWidth(chartWidth) canvas.Height = New FixedHeight(chartHeight) g = canvas.CreateGraphics() uwCht_HidChartView.Width = chartWidth uwCht_HidChartView.Height = chartHeight uwCht_HidChartView.RenderPdfFriendlyGraphics(g)
'Summary - page3 Dim section1 As ISection = objReport.AddSection() section1.PageOrientation = PageOrientation.Portrait Dim strSectionType As String = "Game Summary" section1 = SetRptSection(section1, ("GW " & strSectionType), "btnDoIT_Click") If (mdvSummary.Count > 0) Then With uwGrid_HiddenObj .BindingContext = New BindingContext .DataSource = Nothing .DataSource = mdvSummary .SetDataBinding(mdvSummary, "") .DisplayLayout.Appearance.FontData.SizeInPoints = 12 .DisplayLayout.Bands(0).PerformAutoResizeColumns(False, Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand) .DisplayLayout.Bands(0).Override.HeaderAppearance.BackColor = Color.Khaki
.DisplayLayout.Bands(0).Columns(0).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right .DisplayLayout.Bands(0).Columns(0).Format = "C" .DisplayLayout.Bands(0).Columns(1).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right .DisplayLayout.Bands(0).Columns(1).Format = "C" .DisplayLayout.Bands(0).Columns(2).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right .DisplayLayout.Bands(0).Columns(2).Format = "C" .DisplayLayout.Bands(0).Columns(3).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right .DisplayLayout.Bands(0).Columns(3).Format = "C" .DisplayLayout.Bands(0).Columns(4).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right .DisplayLayout.Bands(0).Columns(4).Format = "C" .DisplayLayout.Bands(0).Columns(5).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right .DisplayLayout.Bands(0).Columns(5).Format = "C" .DisplayLayout.Bands(0).Columns(6).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right .DisplayLayout.Bands(0).Columns(6).Format = "C" .DisplayLayout.Bands(0).Columns(7).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right .DisplayLayout.Bands(0).Columns(7).Format = "C" .DisplayLayout.Bands(0).Columns(8).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Center .DisplayLayout.Bands(0).Columns(9).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right .DisplayLayout.Bands(0).Columns(9).Format = "C" .DisplayLayout.Bands(0).Columns(10).CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right .DisplayLayout.Bands(0).Columns(10).Format = "C" End With With uwGridDocExporter .Export(uwGrid_HiddenObj, section1) End With Dim flow1 As IFlow = section1.AddFlow() Dim chartWidth = ((section1.PageSize.Width - (section1.PageMargins.Left + section1.PageMargins.Right + 25)) / 3) Dim chartHeight As Integer = (chartWidth * 1.25) - (uwGrid_HiddenObj.Height + 25) With uwCht_HidChartView .Width = chartWidth .Height = chartHeight .DataSource = Nothing .ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.LineChart .Legend.Visible = True .TitleBottom.Visible = False .TitleTop.Text = "Avg Cost! Vendor: GW" .TitleTop.HorizontalAlign = StringAlignment.Center .Tooltips.FormatString = "$<DATA_VALUE:00.00>"
.Axis.X.Labels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.Horizontal .Axis.X.Labels.ItemFormatString = "<ITEM_LABEL>" .Axis.Y.Labels.ItemFormatString = "<DATA_VALUE:$00.00>"
.Axis.Y.TickmarkStyle = Infragistics.UltraChart.Shared.Styles.AxisTickStyle.Smart .ColorModel.ColorBegin = Color.Lime .ColorModel.ColorEnd = Color.Red .ColorModel.ModelStyle = Infragistics.UltraChart.Shared.Styles.ColorModels.LinearRange .ColorModel.Scaling = Infragistics.UltraChart.Shared.Styles.ColorScaling.Increasing
'Should put label formatted on chart data points Dim cta As New Infragistics.UltraChart.Resources.Appearance.ChartTextAppearance cta.ItemFormatString = "<DATA_VALUE:$00.00>" .LineChart.ChartText.Add(cta)
' .ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.PieChart3D .DataSource = mdvSum_Chart1 .DataBind() End With Dim canvas As ICanvas = flow1.AddCanvas canvas.Width = New FixedWidth(chartWidth) canvas.Height = New FixedHeight(chartHeight) Dim g As Drawing.Graphics = canvas.CreateGraphics() uwCht_HidChartView.RenderPdfFriendlyGraphics(g)
With uwCht_HidChartView .DataSource = Nothing .TitleTop.Text = "Game Count! Vendor: GW" .Axis.Y.Labels.ItemFormatString = "<DATA_VALUE:0>" .Tooltips.FormatString = "<DATA_VALUE:0>" .DataSource = mdvSum_Chart2 .DataBind() End With canvas = flow1.AddCanvas canvas.Width = New FixedWidth(chartWidth) canvas.Height = New FixedHeight(chartHeight) g = canvas.CreateGraphics() uwCht_HidChartView.RenderPdfFriendlyGraphics(g)
With uwCht_HidChartView .DataSource = Nothing .TitleTop.Text = "Total Current Charges: GW" .DataSource = mdvSum_Chart3 .DataBind() End With canvas = flow1.AddCanvas canvas.Width = New FixedWidth(chartWidth) canvas.Height = New FixedHeight(chartHeight) g = canvas.CreateGraphics() uwCht_HidChartView.RenderPdfFriendlyGraphics(g)
'Publish PDF objReport.Publish(strSaveFileAs, Infragistics.Documents.Reports.Report.FileFormat.PDF) 'Object clean up objReport = Nothing
'Step 3] Call up doc Dim objExternalCallUp As New System.Diagnostics.Process With objExternalCallUp .Start(strSaveFileAs) .Close() End With
MessageBox.Show("Done I Am!") Catch ex As Exception
End Try End Sub
Private Function SetRptSection(section As ISection, strHeading As String, strWhoCalledMe As String) As ISection Dim strWhoAmI As String = My.Application.Info.Title & ".clsScheduledStuff.SetRptSection" Try Dim sectionHeader As ISectionHeader = section.AddHeader() sectionHeader.Repeat = True sectionHeader.Height = 50
Dim objImage As New Infragistics.Documents.Reports.Graphics.Image(My.Application.Info.DirectoryPath & "\Data Dictionary\Images\PDFCompLogoV2.png") sectionHeader.AddImage(objImage, 0, 0)
Dim sectionHeaderText As Infragistics.Documents.Reports.Report.Text.IText = sectionHeader.AddText(0, 0) sectionHeaderText.Paddings.All = 10 sectionHeaderText.Alignment = New Infragistics.Documents.Reports.Report.TextAlignment(Infragistics.Documents.Reports.Report.Alignment.Center, Infragistics.Documents.Reports.Report.Alignment.Middle) sectionHeaderText.Height = New Infragistics.Documents.Reports.Report.RelativeHeight(100) ' sectionHeaderText.Background = New Infragistics.Documents.Reports.Report.Background(Infragistics.Documents.Reports.Graphics.Brushes.Gainsboro)
Dim objFont As New Infragistics.Documents.Reports.Graphics.Font("Arial", 15) Dim objSecStyle As New Infragistics.Documents.Reports.Report.Text.Style(objFont, Infragistics.Documents.Reports.Graphics.Brushes.White) ' (New Font("Arial", 8), Brushes.White) sectionHeaderText.Style = objSecStyle sectionHeaderText.Style.Font.Bold = True sectionHeaderText.AddContent(strHeading)
Dim sectionFooter As ISectionFooter = section.AddFooter() sectionFooter.Repeat = True sectionFooter.Height = 50 Dim sectionFooterText As Infragistics.Documents.Reports.Report.Text.IText = sectionFooter.AddText(0, 0) sectionFooterText.Paddings.All = 10 sectionFooterText.Alignment = New Infragistics.Documents.Reports.Report.TextAlignment(Infragistics.Documents.Reports.Report.Alignment.Center, Infragistics.Documents.Reports.Report.Alignment.Middle) sectionFooterText.Height = New Infragistics.Documents.Reports.Report.RelativeHeight(100) sectionFooterText.Background = New Infragistics.Documents.Reports.Report.Background(Infragistics.Documents.Reports.Graphics.Brushes.Gainsboro) sectionFooterText.AddContent("Copyright " & Now.Year.ToString & " iManaged Services, Inc. All rights reserved.")
' page numbering Dim pn As PageNumbering = section.PageNumbering pn.Style = New Infragistics.Documents.Reports.Report.Text.Style(Infragistics.Documents.Reports.Graphics.Fonts.Arial, Infragistics.Documents.Reports.Graphics.Brushes.Black) pn.Template = "Page [Page #] of [TotalPages]" pn.SkipFirst = False pn.Alignment.Horizontal = Infragistics.Documents.Reports.Report.Alignment.Right pn.Alignment.Vertical = Infragistics.Documents.Reports.Report.Alignment.Bottom pn.OffsetY = -52 pn.OffsetX = -50
Catch ex As Exception ' msResult = objSpectrotelTools.CreateErrorMSG(msUserName, strWhoAmI, Err.Number.ToString, ex.Message, strWhoAmI, strWhoCalledMe, ex.StackTrace, "", "", msResult, "", "", ("Report On: " & strHeading & Environment.NewLine), My.Application.Info.Title, My.Application.Info.Version.ToString, "", strWhoAmI) End Try SetRptSection = section End Function
#Region "Tables" Private Sub do_CreateDVs(strWhoCalledMe As String) Try 'Page 1: Game Counts do_LineCountsTBL("do_CreateDVs") do_LCs_ChartTBL("do_CreateDVs") do_LC2s_ChartTBL("do_CreateDVs")
'Page 2: Total Charges do_TotChargesTBL("do_CreateDVs") do_TCs_ChartTBL("do_CreateDVs") do_TC2s_ChartTBL("do_CreateDVs")
'Page 2: Summary do_SummTBL("do_CreateDVs") do_Summ_ChartTBL("do_CreateDVs") do_Summ2_ChartTBL("do_CreateDVs") do_Summ3_ChartTBL("do_CreateDVs")
Catch ex As Exception
#Region "Summary"
Private Sub do_SummTBL(strWhoCalledMe As String) Dim dt As DataTable Dim dr As DataRow Try
dt = New DataTable("Summary") 'Columns for table Dim lpcCoulumn As DataColumn Dim mrcCoulumn As DataColumn Dim occCoulumn As DataColumn Dim useCoulumn As DataColumn Dim taxCoulumn As DataColumn Dim scsCoulumn As DataColumn Dim tccCoulumn As DataColumn Dim tadCoulumn As DataColumn Dim lcCoulumn As DataColumn Dim cblCoulumn As DataColumn Dim invblCoulumn As DataColumn
lpcCoulumn = New DataColumn("LPC", Type.GetType("System.Double")) mrcCoulumn = New DataColumn("MRC", Type.GetType("System.Double")) occCoulumn = New DataColumn("OCC", Type.GetType("System.Double")) useCoulumn = New DataColumn("Usage", Type.GetType("System.Double")) taxCoulumn = New DataColumn("Taxes", Type.GetType("System.Double")) scsCoulumn = New DataColumn("SurCharges", Type.GetType("System.Double")) tccCoulumn = New DataColumn("Total Current Charges", Type.GetType("System.Double")) tadCoulumn = New DataColumn("Total Amount Due", Type.GetType("System.Double")) lcCoulumn = New DataColumn("Game Count", Type.GetType("System.Int32")) cblCoulumn = New DataColumn("Avg Cost / Game", Type.GetType("System.Double")) invblCoulumn = New DataColumn("Avg Invoice / Game", Type.GetType("System.Double"))
dt.Columns.Add(lpcCoulumn) dt.Columns.Add(mrcCoulumn) dt.Columns.Add(occCoulumn) dt.Columns.Add(useCoulumn) dt.Columns.Add(taxCoulumn) dt.Columns.Add(scsCoulumn) dt.Columns.Add(tccCoulumn) dt.Columns.Add(tadCoulumn) dt.Columns.Add(lcCoulumn) dt.Columns.Add(cblCoulumn) dt.Columns.Add(invblCoulumn)
dr = dt.NewRow() dr("LPC") = 2586.3 dr("MRC") = 602797.22 dr("OCC") = 64593.08 dr("Usage") = 6257.35 dr("Taxes") = 52.68 dr("SurCharges") = 19.9 dr("Total Current Charges") = 676305.8 dr("Total Amount Due") = 777730.18 dr("Game Count") = 17500 dr("Avg Cost / Game") = 34.8 dr("Avg Invoice / Game") = 34.95
dt.Rows.Add(dr)
mds.Tables.Add(dt) mdvSummary = mds.Tables("Summary").AsDataView Catch ex As Exception
Private Sub do_Summ_ChartTBL(strWhoCalledMe As String) Dim dt As DataTable Dim dr As DataRow Try
dt = New DataTable("Sum_Chart1") 'Columns for table Dim itemCoulumn As DataColumn Dim d1Coulumn As DataColumn Dim d2Coulumn As DataColumn Dim d3Coulumn As DataColumn Dim d4Coulumn As DataColumn Dim d5Coulumn As DataColumn Dim d6Coulumn As DataColumn
itemCoulumn = New DataColumn("Item", Type.GetType("System.String")) d1Coulumn = New DataColumn("[2/2016]", Type.GetType("System.Double")) d2Coulumn = New DataColumn("[3/2016]", Type.GetType("System.Double")) d3Coulumn = New DataColumn("[4/2016]", Type.GetType("System.Double")) d4Coulumn = New DataColumn("[5/2016]", Type.GetType("System.Double")) d5Coulumn = New DataColumn("[6/2016]", Type.GetType("System.Double")) d6Coulumn = New DataColumn("[7/2016]", Type.GetType("System.Double"))
dt.Columns.Add(itemCoulumn) dt.Columns.Add(d1Coulumn) dt.Columns.Add(d2Coulumn) dt.Columns.Add(d3Coulumn) dt.Columns.Add(d4Coulumn) dt.Columns.Add(d5Coulumn) dt.Columns.Add(d6Coulumn)
dr = dt.NewRow() dr("Item") = "Avg Cost / Game" dr("[2/2016]") = 33.4 dr("[3/2016]") = 34.6 dr("[4/2016]") = 33.7 dr("[5/2016]") = 36.5 dr("[6/2016]") = 36.8 dr("[7/2016]") = 40.0 dt.Rows.Add(dr)
dr = dt.NewRow() dr("Item") = "Avg Invoice / Game" dr("[2/2016]") = 31.4 dr("[3/2016]") = 32.6 dr("[4/2016]") = 33.7 dr("[5/2016]") = 32.5 dr("[6/2016]") = 32.8 dr("[7/2016]") = 38.0 dt.Rows.Add(dr)
mds.Tables.Add(dt) mdvSum_Chart1 = mds.Tables("Sum_Chart1").AsDataView Catch ex As Exception
Private Sub do_Summ2_ChartTBL(strWhoCalledMe As String) Dim dt As DataTable Dim dr As DataRow Try
dt = New DataTable("Sum_Chart2") 'Columns for table Dim itemCoulumn As DataColumn Dim d1Coulumn As DataColumn Dim d2Coulumn As DataColumn Dim d3Coulumn As DataColumn Dim d4Coulumn As DataColumn Dim d5Coulumn As DataColumn Dim d6Coulumn As DataColumn
itemCoulumn = New DataColumn("Item", Type.GetType("System.String")) d1Coulumn = New DataColumn("[2/2016]", Type.GetType("System.Int32")) d2Coulumn = New DataColumn("[3/2016]", Type.GetType("System.Int32")) d3Coulumn = New DataColumn("[4/2016]", Type.GetType("System.Int32")) d4Coulumn = New DataColumn("[5/2016]", Type.GetType("System.Int32")) d5Coulumn = New DataColumn("[6/2016]", Type.GetType("System.Int32")) d6Coulumn = New DataColumn("[7/2016]", Type.GetType("System.Int32"))
dr = dt.NewRow() dr("Item") = "Game Count" dr("[2/2016]") = 100 dr("[3/2016]") = 200 dr("[4/2016]") = 175 dr("[5/2016]") = 300 dr("[6/2016]") = 321 dr("[7/2016]") = 330 dt.Rows.Add(dr)
mds.Tables.Add(dt) mdvSum_Chart2 = mds.Tables("Sum_Chart2").AsDataView Catch ex As Exception
Private Sub do_Summ3_ChartTBL(strWhoCalledMe As String) Dim dt As DataTable Dim dr As DataRow Try
dt = New DataTable("Sum_Chart3") 'Columns for table Dim itemCoulumn As DataColumn Dim d1Coulumn As DataColumn Dim d2Coulumn As DataColumn Dim d3Coulumn As DataColumn Dim d4Coulumn As DataColumn Dim d5Coulumn As DataColumn Dim d6Coulumn As DataColumn
dr = dt.NewRow() dr("Item") = "WarHammer" dr("[2/2016]") = 80000.0 dr("[3/2016]") = 11000.0 dr("[4/2016]") = 11600.0 dr("[5/2016]") = 13000.0 dr("[6/2016]") = 12700.0 dr("[7/2016]") = 13500.0 dt.Rows.Add(dr)
dr = dt.NewRow() dr("Item") = "WarHammer 40K" dr("[2/2016]") = 85000.0 dr("[3/2016]") = 11000.0 dr("[4/2016]") = 12400.0 dr("[5/2016]") = 13000.0 dr("[6/2016]") = 11600.0 dr("[7/2016]") = 19500.0 dt.Rows.Add(dr)
dr = dt.NewRow() dr("Item") = "X-Wing" dr("[2/2016]") = 90000.0 dr("[3/2016]") = 15000.0 dr("[4/2016]") = 11600.0 dr("[5/2016]") = 14500.0 dr("[6/2016]") = 16700.0 dr("[7/2016]") = 19500.0 dt.Rows.Add(dr)
mds.Tables.Add(dt) mdvSum_Chart3 = mds.Tables("Sum_Chart3").AsDataView Catch ex As Exception
#End Region
#Region "Total Charges" Private Sub do_TotChargesTBL(strWhoCalledMe As String) Dim dt As DataTable Dim dr As DataRow Try
dt = New DataTable("TotalCharges") 'Columns for table Dim idCoulumn As DataColumn Dim ilecCoulumn As DataColumn Dim platformCoulumn As DataColumn Dim d1Coulumn As DataColumn Dim d2Coulumn As DataColumn Dim d3Coulumn As DataColumn Dim d4Coulumn As DataColumn
idCoulumn = New DataColumn("ID", Type.GetType("System.Int32")) ilecCoulumn = New DataColumn("ILEC", Type.GetType("System.String")) platformCoulumn = New DataColumn("PLATFORM", Type.GetType("System.String")) d1Coulumn = New DataColumn("{7/2016} Tot Charges", Type.GetType("System.Double")) d2Coulumn = New DataColumn("{7/2016} % of Total", Type.GetType("System.Double")) d3Coulumn = New DataColumn("{8/2016} Tot Charges", Type.GetType("System.Double")) d4Coulumn = New DataColumn("{8/2016} % of Total", Type.GetType("System.Double"))
dt.Columns.Add(idCoulumn) dt.Columns.Add(ilecCoulumn) dt.Columns.Add(platformCoulumn) dt.Columns.Add(d1Coulumn) dt.Columns.Add(d2Coulumn) dt.Columns.Add(d3Coulumn) dt.Columns.Add(d4Coulumn)
dr = dt.NewRow() dr("ID") = 1 dr("ILEC") = "WarHammer" dr("PLATFORM") = "Eldar" dr("{7/2016} Tot Charges") = 310324.0 dr("{7/2016} % of Total") = 8.58 dr("{8/2016} Tot Charges") = 319078.0 dr("{8/2016} % of Total") = 9.74 dt.Rows.Add(dr)
dr = dt.NewRow() dr("ID") = 2 dr("ILEC") = "WarHammer 40K" dr("PLATFORM") = "Eldar" dr("{7/2016} Tot Charges") = 10275.0 dr("{7/2016} % of Total") = 9.51 dr("{8/2016} Tot Charges") = 10071.0 dr("{8/2016} % of Total") = 9.42 dt.Rows.Add(dr)
dr = dt.NewRow() dr("ID") = 3 dr("ILEC") = "Blood Bowl" dr("PLATFORM") = "Orc" dr("{7/2016} Tot Charges") = 88607.0 dr("{7/2016} % of Total") = 1.12 dr("{8/2016} Tot Charges") = 74780.0 dr("{8/2016} % of Total") = 1.27 dt.Rows.Add(dr)
dr = dt.NewRow() dr("ID") = 4 dr("ILEC") = "Blood Bowl" dr("PLATFORM") = "Human" dr("{7/2016} Tot Charges") = 37775.0 dr("{7/2016} % of Total") = 0.49 dr("{8/2016} Tot Charges") = 42459.0 dr("{8/2016} % of Total") = 0.27 dt.Rows.Add(dr)
dr = dt.NewRow() dr("ID") = 5 dr("ILEC") = "Civ5" dr("PLATFORM") = "Romans" dr("{7/2016} Tot Charges") = 88607.0 dr("{7/2016} % of Total") = 3.25 dr("{8/2016} Tot Charges") = 74980.0 dr("{8/2016} % of Total") = 2.95 dt.Rows.Add(dr)
mds.Tables.Add(dt) mdvTotCharges = mds.Tables("TotalCharges").AsDataView Catch ex As Exception
Private Sub do_TCs_ChartTBL(strWhoCalledMe As String) Dim dt As DataTable Dim dr As DataRow Try
dt = New DataTable("TCs_Chart1") 'Columns for table Dim itemCoulumn As DataColumn Dim d1Coulumn As DataColumn Dim d2Coulumn As DataColumn Dim d3Coulumn As DataColumn Dim d4Coulumn As DataColumn Dim d5Coulumn As DataColumn Dim d6Coulumn As DataColumn
itemCoulumn = New DataColumn("ILEC", Type.GetType("System.String")) d1Coulumn = New DataColumn("[2/2016]", Type.GetType("System.Double")) d2Coulumn = New DataColumn("[3/2016]", Type.GetType("System.Double")) d3Coulumn = New DataColumn("[4/2016]", Type.GetType("System.Double")) d4Coulumn = New DataColumn("[5/2016]", Type.GetType("System.Double")) d5Coulumn = New DataColumn("[6/2016]", Type.GetType("System.Double")) d6Coulumn = New DataColumn("[7/2016]", Type.GetType("System.Double"))
dr = dt.NewRow() dr("ILEC") = "WarHammer" dr("[2/2016]") = 1285.0 dr("[3/2016]") = 1704.0 dr("[4/2016]") = 1871.0 dr("[5/2016]") = 1953.0 dr("[6/2016]") = 6049.0 dr("[7/2016]") = 7294.0 dt.Rows.Add(dr)
dr = dt.NewRow() dr("ILEC") = "WarHammer 40K" dr("[2/2016]") = 5648.0 dr("[3/2016]") = 5704.0 dr("[4/2016]") = 5771.0 dr("[5/2016]") = 5957.0 dr("[6/2016]") = 6703.0 dr("[7/2016]") = 8085.0 dt.Rows.Add(dr)
dr = dt.NewRow() dr("ILEC") = "Blood Bowl" dr("[2/2016]") = 444.0 dr("[3/2016]") = 449.0 dr("[4/2016]") = 496.0 dr("[5/2016]") = 525.0 dr("[6/2016]") = 806.0 dr("[7/2016]") = 950.0 dt.Rows.Add(dr)
dr = dt.NewRow() dr("ILEC") = "Blood Bowl" dr("[2/2016]") = 385.0 dr("[3/2016]") = 424.0 dr("[4/2016]") = 419.0 dr("[5/2016]") = 424.0 dr("[6/2016]") = 429.0 dr("[7/2016]") = 430.0 dt.Rows.Add(dr)
dr = dt.NewRow() dr("ILEC") = "Civ5" dr("[2/2016]") = 1863.0 dr("[3/2016]") = 1930.0 dr("[4/2016]") = 2173.0 dr("[5/2016]") = 2228.0 dr("[6/2016]") = 2247.0 dr("[7/2016]") = 2761.0 dt.Rows.Add(dr)
mds.Tables.Add(dt) mdvTCs_Chart1 = mds.Tables("TCs_Chart1").AsDataView Catch ex As Exception
Private Sub do_TC2s_ChartTBL(strWhoCalledMe As String) Dim dt As DataTable Dim dr As DataRow Try
dt = New DataTable("TCs_Chart2") 'Columns for table Dim itemCoulumn As DataColumn Dim d1Coulumn As DataColumn Dim d2Coulumn As DataColumn Dim d3Coulumn As DataColumn Dim d4Coulumn As DataColumn Dim d5Coulumn As DataColumn Dim d6Coulumn As DataColumn
dr = dt.NewRow() dr("ILEC") = "X-Wing" dr("[2/2016]") = 51087.0 dr("[3/2016]") = 50826.0 dr("[4/2016]") = 51047.0 dr("[5/2016]") = 55947.0 dr("[6/2016]") = 51546.0 dr("[7/2016]") = 64640.0 dt.Rows.Add(dr)
mds.Tables.Add(dt) mdvTCs_Chart2 = mds.Tables("TCs_Chart2").AsDataView Catch ex As Exception
#Region "Game Counts" Private Sub do_LineCountsTBL(strWhoCalledMe As String) Dim dt As DataTable Dim dr As DataRow Try
dt = New DataTable("LineCounts") 'Columns for table Dim idCoulumn As DataColumn Dim ilecCoulumn As DataColumn Dim platformCoulumn As DataColumn Dim d1Coulumn As DataColumn Dim d2Coulumn As DataColumn Dim d3Coulumn As DataColumn Dim d4Coulumn As DataColumn
idCoulumn = New DataColumn("ID", Type.GetType("System.Int32")) ilecCoulumn = New DataColumn("ILEC", Type.GetType("System.String")) platformCoulumn = New DataColumn("PLATFORM", Type.GetType("System.String")) d1Coulumn = New DataColumn("{7/2016} Line Count", Type.GetType("System.Int32")) d2Coulumn = New DataColumn("{7/2016} % of Total", Type.GetType("System.Double")) d3Coulumn = New DataColumn("{8/2016} Line Count", Type.GetType("System.Int32")) d4Coulumn = New DataColumn("{8/2016} % of Total", Type.GetType("System.Double"))
dr = dt.NewRow() dr("ID") = 1 dr("ILEC") = "WarHammer" dr("PLATFORM") = "Eldar" dr("{7/2016} Line Count") = 7294 dr("{7/2016} % of Total") = 8.58 dr("{8/2016} Line Count") = 8345 dr("{8/2016} % of Total") = 9.74 dt.Rows.Add(dr)
dr = dt.NewRow() dr("ID") = 2 dr("ILEC") = "WarHammer 40K" dr("PLATFORM") = "Eldar" dr("{7/2016} Line Count") = 8085 dr("{7/2016} % of Total") = 9.51 dr("{8/2016} Line Count") = 8068 dr("{8/2016} % of Total") = 9.42 dt.Rows.Add(dr)
dr = dt.NewRow() dr("ID") = 3 dr("ILEC") = "Blood Bowl" dr("PLATFORM") = "Orc" dr("{7/2016} Line Count") = 950 dr("{7/2016} % of Total") = 1.12 dr("{8/2016} Line Count") = 1087 dr("{8/2016} % of Total") = 1.27 dt.Rows.Add(dr)
dr = dt.NewRow() dr("ID") = 4 dr("ILEC") = "Blood Bowl" dr("PLATFORM") = "Human" dr("{7/2016} Line Count") = 415 dr("{7/2016} % of Total") = 0.49 dr("{8/2016} Line Count") = 229 dr("{8/2016} % of Total") = 0.27 dt.Rows.Add(dr)
dr = dt.NewRow() dr("ID") = 5 dr("ILEC") = "Civ5" dr("PLATFORM") = "Romans" dr("{7/2016} Line Count") = 2761 dr("{7/2016} % of Total") = 3.25 dr("{8/2016} Line Count") = 2530 dr("{8/2016} % of Total") = 2.95 dt.Rows.Add(dr)
mds.Tables.Add(dt) mdvLineCount = mds.Tables("LineCounts").AsDataView Catch ex As Exception
Private Sub do_LCs_ChartTBL(strWhoCalledMe As String) Dim dt As DataTable Dim dr As DataRow Try
dt = New DataTable("LCs_Chart1") 'Columns for table Dim itemCoulumn As DataColumn Dim d1Coulumn As DataColumn Dim d2Coulumn As DataColumn Dim d3Coulumn As DataColumn Dim d4Coulumn As DataColumn Dim d5Coulumn As DataColumn Dim d6Coulumn As DataColumn
itemCoulumn = New DataColumn("ILEC", Type.GetType("System.String")) d1Coulumn = New DataColumn("[2/2016]", Type.GetType("System.Int32")) d2Coulumn = New DataColumn("[3/2016]", Type.GetType("System.Int32")) d3Coulumn = New DataColumn("[4/2016]", Type.GetType("System.Int32")) d4Coulumn = New DataColumn("[5/2016]", Type.GetType("System.Int32")) d5Coulumn = New DataColumn("[6/2016]", Type.GetType("System.Int32")) d6Coulumn = New DataColumn("[7/2016]", Type.GetType("System.Int32"))
dr = dt.NewRow() dr("ILEC") = "WarHammer" dr("[2/2016]") = 1285 dr("[3/2016]") = 1704 dr("[4/2016]") = 1871 dr("[5/2016]") = 1953 dr("[6/2016]") = 6049 dr("[7/2016]") = 7294 dt.Rows.Add(dr)
dr = dt.NewRow() dr("ILEC") = "WarHammer 40K" dr("[2/2016]") = 5648 dr("[3/2016]") = 5704 dr("[4/2016]") = 5771 dr("[5/2016]") = 5957 dr("[6/2016]") = 6703 dr("[7/2016]") = 8085 dt.Rows.Add(dr)
dr = dt.NewRow() dr("ILEC") = "Blood Bowl" dr("[2/2016]") = 444 dr("[3/2016]") = 449 dr("[4/2016]") = 496 dr("[5/2016]") = 525 dr("[6/2016]") = 806 dr("[7/2016]") = 950 dt.Rows.Add(dr)
dr = dt.NewRow() dr("ILEC") = "Blood Bowl" dr("[2/2016]") = 385 dr("[3/2016]") = 424 dr("[4/2016]") = 419 dr("[5/2016]") = 424 dr("[6/2016]") = 429 dr("[7/2016]") = 430 dt.Rows.Add(dr)
dr = dt.NewRow() dr("ILEC") = "Civ5" dr("[2/2016]") = 1863 dr("[3/2016]") = 1930 dr("[4/2016]") = 2173 dr("[5/2016]") = 2228 dr("[6/2016]") = 2247 dr("[7/2016]") = 2761 dt.Rows.Add(dr)
mds.Tables.Add(dt) mdvLCs_Chart1 = mds.Tables("LCs_Chart1").AsDataView Catch ex As Exception
Private Sub do_LC2s_ChartTBL(strWhoCalledMe As String) Dim dt As DataTable Dim dr As DataRow Try
dt = New DataTable("LCs_Chart2") 'Columns for table Dim itemCoulumn As DataColumn Dim d1Coulumn As DataColumn Dim d2Coulumn As DataColumn Dim d3Coulumn As DataColumn Dim d4Coulumn As DataColumn Dim d5Coulumn As DataColumn Dim d6Coulumn As DataColumn
dr = dt.NewRow() dr("ILEC") = "X-Wing" dr("[2/2016]") = 51087 dr("[3/2016]") = 50826 dr("[4/2016]") = 51047 dr("[5/2016]") = 55947 dr("[6/2016]") = 51546 dr("[7/2016]") = 64640 dt.Rows.Add(dr)
mds.Tables.Add(dt) mdvLCs_Chart2 = mds.Tables("LCs_Chart2").AsDataView Catch ex As Exception
End Class
ahh found the attachment option! :)
Here is a modified version of your sample that should achieve what I believe to be your desired behaviors.
The main thing to keep in mind is that the UltraGridDocumentExporter will changed the section's PageSize when it performs the export. As such, you'll see that I reset the PageSize after each export. This helped to make sure that pages were all the same size.
The next issue to resolve was getting the exported grids to extend across the entire width of the section. To achieve this, I determined the default export size of the grid, and then added the necessary pixels to the width of each UltraGridColumn based on the Point difference between the default export size and the desired size.
Finally, I had to tweak the calculated ChartWidth and the Paddings of each chart canvas so the charts are nicely aligned/spaced. Note that I assigned a BackColor to the chart in the sample to make it easier to see the bounds of each rendered chart.
Hopefully these modifications help resolve your issues.
Hi!