table overflow to two columns

table overflow to two columns

Forum member · Feb 2, 2007
Hello-- I'm trying to build a phone directory that will display two columns on a page. Right now I've got a table with columns for name, phone, team, floor and phone number. That information is half a page wide. What I need is when the page bottom is reached, the table continues beside it. This directory will end up several pages long, too. Do I need to put the table into a formattedtextarea and grab the overflow or is there a better way? Thanks! :kevin

Re: table overflow to two columns

Support · Feb 2, 2007
Hello kevin, You can use the GetOverflowRows() method of the Table object which returns the records which does not fit in the given height of the table. You can capture these overflow rows and add it to another page or besides the table on the same page. You can do this in a loop until the overflow rows exists. You can refer to the Table Continuation topic on our help documenation for more details. Thanks, ceTe Software Support Team.

Re: table overflow to two columns

Forum member · Feb 2, 2007
thank you for the quick reply. Will I need to define two tables for the flow? I'm pulling the data from a database into a SQLDataReader. I understand all the data rows are created then attached to a page, but how should I handle creating tables on alternating sides of a page? Thank you! :kevin Here's my code: Dim MyDocument As Document = New Document ' Create a page dimensions object and set the margins Dim dimensions As PageDimensions = New PageDimensions(PageSize.Letter, PageOrientation.Portrait) dimensions.BottomMargin = 10 dimensions.TopMargin = 10 dimensions.LeftMargin = 10 dimensions.RightMargin = 10 Dim MyPage as ceTe.DynamicPDF.Page = new ceTe.DynamicPDF.Page(dimensions) MyDocument.Pages.Add(MyPage) Dim MyTable As ceTe.DynamicPDF.PageElements.Table = New ceTe.DynamicPDF.PageElements.Table(0, 0, 500, 770) MyTable.BorderWidth=0 ' Add columns to the table MyTable.Columns.Add(4) ' voice mail asterisk MyTable.Columns.Add(140) ' full name and alias MyTable.Columns.Add(75) ' division/team MyTable.Columns.Add(20) ' floor MyTable.Columns.Add(4) ' floor captain MyTable.Columns.Add(55) ' phone While (dr.read()) if dr("Full_Name").substring(0,1)<>alphabet.substring(header-1,1) then Dim hdrRow As Row = MyTable.Rows.Add() Dim Cell1 As Cell = hdrRow.Cells.Add("- " & alphabet.substring(header,1) & " -", Font.HelveticaBold, 12, Grayscale.Black, Grayscale.Gray, 1) Cell1.ColumnSpan=6 header+=1 if header>26 then header=26 end if end if Dim MyRow2 As Row = MyTable.Rows.Add() if dr("VoiceMail")="1" then vm="*" else vm="" end if MyRow2.Cells.Add(vm, Font.Helvetica, 8, RgbColor.Black, RgbColor.White, 0) MyRow2.Cells.Add(dr("Full_Name"), Font.Helvetica, 8, RgbColor.Black, RgbColor.White, 0) MyRow2.Cells.Add(dr("divteam"), Font.Helvetica, 8, RgbColor.Black, RgbColor.White, 0) MyRow2.Cells.Add(dr("floor"), Font.Helvetica, 8, RgbColor.Black, RgbColor.White, 0) if dr("FLCaptain")=1 then captain="+" else captain="" end if MyRow2.Cells.Add(captain, Font.Helvetica, 8, RgbColor.Black, RgbColor.White, 0) MyRow2.Cells.Add(dr("phone"), Font.Helvetica, 8, RgbColor.Black, RgbColor.White, 0) End While ' Add the table to the page MyPage.Elements.Add(MyTable) ' Save the PDF MyDocument.DrawToWeb(false) ' this line suppresses a weird error visible=false

Re: table overflow to two columns

Support · Feb 2, 2007
Hello Kevin, You do not have to create two Table objects. You can have only one table object with all the data from the database and after adding the table to the page you can assign the overflow rows to the original table object. MyTable = Mytable.GetOverflowRows() and here you can set the X and Y coordinates for the MyTable object so that it comes besides the first table. Add this table object to the page. You can refer to the AllPageElements and MailingLabels examples downloaded with the product download. Thanks, ceTe Software Support Team.

Re: table overflow to two columns

Forum member · Feb 7, 2007
Hi-- I'm having a bit of trouble getting this to work. Although the table is being redrawn side by side, each page displays the same data. The left side starts with the beginning, and the right side displays the end of the data, but not in order. Here's my code: <%@ Page Language="vb" AutoEventWireup="True" debug="true"%> <%@ import Namespace="System" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="System.Data.SqlClient" %> <%@ import Namespace="ceTe.DynamicPDF" %> <%@ import Namespace="ceTe.DynamicPDF.PageElements" %> <script runat="server"> ' ============================================================================================ ' staff/topic reports menu; ' Kevin Frey, Inky Fever Ltd, February 2007 ' ============================================================================================ Sub Page_Load(Source As Object, E As EventArgs) if Session("accessLevel")="" Then response.Redirect("login.aspx") end if End Sub Sub staffDir(Sender As Object, E As EventArgs) Dim dbConn As SqlConnection Dim dbCmd as SqlCommand Dim dr as SQLDataReader Dim vm as string Dim captain as string Dim tty as string Dim alphabet as string = " ABCDEFGHIJKLMNOPQRSTUVWXYZ" Dim header as integer = 1 Dim fullname as string Dim column as integer = 1 dbConn = New SqlConnection(XXX) dbConn.Open() dbCmd = new SQLCommand( "SELECT tblUsers2.VoiceMail, tblUsers2.FLCaptain, tblUsers2.Alias, tblUsers2.Full_Name, tblUsers2.floor, tblPhones.AreaCode +'-'+ tblPhones.Phone + tblPhones.tty AS phone, tblPhones.DivInitials +'/'+tblPhones.TmInitials AS divteam FROM tblUsers2 INNER JOIN tblPhones ON tblUsers2.StaffID = tblPhones.StaffID ORDER BY tblUsers2.Full_Name", dbConn) dr = dbCmd.executereader() dr.read() ' Create a PDF Document Dim MyDocument As Document = New Document ' Create a page dimensions object and set the margins Dim dimensions As PageDimensions = New PageDimensions(PageSize.Letter, PageOrientation.Portrait) dimensions.BottomMargin = 10 dimensions.TopMargin = 10 dimensions.LeftMargin = 10 dimensions.RightMargin = 10 Dim MyPage as ceTe.DynamicPDF.Page = new ceTe.DynamicPDF.Page(dimensions) MyDocument.Pages.Add(MyPage) Dim MyTable As ceTe.DynamicPDF.PageElements.Table = New ceTe.DynamicPDF.PageElements.Table(0, 0, 505, 780) MyTable.BorderWidth=0 ' Add columns to the table MyTable.Columns.Add(4) ' voice mail asterisk MyTable.Columns.Add(145) ' full name and alias MyTable.Columns.Add(55) ' division/team MyTable.Columns.Add(20) ' floor MyTable.Columns.Add(4) ' floor captain MyTable.Columns.Add(55) ' phone While (dr.read()) Dim MyRow2 As Row = MyTable.Rows.Add() if dr("VoiceMail")="1" then vm="*" else vm="" end if MyRow2.Cells.Add(vm, Font.Helvetica, 8, RgbColor.Black, RgbColor.White, 0) if dr("Alias")<>"" then fullname=dr("Full_Name") & " (" & dr("Alias") & ")" else fullname=dr("Full_Name") end if MyRow2.Cells.Add(fullname, Font.Helvetica, 8, RgbColor.Black, RgbColor.White, 0) MyRow2.Cells.Add(dr("divteam"), Font.Helvetica, 8, RgbColor.Black, RgbColor.White, 0) MyRow2.Cells.Add(dr("floor"), Font.Helvetica, 8, RgbColor.Black, RgbColor.White, 0) if dr("FLCaptain")=1 then captain="+" else captain="" end if MyRow2.Cells.Add(captain, Font.Helvetica, 8, RgbColor.Black, RgbColor.White, 0) MyRow2.Cells.Add(dr("phone"), Font.Helvetica, 8, RgbColor.Black, RgbColor.White, 0) End While Do 'Dim MyPage As Page = New Page MyDocument.Pages.Add(MyPage) MyPage.Elements.Add(MyTable) MyTable = MyTable.GetOverflowRows(305, 0, 500, 780) Loop While Not (MyTable Is Nothing) ' Save the PDF MyDocument.DrawToWeb(false) visible=false End Sub Sub programDir(Sender As Object, E As EventArgs) End Sub </script> <html> <head> <title>DPI Staff and Topical Directory Management</title> </head> <link rel="Stylesheet" rev="Stylesheet" href="st.css" type="text/css" media="screen" charset="utf-8" /> <body> <div id="box"> <div id="inner"> <div style="text-align: center;"><strong>DPI Staff and Topical Directory Management</strong></div> <form runat="server"> <table width="400" border="0" cellpadding="5" cellspacing="0"> <tr> <td style="border-right: 1px #000000 solid;">&nbsp;</td> <td>&nbsp;</td> </tr> <tr> <td align="center" style="border-right: 1px #000000 solid;"><asp:button text="Program Directory" onclick="programDir" runat="server" width="180" /></td> <td align="center"><asp:button text="Staff Directory" onclick="staffDir" runat="server" width="180" /></td> </tr> <tr> <td align="center" style="border-right: 1px #000000 solid;">&nbsp;</td> <td align="center">&nbsp;</td> </tr> <tr> <td align="center" style="border-right: 1px #000000 solid;">&nbsp;</td> <td align="center">&nbsp;</td> </tr> <tr> <td align="center" style="border-right: 1px #000000 solid;">&nbsp;</td> <td align="center">&nbsp;</td> </tr> <tr> <td align="center" style="border-right: 1px #000000 solid;">&nbsp;</td> <td align="center">&nbsp;</td> </tr> <tr> <td align="center" style="border-right: 1px #000000 solid;">&nbsp;</td> <td align="center">&nbsp;</td> </tr> <tr> <td style="border-right: 1px #000000 solid;">&nbsp;</td> <td>&nbsp;</td> </tr> </table> </form> <p class="info" style="text-align: center; clear: both;">You are logged in as <%=Session("user") %>. <a href="logout.aspx">Logout</a></p> </div> </div> </body> </html>

Re: table overflow to two columns

Support · Feb 7, 2007
Hello Kevin, In order to place the table side by side in a single page you will have to take care of the X and Y positions of the table. You will have to create new pages and have to add the overflow to the new page in the do loop until the overflow exists. In the code you sent you are not adding new pages to the documents. In every new page you will have to set the X, Y coordinates to 0,0. Following is a sample code which creates a table as you described. Dim MyDocument As Document = New Document 'create table Dim MyTable As ceTe.DynamicPDF.PageElements.Table = New ceTe.DynamicPDF.PageElements.Table(0, 0, 200, 500) 'add columns MyTable.Columns.Add(100) MyTable.Columns.Add(100) 'add records to the table For i As Integer = 0 To 200 Dim MyRow As Row = MyTable.Rows.Add() MyRow.Cells.Add("First" + " " + i.ToString()) MyRow.Cells.Add("Second" + " " + i.ToString()) Next Do 'take a new page Dim page As New ceTe.DynamicPDF.Page 'add table to the page page.Elements.Add(MyTable) 'add page to the document MyDocument.Pages.Add(page) 'take the overflow records MyTable = MyTable.GetOverflowRows(0, 0, 200, 500) 'check if the table has overflow If (Not MyTable Is Nothing) Then 'set X and Y to place the table on right side MyTable.X = 250 MyTable.Y = 0 'add this table to the same page page.Elements.Add(MyTable) 'take the overflow to add to a new page MyTable = MyTable.GetOverflowRows(0, 0, 200, 500) End If Loop While Not (MyTable Is Nothing) MyDocument.DrawToWeb(False) Thanks, ceTe Software Support Team.

Re: table overflow to two columns

Forum member · Feb 7, 2007
Thank you for the assistance. This is working better, but still produces unusual output. The final document is 7 pages, but it appears each page is the same, with all the data overlapping. Unfortunately, the URL is inside our firewall so I can't share it, but I can email the PDF to you if that will help. Thank you again. :kevin

Re: table overflow to two columns

Support · Feb 7, 2007
Hello Kevin, Can you please send over your code and final PDF document to [^a|mailto:support@cete.com|Support Team^], so that they can take a look at what exactly is causing the unusual behavior? Thanks, ceTe Software Support Team