AVAX-software.com Forums: Use of TABLE and CELL features - AVAX-software.com Forums

Jump to content

Page 1 of 1

Use of TABLE and CELL features

#1 User is offline   John Cohoon Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 16-October 07

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 User is offline   Athanasios Gardos Icon

  • Administrator
  • Icon
  • Group: Admin
  • Posts: 331
  • Joined: 21-March 05
  • 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
		oParagraph.InsertText(oText)
		oPage.InsertParagraph(oParagraph)
		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)
				Else
					sText = "0"
				End If
				oText.Text = sText
				oParagraph.InsertText(oText)
				oCell(cc, rr).InsertParagraph(oParagraph)
			Next rr
		Next cc
		v = oCell
		oPage.InsertTable(v)
		odocument.InsertPage(oPage)
		If odocument.Save("c:\mytest~.rtf") = True Then
			MsgBox("ok")
		End If

Athanasios Gardos
Avax-Software.com

#3 User is offline   John Cohoon Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 16-October 07

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:

Old:
objPage.InsertTable(objCells)

New
Dim objIns as Object = objCells
objPage.InsertTable(objIns)

Thanks a lot for your help!

John

#4 User is offline   John Cohoon Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 16-October 07

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.

Thouhts?

John

Page 1 of 1


Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users