Class Workbook
public sealed class Workbook : IDisposable
- Inheritance
-
Workbook
- Implements
- Inherited Members
Constructors
Workbook()
Create a new instance of workbook.
public Workbook()
Workbook(string, string)
Workbook use for Online
public Workbook(string sFrom = null, string sPassword = null)
Parameters
Properties
AIHelper
helper for call AI.
public static ExcelAI AIHelper { get; }
Property Value
ActiveSheet
Returns an object that represents the active sheet (the sheet on top) in the active workbook or in the specified window or workbook. Returns Nothing if no sheet is active. Read-only.
public Worksheet ActiveSheet { get; }
Property Value
ActiveSheetIndex
Gets or sets index of the active worksheet.
public int ActiveSheetIndex { get; set; }
Property Value
AddInFunctions
Returns collection of add-in functions.
public AddInFunctionsCollection AddInFunctions { get; }
Property Value
Allow3DRangesInDataValidation
public bool Allow3DRangesInDataValidation { get; set; }
Property Value
CalculationMode
Get or set calculation mode.
public ExcelCalculationMode CalculationMode { get; set; }
Property Value
Charts
Returns a Sheets collection that represents all the chart sheets in the specified workbook. Read-only.
public ChartsCollection Charts { get; }
Property Value
Chartsheets
public List<ChartSheet> Chartsheets { get; }
Property Value
CheckComptiliblity
public bool CheckComptiliblity { get; set; }
Property Value
CodeName
Name which used by macros to access to workbook items.
public string CodeName { get; set; }
Property Value
Colors
Returns colors in the palette for the workbook. The palette has 56 entries, each represented by an RGB value. Read/write Object.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Get colors
System.Drawing.Color[] colors = workbook.Colors;
//Get color
System.Drawing.Color color = colors[2];
//Set color
worksheet["B2"].Style.Color = color;
//Save to file
workbook.SaveToFile("CellFormats.xlsx");
public Color[] Colors { get; }
Property Value
- Color[]
ConverterSetting
public ConverterSetting ConverterSetting { get; set; }
Property Value
CultureInfo
public CultureInfo CultureInfo { get; set; }
Property Value
CustomDocumentProperties
Returns collection that represents all the custom document properties
for the specified workbook. Read-only.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Get the document properties
ICustomDocumentProperties documentProperties = workbook.CustomDocumentProperties;
public ICustomDocumentProperties CustomDocumentProperties { get; }
Property Value
CustomFontFileDirectory
Sets the custom directory of font files.
public string[] CustomFontFileDirectory { get; set; }
Property Value
- string[]
CustomFontFilePaths
Returns or sets the custom path of font files.
public string[] CustomFontFilePaths { get; set; }
Property Value
- string[]
CustomTableStyles
public Dictionary<string, PivotTableStyle> CustomTableStyles { get; }
Property Value
DataConns
public DataConnections DataConns { get; }
Property Value
DataSorter
Gets Data sorter to sort the data..
public DataSorter DataSorter { get; }
Property Value
Date1904
True if the workbook uses the 1904 date system. Read/write Boolean.
public bool Date1904 { get; set; }
Property Value
DefaultFontName
Returns or sets the name of the default font.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Set text
worksheet["B2"].Text = "Text";
//Set standard font
workbook.DefaultFontName = "Arial";
//Set standard font size
workbook.DefaultFontSize = 18;
//Save to file
workbook.SaveToFile("CellFormats.xlsx");
public string DefaultFontName { get; set; }
Property Value
DefaultFontSize
Returns or sets the default font size.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Set text
worksheet["B2"].Text = "Text";
//Set standard font
workbook.DefaultFontName = "Arial";
//Set standard font size
workbook.DefaultFontSize = 18;
//Save to file
workbook.SaveToFile("CellFormats.xlsx");
public double DefaultFontSize { get; set; }
Property Value
DisableMacrosStart
Allows users to disable load of macros from document.
public bool DisableMacrosStart { get; set; }
Property Value
DocumentProperties
Returns a BuiltInDocumentProperties collection that represents all the built-in document properties for the specified workbook. Read-only.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Get the built in document properties
IBuiltInDocumentProperties builtInDocumentProperties = workbook.DocumentProperties;
public BuiltInDocumentProperties DocumentProperties { get; }
Property Value
ExternalLinks
public ExternalLinkCollection ExternalLinks { get; }
Property Value
FileName
Gets file name.
public string FileName { get; }
Property Value
HasMacros
Indicates whether contains VBA macros.
public bool HasMacros { get; set; }
Property Value
HasTrackedChanges
Indicates whether the workbook has any tracked changes
public bool HasTrackedChanges { get; }
Property Value
IsCellProtection
Indicates whether cells are protected.
public bool IsCellProtection { get; }
Property Value
IsDigitallySigned
Indicates whether this spreadsheet is digitally signed.
public bool IsDigitallySigned { get; }
Property Value
IsHScrollBarVisible
Returns or sets whether show horizontal scroll bar.
//Create workbook
Workbook workbook = new Workbook();
//Hide horizontal scroll bar
workbook.IsHScrollBarVisible = false;
//Save to file
workbook.SaveToFile("IsHScrollBarVisible.xlsx");
public bool IsHScrollBarVisible { get; set; }
Property Value
IsHideWindow
Hide window
public bool IsHideWindow { get; set; }
Property Value
IsRightToLeft
Indicates whether worksheet is displayed right to left.
public bool IsRightToLeft { get; set; }
Property Value
IsSaved
Indicates whether workbook changes have been saved.
public bool IsSaved { get; set; }
Property Value
IsVScrollBarVisible
Returns or sets whether show vertical scroll bar.
//Create workbook
Workbook workbook = new Workbook();
//Hide vertical scroll bar
workbook.IsVScrollBarVisible = false;
//Save to file
workbook.SaveToFile("IsVScrollBarVisible.xlsx");
public bool IsVScrollBarVisible { get; set; }
Property Value
IsWindowProtection
Indicates window is protected.
public bool IsWindowProtection { get; }
Property Value
MarkerDesigner
public MarkerDesigner MarkerDesigner { get; }
Property Value
MaxColumnCount
public int MaxColumnCount { get; }
Property Value
MaxDigitWidth
public int MaxDigitWidth { get; }
Property Value
MaxRowCount
public int MaxRowCount { get; }
Property Value
MaxRowsOfSharedFormula
public int MaxRowsOfSharedFormula { get; set; }
Property Value
NameRanges
Gets Names collection that represents all the names in the specified
workbook.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Get names
INameRanges names = workbook.NameRanges;
public INameRanges NameRanges { get; }
Property Value
OpenPassword
Returns or sets password to encrypt document.
public string OpenPassword { get; set; }
Property Value
OptimizeImport
Indicates whether to optimize Import data. This option will take effect only on Import methods that are available with the worksheet WARNING: Setting this property to True can decrease memory significantly, but will increase the performance of data import .
public bool OptimizeImport { get; set; }
Property Value
PivotCaches
Returns pivot caches collection. Read-only.
//Create worksheet
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
//Gets pivot caches collection
IPivotCaches pivotCaches = workbook.PivotCaches;
public PivotCachesCollection PivotCaches { get; }
Property Value
ReadOnly
Indicates whether the workbook has been opened as Read-only.
public bool ReadOnly { get; }
Property Value
SelectedTab
Gets or sets tab index of selected.
public int SelectedTab { get; set; }
Property Value
SheetTabBarWidth
Returns or sets the width of worksheet tab bar. 1/1000 of window width.
public int SheetTabBarWidth { get; set; }
Property Value
ShowTabs
Get or sets a value whether the Workbook tabs are displayed.
public bool ShowTabs { get; set; }
Property Value
Styles
Returns a Styles collection that represents all the styles in the specified workbook. Read-only.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Set styles
IStyles styles = workbook.Styles;
public StylesCollection Styles { get; }
Property Value
UseStorageMode
User Compound storage mode
public bool UseStorageMode { get; set; }
Property Value
Version
public ExcelVersion Version { get; set; }
Property Value
Worksheets
Returns a Sheets collection that represents all the worksheets in the specified workbook. Read-only Sheets object.
public WorksheetsCollection Worksheets { get; }
Property Value
WriteProtection
Returns options of the workbook write protection.
public WriteProtection WriteProtection { get; }
Property Value
Methods
AcceptAllTrackedChanges()
Accept all tracked changes in the workbook.
public void AcceptAllTrackedChanges()
AddCustomFont(CustomFontData)
public CustomFontData AddCustomFont(CustomFontData data)
Parameters
data
CustomFontData
Returns
AddDigitalSignature(X509Certificate2, string, DateTime)
Add a DigitalSignature.
public IDigitalSignatures AddDigitalSignature(X509Certificate2 certificate, string comments, DateTime signTime)
Parameters
certificate
X509Certificate2Certificate object that was used to sign
comments
stringSignature Comments
signTime
DateTimeSign Time
Returns
- IDigitalSignatures
Collection of DigitalSignature
AddPivotTableStyle(PivotTableStyle)
public void AddPivotTableStyle(PivotTableStyle pts)
Parameters
pts
PivotTableStyle
CaculateFormulaValue(string)
Computes the string formula
[Obsolete("the method is obsolete, please use CalculateFormulaValue.")]
public object CaculateFormulaValue(string text)
Parameters
text
string
Returns
CalculateAllValue()
Caculate all formula for the workbook
public void CalculateAllValue()
CalculateFormulaValue(string)
Computes the string formula
public object CalculateFormulaValue(string text)
Parameters
text
string
Returns
ChangePaletteColor(Color, int)
Changes the palette for the spreadsheet in the specified index.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Set palette color
workbook.ChangePaletteColor(System.Drawing.Color.Red , 10);
//Set color
worksheet["B2"].Style.Color = workbook.Colors[10];
//Save to file
workbook.SaveToFile("CellFormats.xlsx");
public void ChangePaletteColor(Color color, int index)
Parameters
ClearFontCache()
Clear used fonts in cache.
public void ClearFontCache()
ColumnWidthToPixels(double)
onverts column width in characters into column width in pixels.
public double ColumnWidthToPixels(double columnWidth)
Parameters
columnWidth
doubleColumn width in characters.
Returns
- double
Column width in pixels.
ContainsFont(ExcelFont)
Indicates whether the workbook contains specified font.
public bool ContainsFont(ExcelFont font)
Parameters
font
ExcelFont
Returns
CopyTheme(Workbook)
Copy the theme from source workbook
public void CopyTheme(Workbook srcWorkbook)
Parameters
srcWorkbook
Workbooksource workbook.
CopyThemeColor(Workbook)
Copy the theme color from source workbook
public void CopyThemeColor(Workbook srcWorkbook)
Parameters
srcWorkbook
Workbooksource workbook.
CopyToClipboard()
Copies whole workbook to the clipboard.
[Obsolete("the method is not implemented")]
public void CopyToClipboard()
CopyToClipboard(Worksheet)
Copies the selected worksheet to clipboard.
[Obsolete("the method is not implemented")]
public void CopyToClipboard(Worksheet worksheet)
Parameters
worksheet
Worksheet
CreateEmptySheet()
Create a new worksheet.
public Worksheet CreateEmptySheet()
Returns
CreateEmptySheet(string)
Create a new worksheet.
public Worksheet CreateEmptySheet(string name)
Parameters
name
stringSheet name.
Returns
CreateEmptySheets(int)
Create workbook with specified number of worksheets.
public void CreateEmptySheets(int sheetCount)
Parameters
sheetCount
int
CreateEmptySheets(string[])
Create workbook with specified names of worksheets.
public void CreateEmptySheets(string[] sheetNames)
Parameters
sheetNames
string[]
CreateFont()
Creates a font object and add it to the workbook.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Set text
IRichTextString richText = worksheet["B2"].RichText;
//Create font
IFont font = workbook.CreateFont();
//Set color
font.Color = Color.Red;
//Set text
richText.Text = "Sample";
//Set font
richText.SetFont(0, 5, font);
//Save to file
workbook.SaveToFile("CellFormats.xlsx");
public ExcelFont CreateFont()
Returns
CreatePivotStyle()
public PivotStyle CreatePivotStyle()
Returns
Dispose()
public void Dispose()
FindAllBool(bool)
Finds the cell with the input bool.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Find cells with specified bool value
CellRange[] result = workbook.FindAllBool(true);
public CellRange[] FindAllBool(bool boolValue)
Parameters
boolValue
boolBool value to search for
Returns
- CellRange[]
Found ranges
FindAllDateTime(DateTime)
Finds the cell with the input datetime.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Find cells with specified DateTime value
CellRange[] result = workbook.FindAllDateTime(DateTime.Now);
public CellRange[] FindAllDateTime(DateTime dateTimeValue)
Parameters
dateTimeValue
DateTimeDatetime value to search for.
Returns
- CellRange[]
Found ranges.
FindAllNumber(double, bool)
Finds the cell with the input double.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Find cells with specified double value
CellRange[] result = workbook.FindAllNumber(100.32 , false);
public CellRange[] FindAllNumber(double doubleValue, bool formulaValue)
Parameters
doubleValue
doubleDouble value to search for.
formulaValue
boolIndicates whether includes formula value to search for.
Returns
- CellRange[]
Found ranges.
FindAllString(string, bool, bool)
Finds the cell with the input string.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Find cells with specified string value
string value = "value";
CellRange[] result = workbook.FindAllString(value , false , false);
public CellRange[] FindAllString(string stringValue, bool formula, bool formulaValue)
Parameters
stringValue
stringString value to search for
formula
boolIndicates whether includes formula to search for.
formulaValue
boolIndicates whether includes formula value to search for.
Returns
- CellRange[]
Found ranges.
FindAllTimeSpan(TimeSpan)
Finds the cell with the input time span.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Find cells with specified TimeSpan value
TimeSpan value = new TimeSpan(2, 30, 30);
CellRange[] result = workbook.FindAllTimeSpan(value);
public CellRange[] FindAllTimeSpan(TimeSpan timeSpanValue)
Parameters
timeSpanValue
TimeSpan
Returns
- CellRange[]
Found ranges.
FindBool(bool)
Finds the cell with the input bool.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Find cell with specified bool value
IXLSRange result = workbook.FindBool(true);
public CellRange FindBool(bool boolValue)
Parameters
boolValue
boolBool value to search for.
Returns
- CellRange
Found range.
FindDateTime(DateTime)
Finds the cell with the input datetime.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Find cell with specified DataTime value
DateTime dateTime = DateTime.Now;
IXLSRange result = workbook.FindDateTime(dateTime);
public CellRange FindDateTime(DateTime dateTimeValue)
Parameters
dateTimeValue
DateTimeDatetime value to search for.
Returns
- CellRange
Found range.
FindNumber(double, bool)
Finds the cell with the input number.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Find cell with specified double value
double value = 9.00;
IXLSRange result = workbook.FindNumber(value, false);
public CellRange FindNumber(double doubleValue, bool formulaValue)
Parameters
doubleValue
doubleDouble value to search for.
formulaValue
boolIndicates whether includes formula value to search for.
Returns
- CellRange
Found range.
FindString(string, bool, bool)
Finds the cell with the input string.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Find cell with specified string value
string value = "value";
IXLSRange result = workbook.FindString(value, false, false);
public CellRange FindString(string stringValue, bool formula, bool formulaValue)
Parameters
stringValue
stringString value to search for.
formula
boolIndicates whether includes formula to search for.
formulaValue
boolIndicates whether includes formula value to search for.
Returns
- CellRange
Found range.
FindTimeSpan(TimeSpan)
Finds the cell with the input time span.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Find cell with specified TimeSpan value
TimeSpan timeSpan = new TimeSpan(2, 30, 30);
IXLSRange result = workbook.FindTimeSpan(timeSpan);
public CellRange FindTimeSpan(TimeSpan timeSpanValue)
Parameters
timeSpanValue
TimeSpanTime span value to search for.
Returns
- CellRange
Found range.
GetChartSheetByName(string)
public ChartSheet GetChartSheetByName(string name)
Parameters
name
string
Returns
GetCustomFontParsedResult()
Get result that parse the custom path of font files
public Hashtable GetCustomFontParsedResult()
Returns
GetDigitalSignatures()
Get collection of DigitalSignature in this file.
public IDigitalSignatures GetDigitalSignatures()
Returns
- IDigitalSignatures
Collection of DigitalSignature
GetMatchingColor(Color)
Find best matching Color in workbook palette.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Get color
ExcelColors color = workbook.GetMatchingColor(System.Drawing.Color.Red);
//Set color
worksheet["B2"].Style.KnownColor = color;
//Save to file
workbook.SaveToFile("CellFormats.xlsx");
public ExcelColors GetMatchingColor(Color color)
Parameters
color
ColorColor to search for.
Returns
- ExcelColors
Workbook palette color.
GetMatchingColor(int, int, int)
Find best matching Color in workbook palette.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Get color
ExcelColors color = workbook.GetMatchingColor(255, 0, 0);
//Set color
worksheet["B2"].Style.KnownColor = color;
//Save to file
workbook.SaveToFile("CellFormats.xlsx");
public ExcelColors GetMatchingColor(int r, int g, int b)
Parameters
Returns
- ExcelColors
Workbook palette color.
GetOleSize()
get the size of the visible range of cells when this workbook is displyed as an embedded obect in another document;
public IXLSRange GetOleSize()
Returns
- IXLSRange
if there does not set the size ,return null
GetPaletteColor(ExcelColors)
Gets excel color from workbook palette.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Get color
System.Drawing.Color color = workbook.GetPaletteColor(ExcelColors.Red);
//Set color
worksheet["B2"].Style.Color = workbook.Colors[10];
//Save to file
workbook.SaveToFile("CellFormats.xlsx");
public Color GetPaletteColor(ExcelColors color)
Parameters
color
ExcelColorsIndex from palette array.
Returns
- Color
RGB Color.
GetSafeSheetName(string)
public string GetSafeSheetName(string inputName)
Parameters
inputName
string
Returns
GetSafeSheetName(string, char)
public string GetSafeSheetName(string inputName, char replaceChar)
Parameters
Returns
GetSplitPageInfo()
public List<Dictionary<int, PageColRow>> GetSplitPageInfo()
Returns
GetSplitPageTable(Workbook)
public DataTable GetSplitPageTable(Workbook wb)
Parameters
wb
Workbook
Returns
GetThemeColor(ThemeColorType)
Gets theme color.
public Color GetThemeColor(ThemeColorType type)
Parameters
type
ThemeColorTypeThe theme color type.
Returns
- Color
The theme color.
InitCalcEngine()
Initilize Calc engine
public void InitCalcEngine()
IsPasswordProtected(Stream)
public static bool IsPasswordProtected(Stream stream)
Parameters
stream
Stream
Returns
IsPasswordProtected(string)
check file is password protect
public static bool IsPasswordProtected(string fileName)
Parameters
fileName
string
Returns
LoadFromFile(string)
Loads a file and imports its data.
public void LoadFromFile(string fileName)
Parameters
fileName
string
LoadFromFile(string, ExcelVersion)
Loads a file and imports its data.
public void LoadFromFile(string fileName, ExcelVersion version)
Parameters
fileName
stringFile name
version
ExcelVersionExcel version
LoadFromFile(string, bool)
Loads a file and imports its data.
public void LoadFromFile(string fileName, bool preserveMode)
Parameters
LoadFromFile(string, string)
Loads text files stream with user defined separator.
public void LoadFromFile(string fileName, string separator)
Parameters
LoadFromFile(string, string, int, int)
Loads text files with user defined separator.
public void LoadFromFile(string fileName, string separator, int row, int column)
Parameters
fileName
stringFile name.
separator
stringDelimiter of text file.
row
intStart row.
column
intStart column.
LoadFromFile(string, string, int, int, ExcelVersion)
Loads text files with user defined separator.
public void LoadFromFile(string fileName, string separator, int row, int column, ExcelVersion version)
Parameters
fileName
stringFile name.
separator
stringDelimiter of text file.
row
intStart row.
column
intStart column.
version
ExcelVersionworkbook version
LoadFromFile(string, string, int, int, ExcelVersion, Encoding)
Loads text files with user defined separator.
public void LoadFromFile(string fileName, string separator, int row, int column, ExcelVersion version, Encoding encoding)
Parameters
fileName
stringFile name.
separator
stringDelimiter of text file.
row
intStart row.
column
intStart column.
version
ExcelVersionworkbook version
encoding
EncodingText Encoding
LoadFromHtml(Stream)
Loads a html file and imports its data.
public void LoadFromHtml(Stream stream)
Parameters
stream
StreamStream contains data.
LoadFromHtml(string)
Loads a html file and imports its data.
public void LoadFromHtml(string fileName)
Parameters
fileName
stringFile name.
LoadFromMHtml(Stream)
Loads a Mhtml file and imports its data.
public void LoadFromMHtml(Stream stream)
Parameters
stream
StreamStream contains data.
LoadFromMHtml(string)
Loads a Mhtml file and imports its data.
public void LoadFromMHtml(string fileName)
Parameters
fileName
stringFile name.
LoadFromStream(Stream)
Load workbook from the stream.
public void LoadFromStream(Stream stream)
Parameters
stream
StreamStream contains data.
LoadFromStream(Stream, ExcelVersion)
Load workbook from the stream.
public void LoadFromStream(Stream stream, ExcelVersion version)
Parameters
stream
StreamStream contains data
version
ExcelVersionExcel version
LoadFromStream(Stream, bool)
Load workbook from the stream.
public void LoadFromStream(Stream stream, bool loadStyles)
Parameters
LoadFromStream(Stream, string, int, int)
Loads text files stream with user defined separator.max row 60000.
public void LoadFromStream(Stream stream, string separator, int row, int column)
Parameters
stream
StreamFile stream.
separator
stringDelimiter of text file.
row
intStart row.
column
intStart column.
LoadFromStream(Stream, string, int, int, ExcelVersion)
Loads text files stream with user defined separator. Version2007 support 60000+ row
public void LoadFromStream(Stream stream, string separator, int row, int column, ExcelVersion version)
Parameters
stream
StreamFile stream.
separator
stringDelimiter of text file.
row
intStart row.
column
intStart column.
version
ExcelVersionExcel version.
LoadFromXml(Stream)
Loads a xml file and imports its data.
public void LoadFromXml(Stream stream)
Parameters
stream
StreamStream contains data.
LoadFromXml(string)
Loads a xml file and imports its data.
public void LoadFromXml(string fileName)
Parameters
fileName
stringFile name.
LoadTemplateFromFile(string)
Load workbook from the excel template.
public void LoadTemplateFromFile(string fileName)
Parameters
fileName
stringFile name
LoadTemplateFromFile(string, bool)
Load workbook from the excel template.
public void LoadTemplateFromFile(string fileName, bool loadStyles)
Parameters
OnlineSaveToFile(string)
Save file use for Online
public bool OnlineSaveToFile(string fileName)
Parameters
fileName
string
Returns
OpenOnlineBin(string)
Save bin use for Online
public void OpenOnlineBin(string binFile)
Parameters
binFile
string
PasteFromClipboard()
Copies workbook and all its worksheets from the clipboard.
public void PasteFromClipboard()
PixelsToColumnWidth(double)
Converts column width in pixels into column width in characters.
public double PixelsToColumnWidth(double pixels)
Parameters
pixels
doubleColumn width in pixels.
Returns
- double
Column width in characters.
Protect(string)
protect file also protect workbook window and structure.
public void Protect(string passwordToOpen)
Parameters
passwordToOpen
stringpassword to open file.
Protect(string, bool, bool)
protect file,also Indicates whether protect workbook window and structure or not
public void Protect(string passwordToOpen, bool bIsProtectWindow, bool bIsProtectContent)
Parameters
passwordToOpen
stringpassword to open file.
bIsProtectWindow
boolIndicates if protect workbook window.
bIsProtectContent
boolIndicates if protect workbook content.
ProtectWorkbook(bool, bool, string)
Sets protection for workbook.
public void ProtectWorkbook(bool bIsProtectWindow, bool bIsProtectContent, string password)
Parameters
bIsProtectWindow
boolIndicates if protect workbook window.
bIsProtectContent
boolIndicates if protect workbook content.
password
stringpassword
RejectAllTrackedChanges()
Reject all tracked changes in the workbook.
public void RejectAllTrackedChanges()
RemoveAllDigitalSignatures()
Remove all DigitalSignature in this file.
public void RemoveAllDigitalSignatures()
Replace(string, DataColumn, bool)
Replaces cell's value from data column values.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Replace the oldValue by data column
string oldValue = "Find";
System.Data.DataTable table = new System.Data.DataTable();
table.Columns.Add("Dosage", typeof(int));
table.Rows.Add(1);
System.Data.DataColumn dataColumn = table.Columns[0];
workbook.Replace(oldValue, dataColumn, true);
//Save to file
workbook.SaveToFile("Replace.xlsx");
public void Replace(string oldValue, DataColumn newValues, bool includeColumnName)
Parameters
oldValue
stringValue to replace.
newValues
DataColumnNew data.
includeColumnName
boolIndicates whether includes column name.
Replace(string, DataTable, bool)
Replaces cell's value from data table values.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Replace the oldValue by data table
string oldValue = "Find";
System.Data.DataTable table = new System.Data.DataTable();
table.Columns.Add("Dosage", typeof(int));
table.Rows.Add(1);
workbook.Replace(oldValue, table, true);
//Save to file
workbook.SaveToFile("Replace.xlsx");
public void Replace(string oldValue, DataTable newValues, bool includeColumnName)
Parameters
oldValue
stringValue to replace.
newValues
DataTableNew data.
includeColumnName
boolIndicates whether includes column name.
Replace(string, DateTime)
Replaces cell's value by specified value.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Replace the oldValue by dateTime
string oldValue = "Find";
DateTime dateTime = DateTime.Now;
workbook.Replace(oldValue, dateTime);
//Save to file
workbook.SaveToFile("Replace.xlsx");
public void Replace(string oldValue, DateTime newValue)
Parameters
Replace(string, double)
Replaces cell's value by specified value.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Replace the oldValue by double
string oldValue = "Ten";
workbook.Replace(oldValue, 10.0);
//Save to file
workbook.SaveToFile("Replace.xlsx");
public void Replace(string oldValue, double newValue)
Parameters
Replace(string, double[], bool)
Replaces cell's value from array.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Replace the oldValue by array of double values
string oldValue = "Find";
double[] newValues = { 1.0, 2.0 };
workbook.Replace(oldValue, newValues, true);
//Save to file
workbook.SaveToFile("Replace.xlsx");
public void Replace(string oldValue, double[] newValues, bool isVertical)
Parameters
oldValue
stringValue to replace.
newValues
double[]New values.
isVertical
boolIndicates whether new values should be inserted vertically.
Replace(string, int[], bool)
Replaces cell's value from array.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Replace the oldValue by array of int values
string oldValue = "Find";
int[] newValues = { 1, 2 };
workbook.Replace(oldValue, newValues, true);
//Save to file
workbook.SaveToFile("Replace.xlsx");
public void Replace(string oldValue, int[] newValues, bool isVertical)
Parameters
oldValue
stringValue to replace.
newValues
int[]New values.
isVertical
boolIndicates whether new values should be inserted vertically.
Replace(string, string)
Replaces cell's value by specified value.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Replace the oldValue by newValue
string oldValue = "Find";
string newValue = "NewValue";
workbook.Replace(oldValue, newValue);
//Save to file
workbook.SaveToFile("Replace.xlsx");
public void Replace(string oldValue, string newValue)
Parameters
Replace(string, string[], bool)
Replaces cell's value from array.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Replace the oldValue by array of string values
string oldValue = "Find";
string[] newValues = { "X values", "Y values" };
workbook.Replace(oldValue, newValues , true);
//Save to file
workbook.SaveToFile("Replace.xlsx");
public void Replace(string oldValue, string[] newValues, bool isVertical)
Parameters
oldValue
stringValue to replace.
newValues
string[]New values.
isVertical
boolIndicates whether new values should be inserted vertically.
ResetPalette()
Resets the color palette to the default colors.
//Create worksheet
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
//Get colors
System.Drawing.Color[] colors = workbook.Colors;
//Check color
Console.WriteLine(colors[2].Name);
//Set color
colors[2] = System.Drawing.Color.Yellow;
//Reset palette
workbook.ResetPalette();
//Check color
Console.WriteLine(workbook.Colors[2].Name);
//Save to file
workbook.SaveToFile("CellFormats.xlsx");
public void ResetPalette()
Save()
Saves changes to the specified workbook
public void Save()
SaveAsImage(int, float, float)
public Stream SaveAsImage(int sheetIndex, float dpiX, float dpiY)
Parameters
Returns
SaveAsImage(float, float)
public Stream[] SaveAsImage(float dpiX, float dpiY)
Parameters
Returns
- Stream[]
SaveAsTemplate(string)
Save workbook as template to file.
public void SaveAsTemplate(string fileName)
Parameters
fileName
stringFile name.
SaveAsXml(Stream)
Save workbook as XML format to stream.
public void SaveAsXml(Stream stream)
Parameters
stream
StreamStream object.
SaveAsXml(string)
Save workbook to an XML data file.
public void SaveAsXml(string fileName)
Parameters
fileName
stringXML file name.
SaveChartAsImage(ChartSheet)
Save chart to image.
public Stream SaveChartAsImage(ChartSheet chartSheet)
Parameters
chartSheet
ChartSheet
Returns
SaveChartAsImage(Worksheet)
Save chart to images.
public Stream[] SaveChartAsImage(Worksheet worksheet)
Parameters
worksheet
Worksheetworksheet instance
Returns
- Stream[]
SaveChartAsImage(Worksheet, int)
Save chart to image.
public Stream SaveChartAsImage(Worksheet worksheet, int chartIndex)
Parameters
Returns
SaveToFile(string)
Saves changes to the workbook in a different file
public void SaveToFile(string fileName)
Parameters
fileName
stringFile name.
SaveToFile(string, ExcelVersion)
Saves changes to the workbook in a different file
public void SaveToFile(string fileName, ExcelVersion version)
Parameters
fileName
stringFile name
version
ExcelVersionExcel version
SaveToFile(string, FileFormat)
Saves changes to the workbook in a different file
public void SaveToFile(string fileName, FileFormat fileFormat)
Parameters
fileName
stringFile name
fileFormat
FileFormatFile format
SaveToFile(string, FileFormat, bool)
Saves changes to the workbook in a different file
public void SaveToFile(string fileName, FileFormat fileFormat, bool retainHiddenDataToCSV)
Parameters
fileName
stringFile name
fileFormat
FileFormatFile format
retainHiddenDataToCSV
boolRetain hidden data when save to csv.
SaveToFile(string, TextSaveOptions)
Saves changes to the workbook in a different file
public void SaveToFile(string fileName, TextSaveOptions textSaveOptions)
Parameters
fileName
stringFile name
textSaveOptions
TextSaveOptionsText save options.
SaveToFile(string, string)
Saves changes to the workbook in a different file.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Save to file
workbook.SaveToFile("Result.csv" , ",");
public void SaveToFile(string fileName, string separator)
Parameters
SaveToFile(string, string, bool)
Saves changes to the workbook in a different file.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Save to file
workbook.SaveToFile("Result.csv" , ",", true);
public void SaveToFile(string fileName, string separator, bool addQuotationsForStringValue)
Parameters
fileName
stringFile name.
separator
stringCurrent separator.
addQuotationsForStringValue
boolAdd double Quotation marks for string value.
SaveToHtml(string)
Saves the workbook to html
public void SaveToHtml(string fileName)
Parameters
fileName
stringFile name.
SaveToHtml(string, bool)
Saves the workbook to html
public void SaveToHtml(string fileName, bool skipHideSheet)
Parameters
SaveToStream(Stream)
Save workbook the stream
public void SaveToStream(Stream Stream)
Parameters
Stream
StreamStream object
SaveToStream(Stream, FileFormat)
Save workbook to stream.
public void SaveToStream(Stream stream, FileFormat fileFormat)
Parameters
stream
StreamfileFormat
FileFormat
SaveToStream(Stream, string)
Save workbook the stream.
//Create workbook
Workbook workbook = new Workbook();
workbook.LoadFromFile("Sample.xlsx");
//Save to stream
Stream stream = new MemoryStream();
workbook.SaveToFile(stream , ",");
public void SaveToStream(Stream stream, string separator)
Parameters
SetMaxDigitWidth(int)
public void SetMaxDigitWidth(int w)
Parameters
w
int
SetOleSize(int, int, int, int)
set the size of the visible range of cells when this workbook is displyed as an embedded obect in another document;
public void SetOleSize(int firstRow, int firstColumn, int lastRow, int lastColumn)
Parameters
firstRow
intthe visible range's first row index
firstColumn
intthe visible range's first column index
lastRow
intthe visible range's last row index
lastColumn
intthe visible range's last column index
SetThemeColor(ThemeColorType, Color)
Sets the theme color
public void SetThemeColor(ThemeColorType type, Color color)
Parameters
type
ThemeColorTypeThe theme color type.
color
Colorthe theme color
SetWriteProtectionPassword(string)
Sets write protection password.
public void SetWriteProtectionPassword(string password)
Parameters
password
stringPassword to set
SprBpcmUuRG9jLkRvY3Vt(object, object)
public void SprBpcmUuRG9jLkRvY3Vt(object val1, object val2)
Parameters
UnProtect()
unprotect file also upprotect workbook window and structure
public void UnProtect()
UnProtect(string)
unprotect file also upprotect workbook window and structure
public void UnProtect(string bookWindowAndStructurePassword)
Parameters
bookWindowAndStructurePassword
stringpassword for protect workbook window and structure
UnProtectWorkbook(string)
unprotect workbook window and structure
public void UnProtectWorkbook(string password)
Parameters
password
stringpassword