Adding columns and data in Tables

Phenom
Phenom

I am trying to add columns and some data in a Table on a Draft sheet.

 

Dim oApp As SolidEdgeFramework.Application = Marshal.GetActiveObject("SolidEdge.Application")

Dim oDoc As SolidEdgeDraft.DraftDocument = oApp.ActiveDocument
Dim oTable As SolidEdgeDraft.Table = oDoc.Tables.Add()

Dim oTitles As TableTitles = oTable.Titles
Dim oTitle As TableTitle = oTitles.Add()
oTitle.value = "New Table"

oTable.Columns.Add(4, True) oTable.Rows.Add(4, True) Dim oCell As TableCell = oTable.Cell(2, 2) oCell.value = 12

oTable.Columns is marked Read-Only but strangely there is a Add method to it which works without errors.

The error is on the next line for the TableCell (E_FAIL).

Is a Table object meant only to be created interactively and accesed programatically ?

The first few lines do create a table on the sheet and also the Title property can be set through code.

The only problem is when adding columns, rows and data into the cells.

Is there a way to add columns, rows and data to the table ?

 

2 REPLIES

Re: Adding columns and data in Tables

Phenom
Phenom

OK, found this to be working.

 

Dim oRows As TableRows = oTable.Rows
oRows.Add(1, True)
oRows.Add(2, True)

Dim oColumns As TableColumns = oTable.Columns
oColumns.Add(1, True)
oColumns.Add(2, True)

Dim oCell As TableCell = oTable.Cell(1, 1)
oCell.value = 100

An option to delete a topic should be made available when a solution is found by the person who orginally started the topic.

Re: Adding columns and data in Tables

Creator
Creator

I was struggling with this same topic for a while. Then I found that in C#, the cell identification needed to use [] instead of ().

 

in c#:

if (table.Cell[rowIndex,columnIndex].value == Rev) 
{

}



Don't delete topics, sometimes these are really helpful!

ST9 MP10
ST10
VS2017 VB.Net & C#