Hi,
Recently I have been trying to create the following table structure.
-----------------------------
| | | | |
| Col1 | Col2 | Col3 | Col4 |
| | | | |
-----------------------------
This table will have several rows and will sit on top of an entirely different table directly below it. This pattern will be continued for around 15 separate tables. Each of the tables will have different column constraints. They will all also potentially overflow.
What I am currently doing is as follows:
1. Create a table for columns 1 and 2 (2 columns)- set its border to white.
2. Create a table for columns 3 and 4 (2 columns)- set its border to white.
3. Create a third table to receive tables 1 and 2 (2 columns) - set its border control to black.
4. Add the third table to a fourth table (1 column) that will collect its information.
5. Repeat this for every row that needs to be added to this 4th table. ****(I am adding these as rows so as to be able to overflow them at page end)
- Is there an easier way to do this? I tried adding rectangle elements and or lines with out much success. This will work but is a lot of coding.
Thanks in advance!
Scott
PS - I could send you an attachment and a code snippet if my explanation isn't working!
Table Borders
Re: Table Borders
Support · Oct 23, 2007Hello Scott,
You can add all four columns to the same main table and make that table overflow without any problem to several pages. Following is the link to the Help Documentation on our web site that shows a sample example about Table Continuation
.
Thanks,
ceTe Software Support Team
Re: Table Borders
Forum member · Oct 23, 2007Thanks very much for the reply. Unfortunately I don't think I explained my problem very well. I am looking for a way to control the right and left border on a cell.
- In an attempt to create the appropriate cell level borders I desire, I have placed 2 tables within another table.
Re: Table Borders
Forum member · Oct 23, 2007(LAST POST CONTINUED)
- After I create my new third table - I treat it as a row and place it in a 4th table to house all of the individual table (rows). I do this so that the overflow method will work at the granularity level I desire. This is working fine.
- I am really only trying to hide cell borders.
** Is there a better way to handle borders? Ideally I would like cell level, right border and left border properties. Right now it I am only able to adjust borders at a table level.
- Are there any plans to upgrade the functionality of tables in the future?
-Thanks Again
Re: Table Borders
Support · Oct 23, 2007Hello,
Currently the way to handle cell borders is either by using Rectangle and Line page element or using the method you have currently employed.
We do plan on adding support for cell level borders to a future version but can give no estimate as to if or when this functionality will be made available.
Thanks,
ceTe Software Support Team
Re: Table Borders
Forum member · Oct 23, 2007Thanks!
Re: Table Borders
Forum member · Oct 24, 2007To all,
I decided to post my solution to the above problem. In the end I primarily created an area group adding a white line to the cell I wished to remove the border on (simply covering up the existing black line). I also dynamically adjust column widths in this code in a table with 4 columns based on data input.
Private Sub submitTest()
'0 = no overflow rows -- 1 = overflow rows
Dim Split As Integer
Split = 0
'table cell alignment
Dim align As String
align = "left"
Dim varLength As Single = 0 'string array element length
Dim LargestVarCol1 As Double = 0 ' largest element length
Dim LargestVarCol2 As Double = 0
Dim LargestVarCol3 As Double = 0
Dim LargestVarCol4 As Double = 0
'test string
Dim testArray() As String = {"This", "method", "will", "seem", "more", "intuitive", "to", "programmers", _
"with", "a C background.", "I prefer", "the latter", "becausebecausebecause", "to me, an", "Integer", _
"isn't the", "same", "1818181818", "19191", "220johvjkhvjk22222hvjk2", "2121212", "2222222222", "232323", "242424242424"}
Dim col1 As Integer
Dim col2 As Integer
Dim col3 As Integer
Dim col4 As Integer
'Iterate through each of the 4 columns to determine the longest string in each column
For col1 = 0 To 20 Step 4
varLength = Len(testArray(col1))
If varLength > LargestVarCol1 Then
LargestVarCol1 = varLength
Else
varLength = varLength
End If
Next
varLength = 0
For col2 = 1 To 21 Step 4
varLength = Len(testArray(col2))
If varLength > LargestVarCol2 Then
LargestVarCol2 = varLength
Else
varLength = varLength
End If
Next
varlength = 0
For col3 = 2 To 22 Step 4
varLength = Len(testArray(col3))
If varLength > LargestVarCol3 Then
LargestVarCol3 = varLength
Else
varLength = varLength
End If
Next
varlength = 0
For col4 = 3 To 23 Step 4
varLength = Len(testArray(col4))
If varLength > LargestVarCol4 Then
LargestVarCol4 = varLength
Else
varLength = varLength
End If
Next
varLength = 0
'Determine the appropriate column widths of 4 different columns
'1) ((ColumnWidth1 + ColumnWidth2) = (ColumnWidth3 + ColumnWidth4))
'2) the 4 columns should never be larger than the table width
Dim colWidth As Single
Dim Col1and2Width As Double
Dim Col3and4Width As Double
Dim fixIt1 As Double
Dim fixIt2 As Double
Dim fontFactor As Single = 6.5
'get left over column width
Col1and2Width = 275 - (fontFactor * (LargestVarCol1 + LargestVarCol2))
Col3and4Width = 275 - (fontFactor * (LargestVarCol3 + LargestVarCol4))
'determine how much width can be added to each column
fixIt1 = Col1and2Width / 2
fixIt2 = Col3and4Width / 2
'set the column widths
LargestVarCol1 = (6.5) * LargestVarCol1 + fixIt1
LargestVarCol2 = (6.5) * LargestVarCol2 + fixIt1
LargestVarCol3 = (6.5) * LargestVarCol3 + fixIt2
LargestVarCol4 = (6.5) * LargestVarCol4 + fixIt2
Dim var1 As Single
var1 = CType(LargestVarCol1, Single)
Dim var2 As Single
var2 = CType(LargestVarCol2, Single)
Dim var3 As Single
var3 = CType(LargestVarCol3, Single)
Dim var4 As Single
var4 = CType(LargestVarCol4, Single)
'build the table
Dim testTable As Table = New Table(0, height, 550, 84)
testTable.Columns.Add(var1)
testTable.Columns.Add(var2)
testTable.Columns.Add(var3)
testTable.Columns.Add(var4)
testTable.Padding = 0
testTable.BorderColor = Grayscale.Black ' Note table border color
testTable.Align = TextAlign.Left
Dim c As Integer = 0
Dim I As Integer = 0
'assign the array data to the appropriate columns - calling group Area for fromatting
For I = 0 To 5
Dim MyRow As Row = testTable.Rows.Add(14)
MyRow.Cells.Add((" " & testArray(c)))
MyRow.Cells.Add(groupArea(testArray(c + 1), align, var2))
MyRow.Cells.Add((" " & testArray(c + 2)))
MyRow.Cells.Add(groupArea(testArray(c + 3), align, var4))
c = c + 4
Next
'function that adds table to page
NewPage(testTable, Split)
end sub
Public Overridable Function groupArea(ByVal dataVariable As String, ByVal align As String, ByVal varx As Single) As AreaGroup
'This function accepts 3 paramters to build an area group for a table cell:
'1) format cell borders
'2) Automatically adjust column width
'3) Format text
'dataVariable = string to be formatted
'Align = right, left or center html tag
'varx = column width
' this is used to overlay the existing black border on a cell
Dim Myline As Line = New Line(0, 0.65, 0, 13.4, Grayscale.White)
'Formatted text area to pick up the bold tag
Dim formattedString As String = "<p align=" & align & "><b>" & " " & dataVariable & "</b></p>"
'Define the new formatted text area
Dim ft As FormattedTextArea
'Formatted text area
ft = New FormattedTextArea(formattedString, 0, 0, varx, 12, FontFamily.Helvetica, 12, True)
' Add the rectangle to the page
'SubmitPage.Elements.Add(MyRectangle)
Dim newGroup As AreaGroup = New AreaGroup(varx, 13)
newGroup.Add(Myline)
newGroup.Add(ft)
Return newGroup
End Function