'''' This code is part of Document Solutions for Imaging demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.DrawingImportsSystem.IOImportsGrapeCity.Documents.DrawingImportsGrapeCity.Documents.TextImportsGrapeCity.Documents.ImagingImportsGrapeCity.Documents.LayoutImports GCTEXT = GrapeCity.Documents.Text '' This example shows how to draw a table representing a time chart,'' using the GrapeCity.Documents.Drawing.TableRenderer and related classes.PublicClassTimeChartTablePublicFunctionGenerateImage(ByVal pixelSize AsSize,ByVal dpi AsSingle,ByVal opaque AsBoolean,OptionalByVal sampleParams AsString() = Nothing) AsGcBitmap Dim bmp = NewGcBitmap(pixelSize.Width, pixelSize.Height, opaque, dpi, dpi)Using g = bmp.CreateGraphics(Color.White)DrawTable(g, pixelSize.Width, pixelSize.Height)EndUsingReturn bmpEndFunction PrivateSharedSubDrawTable(g AsGcGraphics, pageWidth AsSingle, pageHeight AsSingle)Dim host = NewLayoutHost()Dim view = host.CreateView(pageWidth, pageHeight * 0.7F) Dim rt = view.CreateRect() '' Pad the table rectangle equally from left, right, top and bottom: rt.AnchorDeflate(Nothing, 10) '' All sides of the table are fixed, so we can apply'' star widths to columns and star heights to rows:Dim ta = NewTableRenderer(g, rt, FixedTableSides.All, rowCount:=10, columnCount:=32, gridLineColor:=Color.DimGray, gridLineWidth:=1) Dim columns = ta.ColumnRects columns(0).SetWidth(120)For i = 1To31 columns(i).SetStarWidth(1F)Next '' Table header is a part of the table;'' the first row (rows[0]) is for the table header:Dim rows = ta.RowRects rows(0).SetHeight(40) rows(1).SetHeight(30)For i = 2To9 rows(i).SetStarHeight(1F)Next Dim fmt = NewTextFormat() With { .Font = GCTEXT.Font.FromFile(Path.Combine("Resources", "Fonts", "FreeSans.ttf")), .FontSize = 16, .FontSizeInGraphicUnits = True }Dim cs = NewCellStyle() With { .TextFormat = fmt, .TextAlignment = TextAlignment.Center } Dim csTitle = NewCellStyle(cs) With { .Background = True, .TextFormat = NewTextFormat(fmt) With { .FontSize = 16, .FontBold = True } } ta.AddCell(csTitle, 0, 0, 1, 32, "Small Business Marketing Plan") ta.DefaultCellStyle = NewCellStyle(cs) With { .ParagraphAlignment = ParagraphAlignment.Center }For i = 1To31 ta.AddCell(1, i, i.ToString())Next ta.DefaultCellStyle = NewCellStyle(cs) With { .TextAlignment = TextAlignment.Leading, .PaddingLeft = 3 } ta.AddCell(2, 0, "Business Overview") ta.AddCell(3, 0, "Market Analysis") ta.AddCell(4, 0, "Marketing Strategy") ta.AddCell(5, 0, "Operations Plan") ta.AddCell(6, 0, "Organization") ta.AddCell(7, 0, "Management") ta.AddCell(8, 0, "Legal aspects") ta.AddCell(9, 0, "Financial Plan") '' Add merged background cells for color highlighting:AddBand(ta, 2, 1, 6, Color.FromArgb(247, 202, 171))AddBand(ta, 3, 2, 7, Color.FromArgb(179, 198, 231))AddBand(ta, 4, 5, 6, Color.FromArgb(255, 229, 154))AddBand(ta, 5, 11, 6, Color.FromArgb(45, 116, 182))AddBand(ta, 6, 17, 6, Color.FromArgb(255, 155, 155))AddBand(ta, 7, 18, 6, Color.FromArgb(197, 224, 179))AddBand(ta, 8, 24, 4, Color.FromArgb(3, 174, 80))AddBand(ta, 9, 28, 4, Color.FromArgb(1, 176, 241)) '' We exclude the first row when we add missing cells'' to avoid drawing grid lines for the table header: ta.AddMissingCells(1, 0, 9, 32) ta.Render()EndSub '' The band has the background cell style. So, it is displayed behind the table grid.PrivateSharedSubAddBand(ta AsTableRenderer, rowIndex AsInteger, columnIndex AsInteger, columnCount AsInteger, color AsColor) ta.AddCell(NewCellStyle() With { .Background = True, .FillColor = color }, rowIndex, columnIndex, 1, columnCount)EndSubEndClass