The table object is used to store information from the dbf file associated with a shapefile. More...
Public Member Functions | |
bool | Calculate (string Expression, int RowIndex, out object Result, out string ErrorString) |
Calculates the the expression taking the values from the specified row of the attribute table. More... | |
void | ClearCache () |
Clears the cache (cell values already loaded in the memory). More... | |
bool | Close () |
Closes the attribute table. More... | |
bool | CreateNew (string dbfFilename) |
Creates a new attribute table. More... | |
void | Deserialize (string newVal) |
Restores state of joins from string. More... | |
bool | Dump (string dbfFilename, ICallback cBack=null) |
Writes contents of the DBF file to disk without changing the state of in-memory DBF. More... | |
int | EditAddField (string Name, FieldType Type, int Precision, int Width) |
Adds a field to the table. The table must be in editing mode. More... | |
bool | EditCellValue (int FieldIndex, int RowIndex, object newVal) |
Sets the value of the cell. More... | |
bool | EditClear () |
Deletes all rows and fields from the table. Note: The table must be set to allow editing before the rows and fields can be deleted from the table. More... | |
bool | EditDeleteField (int FieldIndex, ICallback cBack) |
Deletes a field from the table. More... | |
bool | EditDeleteRow (int RowIndex) |
Deletes a row from the table. More... | |
bool | EditInsertField (Field Field, ref int FieldIndex, ICallback cBack) |
Inserts a new field into the table. More... | |
bool | EditInsertRow (ref int RowIndex) |
Inserts a new row into the table. More... | |
bool | EditReplaceField (int FieldIndex, Field NewField, ICallback cBack) |
Replaces the specified field in the table with the new field. More... | |
object | get_CellValue (int FieldIndex, int RowIndex) |
Gets the value of the specified cell in the table. More... | |
string | get_ErrorMsg (int ErrorCode) |
Retrieves the error message associated with the specified error code. More... | |
Field | get_Field (int FieldIndex) |
Gets the field object at the specified field index in the table. More... | |
int | get_FieldIndexByName (string Fieldname) |
Seeks field with specified name. Comparison is case insensitive. More... | |
bool | get_FieldIsJoined (int FieldIndex) |
Gets the value indicating whether the specified field is joined from external table. More... | |
int | get_FieldJoinIndex (int FieldIndex) |
Returns the index of join operation by which the specified field was brought in. More... | |
string | get_JoinFields (int joinIndex) |
Gets string with the names of fields which were used in join operation. More... | |
string | get_JoinFilename (int joinIndex) |
Gets filename of the external datasource used in specified join. More... | |
string | get_JoinFromField (int joinIndex) |
Gets name of FromField in external table for specified join operation. More... | |
string | get_JoinOptions (int joinIndex) |
Gets the options of the join operation. More... | |
string | get_JoinToField (int joinIndex) |
Gets name of ToField in this table for specified join operation. More... | |
object | get_MaxValue (int FieldIndex) |
Returns the maximum value for the specified field of the table. More... | |
double | get_MeanValue (int FieldIndex) |
Calculates the mean value for the specified field of the table. More... | |
object | get_MinValue (int FieldIndex) |
Returns the minimum value for the specified field. More... | |
bool | get_RowIsModified (int RowIndex) |
Gets a value indicating whether the row values have been modified. More... | |
double | get_StandardDeviation (int FieldIndex) |
Calculates the standard deviation for the set of values in specified field. More... | |
bool | Join (Table table2, string field1, string field2) |
Joins external table to the current one. More... | |
bool | Join2 (Table table2, string field1, string field2, string filenameToReopen, string joinOptions) |
Joins external table to the current one. More... | |
bool | Join3 (Table table2, string field1, string field2, string filenameToReopen, string joinOptions, Array fieldList) |
Joins external table to the current one. More... | |
bool | Open (string dbfFilename, ICallback cBack) |
Opens a .dbf table from file. More... | |
bool | ParseExpression (string Expression, ref string ErrorString) |
Checks if the expression is a valid one. More... | |
bool | Query (string Expression, ref object Result, ref string ErrorString) |
Selects the rows in the table which agree with the specified expression. More... | |
bool | Save (ICallback cBack) |
Saves in-memory version of the table to the source file. More... | |
bool | SaveAs (string dbfFilename, ICallback cBack) |
Saves the table using the specified filename. More... | |
string | Serialize () |
Serializes the state of joins for table to be restored later with Table.Deserialize method. More... | |
bool | StartEditingTable (ICallback cBack) |
Sets the table to allow table editing. More... | |
void | StopAllJoins () |
Stops all joins associated with table. More... | |
bool | StopEditingTable (bool ApplyChanges, ICallback cBack) |
Sets the table to prevent editing. More... | |
bool | StopJoin (int joinIndex) |
Stops (removes) specific join created for the table. More... | |
bool | TestExpression (string Expression, tkValueType ReturnType, ref string ErrorString) |
Tests the validity of expression and determines its return type. More... | |
bool | TryJoin (Table table2, string fieldTo, string fieldFrom, out int rowCount, out int joinRowCount) |
Tries to create a join and reports number of rows to be joined for the specified join fields. More... | |
Properties | |
string | CdlgFilter [get] |
Returns the common dialog filter containing all supported file extensions in string format. More... | |
bool | EditingTable [get] |
Gets whether or not the table is in editing mode. More... | |
string | Filename [get] |
Gets the filename of the DBF file if the table is bound to one. More... | |
ICallback | GlobalCallback [get, set] |
The global callback is the interface used by MapWinGIS to pass progress and error events to interested applications. More... | |
bool | IsJoined [get] |
Gets a value indicating whether the table has any joined tables. More... | |
int | JoinCount [get] |
Gets number of joins for the table. More... | |
string | Key [get, set] |
The key may be used by the programmer to store any string data associated with the object. More... | |
int | LastErrorCode [get] |
Retrieves the last error generated in the object. More... | |
int | NumFields [get] |
Gets the number of fields in the table. More... | |
int | NumRows [get] |
Gets the number of rows in the table. More... | |
The table object is used to store information from the dbf file associated with a shapefile.
Graph description
Table expressions.
Table class provides a built-in expression parser which is used at the time of writing these lines by the following methods:
Expression may include:
The intermediate values during calculation and resulting values can be of one of the following types:
The parser doesn't rely on any DBMS, therefore it doesn't support standard SQL functions, both mathematic and string. Therefore for more complex expressions a column should be added, where calculations can be made using Table.get_CellValue, Table.EditCellValue API members and programming language of your choice.
Examples:
Here is code sample demonstrating how to calculate a new field as an average of 2 existing fields:
bool Table.Calculate | ( | string | Expression, |
int | RowIndex, | ||
out object | Result, | ||
out string | ErrorString | ||
) |
Calculates the the expression taking the values from the specified row of the attribute table.
Expression | The expression to analyse. |
RowIndex | The index of the row. |
Result | The result of calculation as variant data type, either boolean, double or string. |
ErrorString | An output string with the description of error in case method failed. |
void Table.ClearCache | ( | ) |
Clears the cache (cell values already loaded in the memory).
bool Table.Close | ( | ) |
bool Table.CreateNew | ( | string | dbfFilename | ) |
Creates a new attribute table.
A new table is automatically in editing mode after it is created.
dbfFilename | The filename for the new table. |
void Table.Deserialize | ( | string | newVal | ) |
Restores state of joins from string.
newVal | String generated by Table.Serialize method. |
bool Table.Dump | ( | string | dbfFilename, |
ICallback | cBack = null |
||
) |
Writes contents of the DBF file to disk without changing the state of in-memory DBF.
dbfFilename | Filename to write the data to. |
cBack | Callback interface. |
The methods may be used for in-memory, when the content should be saved without switching to disk mode.
int Table.EditAddField | ( | string | Name, |
FieldType | Type, | ||
int | Precision, | ||
int | Width | ||
) |
Adds a field to the table. The table must be in editing mode.
Name | The name of field. |
Type | The type of field. |
Precision | The precision of field. |
Width | The width of field. |
bool Table.EditCellValue | ( | int | FieldIndex, |
int | RowIndex, | ||
object | newVal | ||
) |
Sets the value of the cell.
The table must be set to allow editing before a cell's value may be edited.
FieldIndex | The field index of the cell to be edited. |
RowIndex | The row index of the cell to be edited. |
newVal | The new value to be used to set the specified cell's value. |
bool Table.EditClear | ( | ) |
Deletes all rows and fields from the table. Note: The table must be set to allow editing before the rows and fields can be deleted from the table.
bool Table.EditDeleteField | ( | int | FieldIndex, |
ICallback | cBack | ||
) |
Deletes a field from the table.
The table must be set to allow editing before a field can be deleted from the table.
FieldIndex | The index of the field to be deleted from the table. |
cBack | The ICallback object which will receive progress and error messages while the field is being deleted from the table. |
bool Table.EditDeleteRow | ( | int | RowIndex | ) |
Deletes a row from the table.
The table must be set to allow editing before a row can be deleted from the table.
RowIndex | The index of the row to be deleted from the table. |
Inserts a new field into the table.
The table must be set to allow editing before a field can be inserted into the table.
Field | The new field to be inserted into the table. |
FieldIndex | The desired index to be used for the new field being inserted into the table. If the desired index is invalid or unavailable, the actual index used for the new field will be returned. |
cBack | The ICallback object which will receive progress and error messages while the new field is being inserted into the table. |
bool Table.EditInsertRow | ( | ref int | RowIndex | ) |
Inserts a new row into the table.
The table must be set to allow editing before a row can be inserted into the table.
RowIndex | The desired index to use when inserting the new row into the table. If the desired index is invalid or unavailable, the actual index used to insert the new row will be returned. |
Replaces the specified field in the table with the new field.
The table must be set to allow editing before a field can be replaced in the table.
FieldIndex | The index of the field to be replaced. |
NewField | The field to be used to replace the specified field in the table. |
cBack | The ICallback object which will receive progress and error messages while the specified field is being replced by the new field. |
object Table.get_CellValue | ( | int | FieldIndex, |
int | RowIndex | ||
) |
Gets the value of the specified cell in the table.
FieldIndex | The field index of the cell for which the value is required. |
RowIndex | The row index of the cell for which the value is required. |
string Table.get_ErrorMsg | ( | int | ErrorCode | ) |
Retrieves the error message associated with the specified error code.
ErrorCode | The error code for which the error message is required. |
Field Table.get_Field | ( | int | FieldIndex | ) |
Gets the field object at the specified field index in the table.
FieldIndex | The index of the field in the table to be returned. |
int Table.get_FieldIndexByName | ( | string | Fieldname | ) |
Seeks field with specified name. Comparison is case insensitive.
Fieldname | The name of field to search. |
bool Table.get_FieldIsJoined | ( | int | FieldIndex | ) |
Gets the value indicating whether the specified field is joined from external table.
FieldIndex | Field index. |
int Table.get_FieldJoinIndex | ( | int | FieldIndex | ) |
Returns the index of join operation by which the specified field was brought in.
FieldIndex | Field index. |
string Table.get_JoinFields | ( | int | joinIndex | ) |
Gets string with the names of fields which were used in join operation.
joinIndex | Index of the join. |
string Table.get_JoinFilename | ( | int | joinIndex | ) |
Gets filename of the external datasource used in specified join.
joinIndex | Index of join operation. |
string Table.get_JoinFromField | ( | int | joinIndex | ) |
Gets name of FromField in external table for specified join operation.
joinIndex | Index of join operation. |
string Table.get_JoinOptions | ( | int | joinIndex | ) |
Gets the options of the join operation.
joinIndex | Index of the join. |
string Table.get_JoinToField | ( | int | joinIndex | ) |
Gets name of ToField in this table for specified join operation.
joinIndex | Index of join operation. |
object Table.get_MaxValue | ( | int | FieldIndex | ) |
Returns the maximum value for the specified field of the table.
NULL will be returned in case of invalid index.
FieldIndex | The index of the field. |
double Table.get_MeanValue | ( | int | FieldIndex | ) |
Calculates the mean value for the specified field of the table.
NULL will be returned in case of invalid index.
FieldIndex | The index of the field. |
object Table.get_MinValue | ( | int | FieldIndex | ) |
Returns the minimum value for the specified field.
NULL will be returned in case of invalid index.
FieldIndex | The index of the field. |
bool Table.get_RowIsModified | ( | int | RowIndex | ) |
Gets a value indicating whether the row values have been modified.
RowIndex | Index of the row. |
double Table.get_StandardDeviation | ( | int | FieldIndex | ) |
Calculates the standard deviation for the set of values in specified field.
NULL will be returned in case of invalid index.
FieldIndex | The index of the field. |
bool Table.Join | ( | Table | table2, |
string | field1, | ||
string | field2 | ||
) |
Joins external table to the current one.
table2 | External table. |
field1 | Join field of this table. |
field2 | Join filed of external table. |
If formats other than DBF are needed, in-memory dbf table should be populated first.
bool Table.Join2 | ( | Table | table2, |
string | field1, | ||
string | field2, | ||
string | filenameToReopen, | ||
string | joinOptions | ||
) |
Joins external table to the current one.
table2 | >External table. |
field1 | Join field of this table. |
field2 | Join filed of external table. |
filenameToReopen | Filename to be opened to restore join on deserialization of table state. |
joinOptions | Arbitrary join options to help restore join on deserialization. |
If filename specify formats other than dbf (extension is checked), Table.OnUpdateJoin event will be raised. Client can handle this event by populating joinSource table parameter using filename, fieldList and options parameters.
bool Table.Join3 | ( | Table | table2, |
string | field1, | ||
string | field2, | ||
string | filenameToReopen, | ||
string | joinOptions, | ||
Array | fieldList | ||
) |
Joins external table to the current one.
table2 | >External table. |
field1 | Join field of this table. |
field2 | Join filed of external table. |
filenameToReopen | Filename to be opened to restore join on deserialization of table state. |
joinOptions | Arbitrary join options to help restore join on deserialization. |
fieldList | Comma separated list of fields to be displayed from external table. |
If filename specify formats other than dbf (extension is checked), Table.OnUpdateJoin event will be raised. Client can handle this event by populating joinSource table parameter using filename, fieldList and options parameters.
bool Table.Open | ( | string | dbfFilename, |
ICallback | cBack | ||
) |
Opens a .dbf table from file.
dbfFilename | The filename of the table to be opened. |
cBack | The ICallback object which will receive progress and error messages while the table is being opened. |
bool Table.ParseExpression | ( | string | Expression, |
ref string | ErrorString | ||
) |
Checks if the expression is a valid one.
Expression | The expression to analyse. |
ErrorString | An output string with the description of error in case expression is not valid. |
bool Table.Query | ( | string | Expression, |
ref object | Result, | ||
ref string | ErrorString | ||
) |
Selects the rows in the table which agree with the specified expression.
Expression | The query expression. |
Result | An array of integer type with the indices of rows which were selected. |
ErrorString | An output string with the description of error on failure. |
bool Table.Save | ( | ICallback | cBack | ) |
Saves in-memory version of the table to the source file.
This method should be called while the table is in editing mode. The editing mode will not be closed.
cBack | A callback object to report information about progress and errors. |
bool Table.SaveAs | ( | string | dbfFilename, |
ICallback | cBack | ||
) |
Saves the table using the specified filename.
dbfFilename | The filename to be used to save the table. |
cBack | The ICallback object which will receive progress and error messages while the table is being saved. |
string Table.Serialize | ( | ) |
Serializes the state of joins for table to be restored later with Table.Deserialize method.
bool Table.StartEditingTable | ( | ICallback | cBack | ) |
Sets the table to allow table editing.
cBack | Optional. The ICallback object which will receive progress and error events while the table is being set to allow editing. |
void Table.StopAllJoins | ( | ) |
Stops all joins associated with table.
bool Table.StopEditingTable | ( | bool | ApplyChanges, |
ICallback | cBack | ||
) |
Sets the table to prevent editing.
ApplyChanges | Optional. A boolean value representing whether or not to save changes to the table. The default is True, to save the changes. |
cBack | Optional. The ICallback object which will receive progress and error messages while the table is being set to prevent editing. |
bool Table.StopJoin | ( | int | joinIndex | ) |
Stops (removes) specific join created for the table.
joinIndex | Index of join to be removed. |
bool Table.TestExpression | ( | string | Expression, |
tkValueType | ReturnType, | ||
ref string | ErrorString | ||
) |
Tests the validity of expression and determines its return type.
Expression | The expression to test. |
ReturnType | An output value with the return type, either double, string or boolean. |
ErrorString | An output string with the description of error. |
bool Table.TryJoin | ( | Table | table2, |
string | fieldTo, | ||
string | fieldFrom, | ||
out int | rowCount, | ||
out int | joinRowCount | ||
) |
Tries to create a join and reports number of rows to be joined for the specified join fields.
table2 | External table to join. |
fieldTo | Join field of this table. |
fieldFrom | Join field of external table. |
rowCount | Number of rows in this table for which a join is found in external table. |
joinRowCount | Number of unique values from external table, joined to this table. |
The method can be used to determine, if the join fields for table are chosen correctly, i.e. their values match.
|
get |
Returns the common dialog filter containing all supported file extensions in string format.
|
get |
Gets whether or not the table is in editing mode.
|
get |
Gets the filename of the DBF file if the table is bound to one.
|
getset |
The global callback is the interface used by MapWinGIS to pass progress and error events to interested applications.
|
get |
Gets a value indicating whether the table has any joined tables.
|
get |
Gets number of joins for the table.
|
getset |
The key may be used by the programmer to store any string data associated with the object.
|
get |
Retrieves the last error generated in the object.
|
get |
Gets the number of fields in the table.
|
get |
Gets the number of rows in the table.