The Autodesk.Revit.DB.TableView
class represents a view of a table in a Revit document.
Columns
- Returns the columns of the table view as a list of Autodesk.Revit.DB.TableViewColumn
objects.Name
- Gets or sets the name of the table view.ParentView
- Returns the parent view of the table view as an Autodesk.Revit.DB.ViewSheet
object.TableData
- Returns the table data of the table view as an Autodesk.Revit.DB.TableData
object.AddColumn
- Adds a new column to the table view, with a specified name and width.DeleteColumn
- Deletes a column from the table view, specified by the index of the column.GetCellText
- Returns the text content of a cell in the table view, specified by the row and column indices.SetCellText
- Sets the text content of a cell in the table view, specified by the row and column indices.// Get the active document
Document doc = commandData.Application.ActiveUIDocument.Document;
// Get the table view by name
TableView tableView = new FilteredElementCollector(doc)
.OfClass(typeof(TableView))
.Where(e => e.Name == "Schedule 1")
.FirstOrDefault() as TableView;
// Get the table data of the table view
TableData tableData = tableView.TableData;
// Output the number of rows and columns in the table
int numRows = tableData.NumberOfRows;
int numCols = tableData.NumberOfColumns;
TaskDialog.Show("Table Info", $"The table has {numRows} rows and {numCols} columns.");
// Add a new column to the table
tableView.AddColumn("New Column", 100);
// Set the text of a cell
int rowIndex = 0;
int colIndex = 0;
tableView.SetCellText(rowIndex, colIndex, "New Value");
// Delete the first column of the table
tableView.DeleteColumn(0);
Autodesk.Revit.DB.TableView
object, use the CreateSchedule(doc, viewId)
method of the Autodesk.Revit.DB.ScheduleSheetInstance
class.Autodesk.Revit.DB.TableViewColumn
class represents a column in a table view. The Columns
property of the Autodesk.Revit.DB.TableView
class returns a list of these objects.TableData
property of the Autodesk.Revit.DB.TableView
class returns a Autodesk.Revit.DB.TableData
object, which represents the data of the table in the view. The data can be modified using the SetCellText
method and retrieved using the GetCellText
method.