IZennoTable
Assembly: ZennoLab.InterfacesLibrary
Full name: ZennoLab.InterfacesLibrary.ProjectModel.IZennoTable
Kind: interface
Represents the data of the table. Provides methods for editing.
This interface can be used in action OwnCode (C# or PHP) of ProjectMaker.
Properties
ContainsHeaderLine
Property
bool ContainsHeaderLine { get; }
Gets or sets a value that indicates the first row is a header line.
ColCount
Property
int ColCount { get; }
Gets the number of columns actually contained in the table.
Example
// get table by name "MyTable"
IZennoTable table = project.Tables["MyTable"];
// get columns count
int colCount = table.ColCount;
// set rows separator
table.ColSeparator = ":";
// add row to table
table.AddRow("one:two:three:four");
// get columns count
if (table.ColCount != colCount) return "Columns count was changed";
return "Columns count wasn't changed";Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
// get columns count
$colCount = $table->ColCount;
// set rows separator
$table->ColSeparator = ":";
// add row
$table->AddRow("one:two:three:four");
// get columns count
if ($table->ColCount != $colCount) return "Columns count was changed";
return "Columns count wasn't changed";RowCount
Property
int RowCount { get; }
Gets the number of rows actually contained in the table.
Example
// get table by name "MyTable"
IZennoTable table = project.Tables["MyTable"];
// get rows count
int rowsCount = table.RowCount;
// add row
table.AddRow("one:two:three:four");
// get rows count
if (table.RowCount != rowsCount) return "Rows count was changed";
return "Rows count wasn't changed";Example2
// get table by name "MyTable"
IZennoTable table = project.Tables->get_Item("MyTable");
// get rows count
$rowsCount = $table->RowCount;
// add row
$table->AddRow("one:two:three:four");
// get rows count
if ($table->RowCount != $rowsCount) return "Rows count was changed";
return "Rows count wasn't changed";RowSeparator
Property
string RowSeparator { get; set; }
Gets or sets the string that separates the segments of the rows.
The separator can be regular expression. In this case IsRowSeparatorRegEx property should be “true”.
Example
// get table by name "MyTable"
IZennoTable table = project.Tables["MyTable"];
// set rows separator
table.RowSeparator = ":";
// add row
table.AddRow("one:two:three:four");
// return table string
return table.ToString();Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
// set rows separator
$table->RowSeparator = ":";
// add row
$table->AddRow("one:two:three:four");
// return table string
return $table->ToString();ColSeparator
Property
string ColSeparator { get; set; }
Gets or sets the string that separates the segments of the columns.
The separator can be regular expression. In this case IsColSeparatorRegEx property should be “true”.
Example
// get table by name "MyTable"
IZennoTable table = project.Tables["MyTable"];
// set rows separator
table.ColSeparator = ":";
// add row
table.AddRow("one:two:three:four");
// return columns count
return table.ColCount;Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
// set rows separator
$table->ColSeparator = ":";
// add row
$table->AddRow("one:two:three:four");
// return columns count
return $table->ColCount;CsvSeparator
Property
string CsvSeparator { get; set; }
Gets or sets the string that separates the segments of the columns in .csv file.
The separator can be ”,” or ”;“.
TryParseType
Property
bool TryParseType { get; set; }
Gets or sets a settings that allow parse types from string value.
IsRowSeparatorRegEx
Property
bool IsRowSeparatorRegEx { get; set; }
Gets or sets a value that indicates the rows separator is a regular expression or not.
IsColSeparatorRegEx
Property
bool IsColSeparatorRegEx { get; set; }
Gets or sets a value that indicates the columns separator is a regular expression or not.
IsCorrectDisplayInExcel
Property
bool IsCorrectDisplayInExcel { get; set; }
Gets or sets a value that indicates the table is displayed correctly in an excel or not.
ColSeparatorType
Property
SeparatorType ColSeparatorType { get; set; }
Gets or sets a value that indicates the columns separator type.
RowSeparatorType
Property
SeparatorType RowSeparatorType { get; set; }
Gets or sets a value that indicates the rows separator type.
Methods
GetCell
Method
string GetCell(string column, int row)
Gets a value from a cell by column name.
Parameters
| Type | Name | Description |
|---|---|---|
string | column | The name of column. |
int | row | Type : System.Int32 The cell’s row, zero-based index. |
Returns: Value of the requested cell.
Example
// get table by name "MyTable"
IZennoTable table = project.Tables["MyTable"];
// get cell value from column "A" in the zero line
string cell = table.GetCell("A", 0);Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
// get cell value from column "A" in the zero line
$cell = $table->GetCell("A", 0);GetRow
Method
IEnumerable<string> GetRow(int row)
Returns the value of the row at the specified index from IZennoTable object as System.Collections.Generic.IEnumerable
Parameters
| Type | Name | Description |
|---|---|---|
int | row | The zero-based index of the row. |
Returns:
Example
// get table by name "MyTable"
IZennoTable table = project.Tables["MyTable"];
// get row
string row = String.Join(":", table.GetRow(0));
// show message
System.Windows.Forms.MessageBox.Show(row, "Row from table");Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
// get row
$row = String::Join(":", $table->GetRow(0));
// show message
System\Windows\Forms\MessageBox::Show($row, "Row from table");SetCell
Method
void SetCell(string column, int row, string value)
Sets a value into a cell by name.
Parameters
| Type | Name | Description |
|---|---|---|
string | column | The name of column. |
int | row | The cell’s row, zero-based index. |
string | value | The value for the cell being set. |
Example
// get table by name "MyTable"
IZennoTable table = project.Tables["MyTable"];
// set value into cell
table.SetCell("A", 0, "value");Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
// set value into cell
$table->SetCell("A", 0, "value");GetCell
Method
string GetCell(int column, int row)
Gets a value from a cell by column index.
Parameters
| Type | Name | Description |
|---|---|---|
int | column | Type : System.Int32 The index of column. |
int | row | Type : System.Int32 The cell’s row, zero-based index. |
Returns: Value of the requested cell.
Example
// get table by name "MyTable"
IZennoTable table = project.Tables["MyTable"];
// get cell value from column "0" in the zero line
string cell = table.GetCell(0, 0);Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
// get cell value from column "0" in the zero line
$cell = $table->GetCell(0, 0);SetCell
Method
void SetCell(int column, int row, string value)
Sets a value into a cell by index.
Parameters
| Type | Name | Description |
|---|---|---|
int | column | The index of column. |
int | row | The cell’s row, zero-based index. |
string | value | The value for the cell being set. |
Example
// get table by name "MyTable"
IZennoTable table = project.Tables["MyTable"];
// set value into cell
table.SetCell(0, 0, "value");Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
// set value into cell
$table->SetCell(0, 0, "value");SetCellStyle
Method
void SetCellStyle(int column, int row, ZennoTableStyle style)
Sets style for excel cell.
Parameters
| Type | Name | Description |
|---|---|---|
int | column | The cell’s column, zero-based index. |
int | row | The cell’s row, zero-based index. |
ZennoTableStyle | style | The style for excel cell. |
Example
// get table by name "MyTable"
var table = project.Tables["MyTable"];
// create style
var style = new ZennoTableStyle
{
HorizontalAlignment = InterfacesLibrary.Enums.Table.ExcelStyle.HorizontalAlignment.Right,
VerticalAlignment = InterfacesLibrary.Enums.Table.ExcelStyle.VerticalAlignment.Bottom,
Font = new Font("Comic Sans MS", 20, FontStyle.Italic | FontStyle.Underline, GraphicsUnit.Point),
FontColor = Color.Red
};
style.SetBorder(InterfacesLibrary.Enums.Table.ExcelStyle.Borders.Right | InterfacesLibrary.Enums.Table.ExcelStyle.Borders.DiagonalUp, Color.Blue, InterfacesLibrary.Enums.Table.ExcelStyle.LineStyle.DashDot);
// set style
table.SetCellStyle(0, 0, style);Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
// create style
$style = new ZennoTableStyle;
$style->HorizontalAlignment = InterfacesLibrary::Enums::Table::ExcelStyle::HorizontalAlignment->Right;
$style->VerticalAlignment = InterfacesLibrary::Enums::Table::ExcelStyle::VerticalAlignment->Bottom;
$style->Font = new Font("Comic Sans MS", 20, FontStyle->Italic | FontStyle->Underline, GraphicsUnit->Point);
$style->FontColor = Color->Red;
style->SetBorder(InterfacesLibrary::Enums::Table::ExcelStyle::Borders->Right | InterfacesLibrary::Enums::Table::ExcelStyle::Borders->DiagonalUp, Color->Blue, InterfacesLibrary::Enums::Table::ExcelStyle::LineStyle->DashDot);
// set style
$table->SetCellStyle(0, 0, $style);SetRowStyle
Method
void SetRowStyle(int row, ZennoTableStyle style)
Sets style for excel row.
Parameters
| Type | Name | Description |
|---|---|---|
int | row | The cell’s row, zero-based index. |
ZennoTableStyle | style | The style for excel row. |
Example
// get table by name "MyTable"
var table = project.Tables["MyTable"];
// create style
var style = new ZennoTableStyle
{
HorizontalAlignment = InterfacesLibrary.Enums.Table.ExcelStyle.HorizontalAlignment.Right,
VerticalAlignment = InterfacesLibrary.Enums.Table.ExcelStyle.VerticalAlignment.Bottom,
Font = new Font("Comic Sans MS", 20, FontStyle.Italic | FontStyle.Underline, GraphicsUnit.Point),
FontColor = Color.Red
};
style.SetBorder(InterfacesLibrary.Enums.Table.ExcelStyle.Borders.Right | InterfacesLibrary.Enums.Table.ExcelStyle.Borders.DiagonalUp, Color.Blue, InterfacesLibrary.Enums.Table.ExcelStyle.LineStyle.DashDot);
// set style
table.SetRowStyle(0, style);Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
// create style
$style = new ZennoTableStyle;
$style->HorizontalAlignment = InterfacesLibrary::Enums::Table::ExcelStyle::HorizontalAlignment->Right;
$style->VerticalAlignment = InterfacesLibrary::Enums::Table::ExcelStyle::VerticalAlignment->Bottom;
$style->Font = new Font("Comic Sans MS", 20, FontStyle->Italic | FontStyle->Underline, GraphicsUnit->Point);
$style->FontColor = Color->Red;
style->SetBorder(InterfacesLibrary::Enums::Table::ExcelStyle::Borders->Right | InterfacesLibrary::Enums::Table::ExcelStyle::Borders->DiagonalUp, Color->Blue, InterfacesLibrary::Enums::Table::ExcelStyle::LineStyle->DashDot);
// set style
$table->SetRowStyle(0, $style);SetColumnStyle
Method
void SetColumnStyle(int column, ZennoTableStyle style)
Sets style for excel column.
Parameters
| Type | Name | Description |
|---|---|---|
int | column | The cell’s column, zero-based index. |
ZennoTableStyle | style | The style for excel column. |
Example
// get table by name "MyTable"
var table = project.Tables["MyTable"];
// create style
var style = new ZennoTableStyle
{
HorizontalAlignment = InterfacesLibrary.Enums.Table.ExcelStyle.HorizontalAlignment.Right,
VerticalAlignment = InterfacesLibrary.Enums.Table.ExcelStyle.VerticalAlignment.Bottom,
Font = new Font("Comic Sans MS", 20, FontStyle.Italic | FontStyle.Underline, GraphicsUnit.Point),
FontColor = Color.Red
};
style.SetBorder(InterfacesLibrary.Enums.Table.ExcelStyle.Borders.Right | InterfacesLibrary.Enums.Table.ExcelStyle.Borders.DiagonalUp, Color.Blue, InterfacesLibrary.Enums.Table.ExcelStyle.LineStyle.DashDot);
// set style
table.SetColumnStyle(0, style);Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
// create style
$style = new ZennoTableStyle;
$style->HorizontalAlignment = InterfacesLibrary::Enums::Table::ExcelStyle::HorizontalAlignment->Right;
$style->VerticalAlignment = InterfacesLibrary::Enums::Table::ExcelStyle::VerticalAlignment->Bottom;
$style->Font = new Font("Comic Sans MS", 20, FontStyle->Italic | FontStyle->Underline, GraphicsUnit->Point);
$style->FontColor = Color->Red;
style->SetBorder(InterfacesLibrary::Enums::Table::ExcelStyle::Borders->Right | InterfacesLibrary::Enums::Table::ExcelStyle::Borders->DiagonalUp, Color->Blue, InterfacesLibrary::Enums::Table::ExcelStyle::LineStyle->DashDot);
// set style
$table->SetColumnStyle(0, $style);GetCellStyle
Method
ZennoTableStyle GetCellStyle(int column, int row)
Get excel cell style.
Parameters
| Type | Name | Description |
|---|---|---|
int | column | The cell’s column, zero-based index. |
int | row | The cell’s row, zero-based index. |
Returns: Cell style.
Example
// get table by name "MyTable"
var table = project.Tables["MyTable"];
var style = table.GetCellStyle(0,0);Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
$style = $table->GetCellStyle(0, 0);GetRowStyle
Method
ZennoTableStyle GetRowStyle(int row)
Get excel row style.
Parameters
| Type | Name | Description |
|---|---|---|
int | row | The cell’s row, zero-based index. |
Returns: Cell style.
Example
// get table by name "MyTable"
var table = project.Tables["MyTable"];
var style = table.GetRowStyle(0);Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
$style = $table->GetRowStyle(0);GetColumnStyle
Method
ZennoTableStyle GetColumnStyle(int column)
Get excel column style.
Parameters
| Type | Name | Description |
|---|---|---|
int | column | The cell’s column, zero-based index. |
Returns: Cell style.
Example
// get table by name "MyTable"
var table = project.Tables["MyTable"];
var style = table.GetColumnStyle(0);Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
$style = $table->GetColumnStyle(0);AddRow
Method
void AddRow(string row)
Adds a row to the end of the object of IZennoTable interface .
If rows separator wasn’t set then will be using separator by default.
Parameters
| Type | Name | Description |
|---|---|---|
string | row | A string of items created through a specified separator. If this string has a special format, for example file of Excel, the values should be separated by semicolons. |
Example
// get table by name "MyTable"
IZennoTable table = project.Tables["MyTable"];
// set row separator
table.ColSeparator = ":";
// add row
table.AddRow("one:two:three:four");Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
// set row separator
$table->ColSeparator = ":";
// add row
$table->AddRow("one:two:three:four");AddRow
Method
void AddRow(IEnumerable<string> values)
Adds a row from a list of values to the end of the object of IZennoTable interface .
Parameters
| Type | Name | Description |
|---|---|---|
IEnumerable<string> | values | The values of the row. |
Example
// get table by name "MyTable"
IZennoTable table = project.Tables["MyTable"];
// add row
table.AddRow(new [] { "one", "two", "three", "four" });Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
// add row
$table->AddRow(array("one", "two", "three", "four"));DeleteRow
Method
void DeleteRow(int rowNumber)
Removes the row at the specified index of the IZennoTable object.
Parameters
| Type | Name | Description |
|---|---|---|
int | rowNumber | The zero-based index of the row to remove. |
Example
// get table by name "MyTable"
IZennoTable table = project.Tables["MyTable"];
// remove row
table.DeleteRow(0);
// if any row exist then remove row by index "0"
if (project.Tables["MyTable"].RowCount > 0) project.Tables["MyTable"].DeleteRow(0);Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
// remove row
$table->DeleteRow(0);
// if any row exist then remove row by index "0"
if ($project->Tables-get_Item("MyTable")->RowCount > 0) $project->Tables->get_Item("MyTable")->DeleteRow(0);DeleteColumn
Method
void DeleteColumn(int columnNumber)
Removes the column at the specified index of the IZennoTable object.
Parameters
| Type | Name | Description |
|---|---|---|
int | columnNumber | The zero-based index of the row to remove. |
Example
// get table by name "MyTable"
IZennoTable table = project.Tables["MyTable"];
// remove row
table.DeleteColumn(0);Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
// remove row
$table->DeleteColumn(0);DeleteColumn
Method
void DeleteColumn(string columnName)
Removes the column at the specified name (A, B, C…) of the IZennoTable object.
Parameters
| Type | Name | Description |
|---|---|---|
string | columnName | The row name (A, B, C…). |
Example
// get table by name "MyTable"
IZennoTable table = project.Tables["MyTable"];
// remove row
table.DeleteColumn("A");Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
// remove row
$table->DeleteColumn("A");GetColumn
Method
IEnumerable<string> GetColumn(string columnName)
Gets the column values as a list at the specified column name (A, B, C…) of the IZennoTable object.
Parameters
| Type | Name | Description |
|---|---|---|
string | columnName | The row name (A, B, C…). |
Example
// get table by name "MyTable"
IZennoTable table = project.Tables["MyTable"];
// remove row
var result = table.GetColumn("A");Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
// remove row
$result = $table->GetColumn("A");GetColumn
Method
IEnumerable<string> GetColumn(int columnNumber)
Gets the column values as a list at the specified index of the IZennoTable object.
Parameters
| Type | Name | Description |
|---|---|---|
int | columnNumber | The zero-based index of the row to remove. |
Example
// get table by name "MyTable"
IZennoTable table = project.Tables["MyTable"];
// remove row
var result = table.GetColumn(0);Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
// remove row
$result = $table->GetColumn(0);DeleteRow
Method
void DeleteRow(IEnumerable<int> rows)
Removes the rows at the specified indices from collection of the IZennoTable object.
Parameters
| Type | Name | Description |
|---|---|---|
IEnumerable<int> | rows | The specified indices of rows. |
Example
// get table by name "MyTable"
IZennoTable table = project.Tables["MyTable"];
// remove rows
table.DeleteRow(new [] { 0, 1, 5, 7 });Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
// remove rows
$table->DeleteRow(array(0, 1, 5, 7));ToString
Method
string ToString()
Returns a string that represents the current table.
The ToString method for represents the rows and columns in string uses ColSeparator and RowSeparator properties.
Returns: A string that represents the current table.
Example
// get table by name "MyTable"
IZennoTable table = project.Tables["MyTable"];
// convert table to string
string str = project.ToString();Example2
// get table by name "MyTable"
$table = $project->Tables->get_Item("MyTable");
// convert table to string
$str = $project->ToString();Clear
Method
void Clear()
Removes all elements from the table.
Example
// clear the table 1
project.Tables["Table 1"].Clear();Example2
// clear the table 1
$project->Tables->get_Item("Table 1")->Clear();Bind
Method
void Bind(string filename)
Binds the specified file to current table.
Parameters
| Type | Name | Description |
|---|---|---|
string | filename | The file name for bind data. |
Example
// get the table
IZennoTable table = project.Tables["Table 1"];
// bind the file
table.Bind("C:\\mytable.txt");Example2
// get the table
$table = $project->Tables->get_Item("Table 1");
// bind the file
$table->Bind("C:\\mytable.txt");GetColumnsNames
Method
IEnumerable<string> GetColumnsNames()
GetItem
Method
IEnumerable<string> GetItem(string filter, bool removeItem)
Gets the first row from the table satisfies the filter.
Parameters
| Type | Name | Description |
|---|---|---|
string | filter | The filter of range. |
bool | removeItem | true if need to remove the row, otherwise and default false. |
Returns: The requried row of table, or null, if the row is not found.
Example
// gets random row from several ranges of the table
return string.Join(";", project.Tables["Table 1"].GetItem("random1(1,12-15,35-end)"));Example2
// gets random item from several ranges of the list
return String::Join(";", $project->Tables->get_Item("Table 1")->GetItem("random1(1,12-15,35-end)"));GetItems
Method
IEnumerable<IEnumerable<string>> GetItems(string filter, bool removeItems)
Gets rows from the table satisfies the filter.
Parameters
| Type | Name | Description |
|---|---|---|
string | filter | The filter of range. |
bool | removeItems | true if need to remove the rows, otherwise and default false. |
Returns: The collection of requried rows.
Example
// gets 20 random rows from several ranges of the table
var rows = project.Tables["Table 1"].GetItems("random20(1,12-15,35-end)");Example2
// gets 20 random rows from several ranges of the table
$rows = $project->Tables->get_Item("Table 1")->GetItems("random20(1,12-15,35-end)");Reload
Method
bool Reload()
Forcibly updates spreadsheet data. In case of error table does not changing. Supports only Google spreadsheets. Spends requests limit.
Returns: Returns true if spreadsheet data has been successfully reloaded The following code example demonstrates the