Jump to content


Use of TABLE and CELL features

3 replies to this topic

#1 John Cohoon

John Cohoon


  • Members
  • Pip
  • 3 posts

Posted 16 October 2007 - 01:05 PM

I am trying to use either C# of VB.Net and I am having problems with the implementation of using tables in my RTF documents. The samples with the product are using VB6, so they don't directly port over to .Net code.

Do you have some .Net examples for creating tables with cells?

#2 Athanasios Gardos

Athanasios Gardos


  • Admin
  • 360 posts
  • Gender:Male

Posted 17 October 2007 - 12:04 PM

Here it is a VB.NET example on how to create table cells.

Dim oDocument As gsRTFWriter.cDocument
		Dim oPage As gsRTFWriter.cPage
		Dim oParagraph As gsRTFWriter.cParagraph
		Dim oText As gsRTFWriter.cText
		Dim oCell(7, 7) As gsRTFWriter.cCell
		Dim v As Object
		Dim cc, rr As Integer
		Dim sText As String
		oDocument = New gsRTFWriter.cDocument
		oPage = New gsRTFWriter.cPage
		oText = New gsRTFWriter.cText
		oParagraph = New gsRTFWriter.cParagraph
		oText.Text = "October 2007"
		oText.Height = 20
		oText.Bold = True
		For cc = 1 To 7
			For rr = 1 To 7
				oCell(cc, rr) = New gsRTFWriter.cCell
				oCell(cc, rr).Width = 720
				oText = New gsRTFWriter.cText
				oText.ForeColorIndex = oDocument.ColorIndex(0)
				oParagraph = New gsRTFWriter.cParagraph
				oParagraph.Align = gsRTFWriter.gsRTFAlignment.aCenter
				If rr = 1 Then
					sText = Choose(cc, "Sun", "Mon", "Teu", "Thu", "Wed", "Fri", "Sat")
					oCell(cc, rr).BackColorIndex = oDocument.ColorIndex(7)
					sText = "0"
				End If
				oText.Text = sText
				oCell(cc, rr).InsertParagraph(oParagraph)
			Next rr
		Next cc
		v = oCell
		If oDocument.Save("c:\mytest~.rtf") = True Then
		End If

Athanasios Gardos

#3 John Cohoon

John Cohoon


  • Members
  • Pip
  • 3 posts

Posted 18 October 2007 - 03:40 PM

Worked like a charm.I had exactly what you had (of course my table was building with different data). One thing that mine was failing on was the .InsertTable method. I was adding the cell array as the argument into the method call, and not declaring an Object, assigning it the value of my array, then passing that Object into the method:


Dim objIns as Object = objCells

Thanks a lot for your help!


#4 John Cohoon

John Cohoon


  • Members
  • Pip
  • 3 posts

Posted 19 October 2007 - 03:28 PM

Well, my code is no longer generating an error, and the table is being generated. However, although I know that my array of Cells objects is correct (I can validate that through debugging), when it builds the table in the RTF file, it is always missing the first row and the first column of my array.



Reply to this topic


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users