ComHelper Class
Contains methods that can be useful for users which are calling GemBox.Spreadsheet component using COM interop.
- Inheritance:
- System.ObjectComHelper
Constructors
ComHelper()
Initializes a new instance of the ComHelper class.
Methods
AddPageBreak(Object, Int32, Boolean)
Adds a new horizontal or vertical page break above or left to the specified index.
public void AddPageBreak(object sheet, int index, bool horizontalBreak)
Public Sub AddPageBreak(sheet As Object, index As Integer, horizontalBreak As Boolean)
Parameters
sheet
- System.Object
The ExcelWorksheet instance in which to add a page break.
index
- System.Int32
The zero-based index of the row or column.
horizontalBreak
- System.Boolean
true for horizontal page break, false for vertical page break.
ComSetLicense(String)
Call this method from your application to set GemBox.Spreadsheet serial key.
Parameters
serialKey
- System.String
Serial key.
Remarks
You should call this method before using any other class from GemBox.Spreadsheet library. Key can only be set once (if you try second key, exception will be thrown). The best place to call this method is from static constructor of your application's main class.
Valid serial key has multiple groups of alphanumeric characters, separated with dashes.
Free version serial key is: FREE-LIMITED-KEY.
GetColumn(Object, Int32)
Gets the column from a sheet with the specified index.
public ExcelColumn GetColumn(object sheet, int index)
Public Function GetColumn(sheet As Object, index As Integer) As ExcelColumn
Parameters
sheet
- System.Object
The ExcelWorksheet instance from which to retrieve the column.
index
- System.Int32
The zero-based index of the column.
Returns
The ExcelColumn instance of the specified index.
GetRow(Object, Int32)
Gets the row from a sheet with the specified index.
public ExcelRow GetRow(object sheet, int index)
Public Function GetRow(sheet As Object, index As Integer) As ExcelRow
Parameters
sheet
- System.Object
The ExcelWorksheet instance from which to retrieve the row.
index
- System.Int32
The zero-based index of the row.
Returns
The ExcelRow instance of the specified index.
IsEncrypted(String)
Determines whether the file is an encrypted XLSX.
Parameters
path
- System.String
The path from which to read a file.
Returns
- System.Boolean
true if file is an encrypted XLSX; otherwise, false.
Load(String)
Loads a spreadsheet from a file with the specified path.
Parameters
path
- System.String
The path from which to load a spreadsheet.
Returns
A loaded spreadsheet.
Remarks
File extension that is extracted from the path
is used to create the appropriate LoadOptions derived class instance that is then passed to the Load(String, LoadOptions) method.
Following file extensions are supported:
- Microsoft Excel: .xlsx, xlsm, .xltx, .xltm, .xls, .xlt
- OpenDocument Spreadsheet: .ods, .ots
- Character Separated Values: .csv, .tsv
- HyperText Markup Language: .htm, .html, .mht, .mhtml
LoadWithOptions(String, Object)
Loads a spreadsheet from a file with the specified path.
public ExcelFile LoadWithOptions(string path, object options)
Public Function LoadWithOptions(path As String, options As Object) As ExcelFile
Parameters
path
- System.String
The path from which to load a spreadsheet.
options
- System.Object
The loading options which can be used to define settings for load operation.
Returns
A loaded spreadsheet.
RemoveColumn(Object, Int32)
Removes the column with the specified index.
public void RemoveColumn(object sheet, int index)
Public Sub RemoveColumn(sheet As Object, index As Integer)
Parameters
sheet
- System.Object
The ExcelWorksheet instance from which to remove the column.
index
- System.Int32
The zero-based index of the column.
RemoveRow(Object, Int32)
Removes the row with the specified index.
public void RemoveRow(object sheet, int index)
Public Sub RemoveRow(sheet As Object, index As Integer)
Parameters
sheet
- System.Object
The ExcelWorksheet instance from which to remove the row.
index
- System.Int32
The zero-based index of the row.
SaveWithOptions(Object, String, Object)
Saves the spreadsheet to a file with the specified path.
public void SaveWithOptions(object file, string path, object options)
Public Sub SaveWithOptions(file As Object, path As String, options As Object)
Parameters
file
- System.Object
The ExcelFile instance which to save.
path
- System.String
The path to which to save the spreadsheet.
options
- System.Object
The saving options which can be used to define settings for save operation.
SetFrozenWorksheetPanes(Object, String)
Sets frozen worksheet panes for freezing rows and columns.
public void SetFrozenWorksheetPanes(object sheet, string topLeftCell)
Public Sub SetFrozenWorksheetPanes(sheet As Object, topLeftCell As String)
Parameters
sheet
- System.Object
The ExcelWorksheet instance in which to freeze row and column.
topLeftCell
- System.String
Top left visible cell in the bottom right pane.