Class CalcSheet
CalcSheet represents a single worksheet in a workbook.
Inheritance
Namespace: Syncfusion.Calculate
Assembly: Syncfusion.Calculate.Base.dll
Syntax
public class CalcSheet : Object, ISheetData, ICalcData, ISerializable
Remarks
A CalcSheet plays the role of an Excel Worksheet. It maintains its own internal data object to hold FormulaInfo objects used by the CalcEngine in its calculation work. The CalcSheet accesses the raw data / formulas that you want to use in the calculations via the ICalcData interface.
Constructors
CalcSheet()
Default constructor.
Declaration
public CalcSheet()
CalcSheet(Int32, Int32)
Constructor that initializes an internal object array to hold data.
Declaration
public CalcSheet(int rows, int cols)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | rows | Number of rows in the data object. |
System.Int32 | cols | Number of columns in the data object. |
CalcSheet(SerializationInfo, StreamingContext)
Constructor used during serialization.
Declaration
protected CalcSheet(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
System.Runtime.Serialization.SerializationInfo | info | |
System.Runtime.Serialization.StreamingContext | context |
Properties
CalculationsSuspended
Gets / sets a flag that indicates whether to compute dependent values as cells change.
Declaration
public bool CalculationsSuspended { get; set; }
Property Value
Type |
---|
System.Boolean |
ColCount
A read-only property that gets the column count.
Declaration
public int ColCount { get; }
Property Value
Type |
---|
System.Int32 |
Delimter
Gets / sets the field delimiter for the WriteSheetToFile method.
Declaration
public static char Delimter { get; set; }
Property Value
Type |
---|
System.Char |
Remarks
The default value is tab.
Engine
A read-only property that gets the CalcEngine object used by this CalcSheet.
Declaration
public CalcEngine Engine { get; set; }
Property Value
Type |
---|
CalcEngine |
Item[Int32, Int32]
Gets / sets a value through the ICalcData.GetValueRowCol and ICalcData.SetValueRowCol implementation methods.
Declaration
public object this[int row, int col] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | row | The row index. |
System.Int32 | col | The column index. |
Property Value
Type |
---|
System.Object |
LockSheetChanges
Enables or disables saving changes within the CalcSheet.
Declaration
public bool LockSheetChanges { get; set; }
Property Value
Type |
---|
System.Boolean |
Name
A property that gets / sets the name used to refer to this sheet.
Declaration
public string Name { get; set; }
Property Value
Type |
---|
System.String |
RowCount
A read-only property that gets the row count.
Declaration
public int RowCount { get; }
Property Value
Type |
---|
System.Int32 |
Methods
add_CalculatedValueChanged(ValueChangedEventHandler)
Declaration
public void add_CalculatedValueChanged(ValueChangedEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
ValueChangedEventHandler | value |
add_ValueChanged(ValueChangedEventHandler)
Declaration
public void add_ValueChanged(ValueChangedEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
ValueChangedEventHandler | value |
CreateSheetFromFile(String)
Creates a CalcSheet from a delimited text file created by WriteSheetToFile.
Declaration
public static CalcSheet CreateSheetFromFile(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | The file name. |
Returns
Type | Description |
---|---|
CalcSheet | A CalcSheet instantiated with the file content. |
GetColumnCount()
This API supports the .NET Framework infrastructure and is not intended to be used directly from your code
Declaration
public int GetColumnCount()
Returns
Type |
---|
System.Int32 |
GetFirstColumn()
Gets the first column index.
Declaration
public int GetFirstColumn()
Returns
Type | Description |
---|---|
System.Int32 | Index of first column |
GetFirstRow()
Get the idex of the first row in UsedRange
Declaration
public int GetFirstRow()
Returns
Type | Description |
---|---|
System.Int32 | index of first row |
GetLastColumn()
Gets the last column index / column count.
Declaration
public int GetLastColumn()
Returns
Type | Description |
---|---|
System.Int32 | Index of last column |
GetLastRow()
get the index of the last row in UsedRange
Declaration
public int GetLastRow()
Returns
Type | Description |
---|---|
System.Int32 | index of last row |
GetObjectData(SerializationInfo, StreamingContext)
Supports serialization.
Declaration
public void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
System.Runtime.Serialization.SerializationInfo | info | Serialization information. |
System.Runtime.Serialization.StreamingContext | context | Describes source and destination of the given stream.. |
GetRowCount()
This API supports the .NET Framework infrastructure and is not intended to be used directly from your code
Declaration
public int GetRowCount()
Returns
Type |
---|
System.Int32 |
GetValueRowCol(Int32, Int32)
Returns the value at the row and column.
Declaration
public virtual object GetValueRowCol(int row, int col)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | row | One-based row index. |
System.Int32 | col | One based column index. |
Returns
Type | Description |
---|---|
System.Object | The cell value. |
OnCalculatedValueChanged(ValueChangedEventArgs)
Raises the CalculatedValueChanged event.
Declaration
protected virtual void OnCalculatedValueChanged(ValueChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
ValueChangedEventArgs | e | Includes the row, col, and value of the change. |
Remarks
This event should be raised any time a value changes.
OnValueChanged(ValueChangedEventArgs)
Raises the ValueChanged event.
Declaration
protected virtual void OnValueChanged(ValueChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
ValueChangedEventArgs | e | Includes the row, col, and value of the change. |
Remarks
This event should be raised any time a value changes.
ReadSSS(StreamReader)
Creates a CalcSheet object from the content of a StreamReader.
Declaration
public static CalcSheet ReadSSS(StreamReader sr)
Parameters
Type | Name | Description |
---|---|---|
System.IO.StreamReader | sr | The StreamReader. |
Returns
Type | Description |
---|---|
CalcSheet | The newly created CalcSheet object. |
remove_CalculatedValueChanged(ValueChangedEventHandler)
Declaration
public void remove_CalculatedValueChanged(ValueChangedEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
ValueChangedEventHandler | value |
remove_ValueChanged(ValueChangedEventHandler)
Declaration
public void remove_ValueChanged(ValueChangedEventHandler value)
Parameters
Type | Name | Description |
---|---|---|
ValueChangedEventHandler | value |
SetValue(Int32, Int32, String)
A Virtual method to save the value through the ICalcData.SetValueRowCol implementation method and raise the ValueChanged event.
Declaration
public virtual void SetValue(int row, int col, string val)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | row | The row index, one-based. |
System.Int32 | col | The column index, one-based. |
System.String | val | The value. |
SetValueRowCol(Object, Int32, Int32)
A Virtual method to set a value at a given row and column.
Declaration
public virtual void SetValueRowCol(object value, int row, int col)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | Value to be set. |
System.Int32 | row | One-based row index. |
System.Int32 | col | One-based column index. |
WireParentObject()
A Virtual method that can be used to handle subscribing to any base object events necessary for implementing the ValueChanged event.
Declaration
public virtual void WireParentObject()
Remarks
For example, when implementing ICalcData on a DataGrid-derived object, you need to know when something in the DataGrid changes so you can raise the required ICalcData.ValueChanged event. In WireParentObject, the DataGrid can subscribe to its DataSource's change event to handle this requirement. If the DataSource is a DataTable, then the DataTable.ColumnChanged event can fulfill the requirement.
WriteSheetToFile(String)
Writes a delimited file.
Declaration
public void WriteSheetToFile(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | The output file name. |
Remarks
The static Delimiter member specifies the field delimiter. Rows are delimited by Environment.NewLine characters. This method serializes formulas instead of computed values. To write a file containing computed values, use the WriteValuesToFile method.
WriteSSS(StreamWriter)
Writes this CalcSheet object with formulas serialized to the given StreamWriter.
Declaration
public void WriteSSS(StreamWriter sw)
Parameters
Type | Name | Description |
---|---|---|
System.IO.StreamWriter | sw | The StreamWriter. |
WriteSSS(StreamWriter, Boolean)
Writes this CalcSheet object to the given StreamWriter.
Declaration
public void WriteSSS(StreamWriter sw, bool valuesOnly)
Parameters
Type | Name | Description |
---|---|---|
System.IO.StreamWriter | sw | The StreamWriter. |
System.Boolean | valuesOnly | Indicates whether to serialize formulas (False) or computed values (True). |
WriteValuesToFile(String)
Serializes the data with computed values to a delimited text file.
Declaration
public void WriteValuesToFile(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | The file name. |
Remarks
The static Delimiter member specifies the field delimiter. Rows are delimited by Environment.NewLine characters. This method serializes computed values instead of formulas. To write a file containing formulas, use the WriteSheetToFile method.
Events
CalculatedValueChanged
This event is raised in SetValueRowCol.
Declaration
public event ValueChangedEventHandler CalculatedValueChanged
Event Type
Type |
---|
ValueChangedEventHandler |
ValueChanged
This event should be raised by the implementer of ICalcData whenever a value changes.
Declaration
public event ValueChangedEventHandler ValueChanged
Event Type
Type |
---|
ValueChangedEventHandler |