alexa
menu

MAUI

  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Search Results for

    Show / Hide Table of Contents

    Interface IWorkbook

    Represents an MS Excel Workbook.

    Inherited Members
    IParentApplication.Application
    IParentApplication.Parent
    Namespace: Syncfusion.XlsIO
    Assembly: Syncfusion.XlsIO.NET.dll
    Syntax
    public interface IWorkbook : IParentApplication

    Properties

    ActiveSheet

    Gets 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.

    Declaration
    IWorksheet ActiveSheet { get; }
    Property Value
    Type
    IWorksheet

    ActiveSheetIndex

    Gets or sets index of the active sheet.

    Declaration
    int ActiveSheetIndex { get; set; }
    Property Value
    Type
    int

    AddInFunctions

    Gets collection of all workbook's add-in functions. Read-only.

    Declaration
    IAddInFunctions AddInFunctions { get; }
    Property Value
    Type
    IAddInFunctions

    Allow3DRangesInDataValidation

    Indicates whether to allow usage of 3D ranges in DataValidation list property (MS Excel doesn't allow).

    Declaration
    bool Allow3DRangesInDataValidation { get; set; }
    Property Value
    Type
    bool

    ArgumentsSeparator

    Gets the formula arguments separator.

    Declaration
    string ArgumentsSeparator { get; }
    Property Value
    Type
    string
    Examples

    The following code snippet illustrates how to get the argument separator.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    //Get the chart argumentSeparator.
    string argumentSeparator = workbook.ArgumentsSeparator;

    Author

    Gets or sets the author of the comment.

    Declaration
    string Author { get; set; }
    Property Value
    Type
    string

    BuiltInDocumentProperties

    Gets collection that represents all the built-in document properties for the specified workbook. Read-only.

    Declaration
    IBuiltInDocumentProperties BuiltInDocumentProperties { get; }
    Property Value
    Type
    IBuiltInDocumentProperties
    Examples

    The following code snippet illustrates how to get the built in document properties.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    //Get the built in document properties.
    IBuiltInDocumentProperties builtInDocumentProperties = workbook.BuiltInDocumentProperties;

    CalculationOptions

    Gets calculation options. Read-only.

    Declaration
    ICalculationOptions CalculationOptions { get; }
    Property Value
    Type
    ICalculationOptions
    Examples

    The following code snippet illustrates how to get the calculation options.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    //Get the calculation options.
    ICalculationOptions calculationOptions = workbook.CalculationOptions;

    Charts

    Gets the collection of the chart objects.

    Declaration
    ICharts Charts { get; }
    Property Value
    Type
    ICharts

    CodeName

    Name which is used by macros to access the workbook items.

    Declaration
    string CodeName { get; set; }
    Property Value
    Type
    string

    Connections

    Gets the workbook connections. Read Only

    Declaration
    IConnections Connections { get; }
    Property Value
    Type
    IConnections
    Examples

    The following code snippet illustrates how to get the connections from the workbook.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    //Gets the workbook connections.
    IConnections connections = workbook.Connections;

    ContentTypeProperties

    Gets a MetaProperties collection that describes the meta data stored in the workbook. Read-only.

    Declaration
    IMetaProperties ContentTypeProperties { get; }
    Property Value
    Type
    IMetaProperties

    CustomDocumentProperties

    Gets collection that represents all the custom document properties for the specified workbook. Read-only.

    Declaration
    ICustomDocumentProperties CustomDocumentProperties { get; }
    Property Value
    Type
    ICustomDocumentProperties
    Examples

    The following code snippet illustrates how to get the custom document properties.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    //Get the document properties.
    ICustomDocumentProperties documentProperties = workbook.CustomDocumentProperties;

    CustomXmlparts

    Gets collection that represents all the Custom Xml parts for the specified workbook. Read-only.

    Declaration
    ICustomXmlPartCollection CustomXmlparts { get; }
    Property Value
    Type
    ICustomXmlPartCollection
    Examples

    The following code snippet illustrates how to get the custom Xml parts.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    //Get the customXml parts.
    ICustomXmlPartCollection CustomXmlparts = workbook.CustomXmlparts;

    Date1904

    True if the workbook uses the 1904 date system.

    Declaration
    bool Date1904 { get; set; }
    Property Value
    Type
    bool

    DetectDateTimeInValue

    Indicates whether detect string value passed to Value (and Value2) property as DateTime. Default value is true.

    Declaration
    bool DetectDateTimeInValue { get; set; }
    Property Value
    Type
    bool
    Remarks

    Setting this property to false can increase performance.

    DisableMacrosStart

    Disables loading of macros from document.

    Declaration
    bool DisableMacrosStart { get; set; }
    Property Value
    Type
    bool
    Remarks

    Excel on file open will simply skip macros and will work as if document does not contain them. This options works only when file contains macros (HasMacros property is True).

    DisplayWorkbookTabs

    True if the tabs are visible. otherwise False.

    Declaration
    bool DisplayWorkbookTabs { get; set; }
    Property Value
    Type
    bool

    DisplayedTab

    Gets or sets index of tab which will be displayed on document open.

    Declaration
    int DisplayedTab { get; set; }
    Property Value
    Type
    int

    HasMacros

    True if workbook contains VBA macros. Read-only.

    Declaration
    bool HasMacros { get; }
    Property Value
    Type
    bool

    IsCellProtection

    True if cell is protected. Read-only.

    Declaration
    bool IsCellProtection { get; }
    Property Value
    Type
    bool

    IsHScrollBarVisible

    Gets or sets a value indicating whether to display horizontal scroll bar.

    Declaration
    bool IsHScrollBarVisible { get; set; }
    Property Value
    Type
    bool
    Examples

    This sample shows how to hide horizontal scroll bar.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    workbook.IsHScrollBarVisible = false;

    IsRightToLeft

    Indicates whether worksheet is displayed right to left.

    Declaration
    bool IsRightToLeft { get; set; }
    Property Value
    Type
    bool

    IsVScrollBarVisible

    Gets or sets a value indicating whether to display vertical scroll bar.

    Declaration
    bool IsVScrollBarVisible { get; set; }
    Property Value
    Type
    bool
    Examples

    This sample shows how to hide vertical scroll bar.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    workbook.IsVScrollBarVisible = false;

    IsWindowProtection

    True if window is protected. Read-only.

    Declaration
    bool IsWindowProtection { get; }
    Property Value
    Type
    bool

    MaxColumnCount

    Gets maximum column count for each worksheet in the workbook. Read-only.

    Declaration
    int MaxColumnCount { get; }
    Property Value
    Type
    int

    MaxRowCount

    Gets maximum row count for each worksheet in the workbook. Read-only.

    Declaration
    int MaxRowCount { get; }
    Property Value
    Type
    int

    Names

    Gets Names collection.

    Declaration
    INames Names { get; }
    Property Value
    Type
    INames
    Remarks

    For an Application object, returns a Names collection that represents all the names in the active workbook. For a Workbook object, returns a Names collection that represents all the names in the specified workbook (including all worksheet-specific names).

    Examples

    The following code snippet illustrates how to get names.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    INames names = workbook.Names;

    Palette

    Gets the color from the Excel document color palette.

    Declaration
    Color[] Palette { get; }
    Property Value
    Type
    Color[]
    Examples

    The following code illustrates how to access the default colors of excel color palette.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet worksheet = workbook.Worksheets[0];
    
        //Get colors
        System.Drawing.Color[] colors = workbook.Palette;
    
        //Get color
        System.Drawing.Color color = colors[2];
    
        //Set color
        worksheet["B2"].CellStyle.Color = color;
    
        //Save and dispose
        workbook.SaveAs("CellFormats.xlsx");
        workbook.Close();
    }

    Palettte

    Gets the color from the Excel document color palette.

    Declaration
    [Obsolete("IWorkbook.Palettte property is obsolete so please use the IWorkbook.Palette property instead. IWorkbook.Palettte will be removed in July 2006. Sorry for the inconvenience")]
    Color[] Palettte { get; }
    Property Value
    Type
    Color[]
    Examples

    The following code snippet illustrates how to get palette color.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    System.Drawing.Color[] palette = workbook.Palette;

    PasswordToOpen

    Gets or sets password to encrypt or decrypt document.

    Declaration
    string PasswordToOpen { get; set; }
    Property Value
    Type
    string

    PivotCaches

    Gets pivot caches collection. Read-only.

    Declaration
    IPivotCaches PivotCaches { get; }
    Property Value
    Type
    IPivotCaches
    Examples

    The following code snippet illustrates how to get pivot caches.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    IPivotCaches pivotCaches = workbook.PivotCaches;

    PrecisionAsDisplayed

    True if the precision to be used as displayed. Read-only.

    Declaration
    bool PrecisionAsDisplayed { get; set; }
    Property Value
    Type
    bool

    ReadOnly

    True if the workbook has been opened as Read-only. Read-only Boolean.

    Declaration
    bool ReadOnly { get; }
    Property Value
    Type
    bool

    ReadOnlyRecommended

    True to display a message when the file is opened, recommending that the file be opened as read-only.

    Declaration
    bool ReadOnlyRecommended { get; set; }
    Property Value
    Type
    bool

    RowSeparator

    Gets or sets row separator for array parsing.

    Declaration
    string RowSeparator { get; }
    Property Value
    Type
    string
    Examples

    The following code snippet illustrates how to get row separator.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    string rowSeparator = workbook.RowSeparator;

    Saved

    True if no changes have been made to the specified workbook since it was last saved. If current value is false then setting it to true cause Save() method call.

    Declaration
    bool Saved { get; set; }
    Property Value
    Type
    bool

    StandardFont

    Gets or sets the name of the standard font.

    Declaration
    string StandardFont { get; set; }
    Property Value
    Type
    string
    Examples

    The following code illustrates how to set the standard font for the workbook.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet worksheet = workbook.Worksheets[0];
    
        //Set text
        worksheet["B2"].Text = "Text";
    
        //Set standard font
        workbook.StandardFont = "Arial";
    
        //Set standard font size
        workbook.StandardFontSize = 18;
    
        //Save and dispose
        workbook.SaveAs("CellFormats.xlsx");
        workbook.Close();
    }

    StandardFontSize

    Gets or sets the standard font size, in points.

    Declaration
    double StandardFontSize { get; set; }
    Property Value
    Type
    double
    Examples

    The following code illustrates how to set the standard font size for the workbook.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet worksheet = workbook.Worksheets[0];
    
        //Set text
        worksheet["B2"].Text = "Text";
    
        //Set standard font
        workbook.StandardFont = "Arial";
    
        //Set standard font size
        workbook.StandardFontSize = 18;
    
        //Save and dispose
        workbook.SaveAs("CellFormats.xlsx");
        workbook.Close();
    }

    Styles

    Gets a Styles collection that represents all the styles in the specified workbook. Read-only.

    Declaration
    IStyles Styles { get; }
    Property Value
    Type
    IStyles
    Examples

    The following code snippet illustrates how to get the Styles.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet worksheet = workbook.Worksheets[0];
    
        //Set text
        worksheet["B2"].Text = "Text";
    
        //Set styles
        IStyles styles = workbook.Styles;
    
        //Set style
        IStyle style = styles[0];
    
        //Set color
        style.ColorIndex = ExcelKnownColors.Red;
    
        //Apply style
        worksheet["B2"].CellStyle = style;
    
        //Save and dispose
        workbook.SaveAs("CellFormats.xlsx");
        workbook.Close();
    }

    TabSheets

    Gets collection of tab sheets. Read-only.

    Declaration
    ITabSheets TabSheets { get; }
    Property Value
    Type
    ITabSheets
    Examples

    The following code snippet illustrates how to get the tabsheets.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    ITabSheets tabsheets = workbook.TabSheets;

    TableStyles

    Gets the table styles object.

    Declaration
    ITableStyles TableStyles { get; }
    Property Value
    Type
    ITableStyles

    ThrowOnUnknownNames

    Indicates whether exception should be thrown when unknown name was found in a formula.

    Declaration
    bool ThrowOnUnknownNames { get; set; }
    Property Value
    Type
    bool
    Examples

    The following code snippet illustrates how to gets or sets the ThrowOnUnknownNames.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    workbook.ThrowOnUnknownNames = true;
    bool isThrowOnUnknownNames = workbook.ThrowOnUnknownNames;

    UseFastStringSearching

    Toggles string searching algorithm.Default value is true.

    Declaration
    bool UseFastStringSearching { get; set; }
    Property Value
    Type
    bool
    Remarks

    If true then Dictionary will be used to locate string inside strings dictionary. This mode is faster but uses more memory. If false then each time string is added to strings dictionary we will have to iterate through it and compare new strings with existing ones.

    VbaProject

    Gets Vba Project in the workbook.

    Declaration
    IVbaProject VbaProject { get; }
    Property Value
    Type
    IVbaProject
    Examples

    The following code snippet illustrates how to get Vba Project from the workbook.

    ExcelEngine engine = new ExcelEngine();
    IWorkbook workbook = engine.Excel.Workbooks.Create();
    IWorksheet sheet = workbook.Worksheets[0];
    
    sheet["A1"].Value = "Test";
    
    IShape shape = sheet.Shapes.AddAutoShapes(AutoShapeType.Rectangle, 2, 2, 40, 40);
    
    Syncfusion.Office.IVbaProject project = workbook.VbaProject;
    
    Syncfusion.Office.IVbaModule module = project.Modules.Add("Test", Syncfusion.Office.VbaModuleType.StdModule);
    
    module.Code = "Sub ShowMessage()" + "\r\n" +
       "    MsgBox \"Shape Clicked!\"" + "\r\n" +
       "End Sub";
    
    shape.OnAction = "Test.ShowMessage";
    
    workbook.SaveAs("Output.xlsm");
    
    workbook.Close();
    engine.Dispose();

    Version

    Gets or sets excel version.

    Declaration
    ExcelVersion Version { get; set; }
    Property Value
    Type
    ExcelVersion

    WorksheetGroup

    Gets grouped worksheets. Read-only.

    Declaration
    IWorksheetGroup WorksheetGroup { get; }
    Property Value
    Type
    IWorksheetGroup
    Examples

    The following code snippet illustrates how to get the grouped sheet.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
     IWorksheetGroup worksheetGroup = workbook.WorksheetGroup;

    Worksheets

    Gets a Sheets collection that represents all the worksheets in the specified workbook. Read-only Sheets object.

    Declaration
    IWorksheets Worksheets { get; }
    Property Value
    Type
    IWorksheets
    Examples

    The following code snippet illustrates how to get the worksheets.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    IWorksheets worksheets = workbook.Worksheets;

    XmlMaps

    Returns the collection of XmlMap object. Read-Only.

    Declaration
    XmlMapCollection XmlMaps { get; }
    Property Value
    Type
    XmlMapCollection

    Methods

    Activate()

    Activates the first window associated with the workbook.

    Declaration
    void Activate()

    AddFont(IFont)

    Adds font to the inner fonts collection. Read-only.

    Declaration
    IFont AddFont(IFont fontToAdd)
    Parameters
    Type Name Description
    IFont fontToAdd

    Font to add.

    Returns
    Type Description
    IFont

    Added IFont.

    Examples

    The following code illustrates how to add IFont to the IWorkbook.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet worksheet = workbook.Worksheets[0];
    
        //Create font
        IFont font = workbook.CreateFont();
    
        //Add font
        workbook.AddFont(font);
    
        //Save and dispose
        workbook.SaveAs("CellFormats.xlsx");
        workbook.Close();
    }

    Clone()

    Creates copy of the current instance.

    Declaration
    IWorkbook Clone()
    Returns
    Type Description
    IWorkbook

    Copy of the current instance.

    Close()

    Closes the object without saving.

    Declaration
    void Close()
    Examples

    The following code illustrate how to closes the object without saving.

            <pre><code class="lang-csharp">ExcelEngine excelEngine = new ExcelEngine();
    

    IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Excel2013; IWorkbook workbook = application.Workbooks.Open("Sample.xlsx"); workbook.Close();

    Close(bool)

    Closes the object. If True, all changes will be saved.

    Declaration
    void Close(bool saveChanges)
    Parameters
    Type Name Description
    bool saveChanges

    If True, all changes will be saved.

    Examples

    The following code illustrate how to closes the object with specified bool value.

            <pre><code class="lang-csharp">ExcelEngine excelEngine = new ExcelEngine();
    

    IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Excel2013; IWorkbook workbook = application.Workbooks.Open("Sample.xlsx"); workbook.Close(true);

    Close(bool, string)

    Closes the object and saves workbook to the specified file name.If True, all changes will be saved.

    Declaration
    void Close(bool SaveChanges, string Filename)
    Parameters
    Type Name Description
    bool SaveChanges

    If True, all changes will be saved.

    string Filename

    Name of the file.

    Examples

    The following code illustrates how to Closes the object and saves workbook to the specified file name.

            <pre><code class="lang-csharp">ExcelEngine excelEngine = new ExcelEngine();
    

    IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Excel2013; IWorkbook workbook = application.Workbooks.Open("Sample.xlsx"); workbook.Close(true,"Output.xlsx");

    CreateDataSorter()

    Creates the Data sorter to sort the data.

    Declaration
    IDataSort CreateDataSorter()
    Returns
    Type Description
    IDataSort

    Returns the Data Sorter.

    CreateFont()

    Creates a IFont object.

    Declaration
    IFont CreateFont()
    Returns
    Type Description
    IFont

    Returns the newly created IFont.

    Examples

    The following code illustrates how to create IFont object.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet worksheet = workbook.Worksheets[0];
    
        //Set text
        IRichTextString richText = worksheet["B2"].RichText;
    
        //Create font
        IFont font = workbook.CreateFont();
    
        //Set color
        font.Color = ExcelKnownColors.Red;
    
        //Set text
        richText.Text = "Sample";
    
        //Set font
        richText.SetFont(0, 5, font);
    
        //Save and dispose
        workbook.SaveAs("CellFormats.xlsx");
        workbook.Close();
    }

    CreateFont(Font)

    Creates a font object based on native font.

    Declaration
    IFont CreateFont(Font nativeFont)
    Parameters
    Type Name Description
    Font nativeFont

    Native font to get settings from.

    Returns
    Type Description
    IFont

    returns newly created font.

    Examples

    The following code illustrates how to create a IFont object based on native System.Drawing.Font.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet worksheet = workbook.Worksheets[0];
    
        //Set text
        IRichTextString richText = worksheet["B2"].RichText;
    
        //Get font
        System.Drawing.Font nativeFont = new System.Drawing.Font(System.Drawing.FontFamily.GenericSerif, 9);
    
        //Create font
        IFont font = workbook.CreateFont(nativeFont);
    
        //Set color
        font.Color = ExcelKnownColors.Red;
    
        //Set text
        richText.Text = "Sample";
    
        //Set font
        richText.SetFont(0, 5, font);
    
        //Save and dispose
        workbook.SaveAs("CellFormats.xlsx");
        workbook.Close();
    }

    CreateFont(IFont)

    Creates font object based on another font object.

    Declaration
    IFont CreateFont(IFont baseFont)
    Parameters
    Type Name Description
    IFont baseFont

    Base font for the new one.

    Returns
    Type Description
    IFont

    Returns a newly created font.

    Examples

    The following code illustrates how to create a IFont using existing IFont.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet worksheet = workbook.Worksheets[0];
    
        //Set text
        IRichTextString richText = worksheet["B2"].RichText;
    
        //Get font
        IFont defaultFont = worksheet["B2"].CellStyle.Font;
    
        //Create font
        IFont font = workbook.CreateFont(defaultFont);
    
        //Set color
        font.Color = ExcelKnownColors.Red;
    
        //Set text
        richText.Text = "Sample";
    
        //Set font
        richText.SetFont(0, 5, font);
    
        //Save and dispose
        workbook.SaveAs("CellFormats.xlsx");
        workbook.Close();
    }

    CreateHFEngine()

    Creates header or footer engine.

    Declaration
    IHFEngine CreateHFEngine()
    Returns
    Type Description
    IHFEngine

    Returns a new instance of header or footer engine.

    CreateTemplateMarkersProcessor()

    Create an instance that can be used for template markers processing.

    Declaration
    ITemplateMarkersProcessor CreateTemplateMarkersProcessor()
    Returns
    Type Description
    ITemplateMarkersProcessor

    Returns the Object that can be used for template markers processing.

    FindAll(bool)

    Returns the cells of the specified bool value.

    Declaration
    IRange[] FindAll(bool findValue)
    Parameters
    Type Name Description
    bool findValue

    Value to search.

    Returns
    Type Description
    IRange[]

    Returns all found cells, or Null if value was not found

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    IRange[] range = workbook.FindAll(true);

    FindAll(DateTime)

    Returns the cells of the specified DateTime value.

    Declaration
    IRange[] FindAll(DateTime findValue)
    Parameters
    Type Name Description
    DateTime findValue

    Value to search.

    Returns
    Type Description
    IRange[]

    Returns all found cells, or Null if value was not found.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    IRange[] results = workbook.FindAll(DateTime.Now);

    FindAll(double, ExcelFindType)

    Returns the cells of the specified double value with the specified ExcelFindType.

    Declaration
    IRange[] FindAll(double findValue, ExcelFindType flags)
    Parameters
    Type Name Description
    double findValue

    Value to search.

    ExcelFindType flags

    Type of value to search.

    Returns
    Type Description
    IRange[]

    Returns all found cells, or Null if value was not found.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    IRange[] results = workbook.FindAll(100.32, ExcelFindType.Number);

    FindAll(string, ExcelFindType)

    Returns the cells with specified string value.

    Declaration
    IRange[] FindAll(string findValue, ExcelFindType flags)
    Parameters
    Type Name Description
    string findValue

    Value to search.

    ExcelFindType flags

    Type of value to search.

    Returns
    Type Description
    IRange[]

    Returns all found cells, or Null if value was not found.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    IRange[] results = workbook.FindAll("Hello World", ExcelFindType.Text);

    FindAll(string, ExcelFindType, ExcelFindOptions)

    Returns the cells of the specified string value with the specified ExcelFindType.

    Declaration
    IRange[] FindAll(string findValue, ExcelFindType flags, ExcelFindOptions findOptions)
    Parameters
    Type Name Description
    string findValue

    Value to search.

    ExcelFindType flags

    Type of value to search.

    ExcelFindOptions findOptions

    Way to search.

    Returns
    Type Description
    IRange[]

    Returns all found cells, or Null if value was not found.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    IRange[] results = workbook.FindAll("Hello World", ExcelFindType.Text, ExcelFindOptions.MatchCase);

    FindAll(TimeSpan)

    Returns the cells of the specified TimeSpan value.

    Declaration
    IRange[] FindAll(TimeSpan findValue)
    Parameters
    Type Name Description
    TimeSpan findValue

    Value to search.

    Returns
    Type Description
    IRange[]

    Return all found cells, or Null if value was not found.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    TimeSpan value = new TimeSpan(2, 30, 30);
    IRange[] results = workbook.FindAll(value);

    FindFirst(bool)

    Returns the first occurrence of the specified bool value.

    Declaration
    IRange FindFirst(bool findValue)
    Parameters
    Type Name Description
    bool findValue

    Value to search.

    Returns
    Type Description
    IRange

    First found cell, or Null if value was not found.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    IRange result = workbook.FindFirst(true);

    FindFirst(DateTime)

    Returns the first occurrence of the specified DateTime value.

    Declaration
    IRange FindFirst(DateTime findValue)
    Parameters
    Type Name Description
    DateTime findValue

    Value to search.

    Returns
    Type Description
    IRange

    First found cell, or Null if value was not found.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    DateTime dateTime = DateTime.Now;
    IRange result = workbook.FindFirst(dateTime);

    FindFirst(double, ExcelFindType)

    Returns the first occurrence of the specified double value with the specified ExcelFindType.

    Declaration
    IRange FindFirst(double findValue, ExcelFindType flags)
    Parameters
    Type Name Description
    double findValue

    Value to search.

    ExcelFindType flags

    Type of value to search.

    Returns
    Type Description
    IRange

    First found cell, or Null if value was not found.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    double value = 9.00;
    IRange result = workbook.FindFirst(value, ExcelFindType.Number);

    FindFirst(string, ExcelFindType)

    Returns the first occurrence of the specified string value with the specified ExcelFindType.

    Declaration
    IRange FindFirst(string findValue, ExcelFindType flags)
    Parameters
    Type Name Description
    string findValue

    Value to search.

    ExcelFindType flags

    Type of value to search.

    Returns
    Type Description
    IRange

    First found cell, or Null if value was not found.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    string value = "value";
    IRange result = workbook.FindFirst(value, ExcelFindType.Text);

    FindFirst(string, ExcelFindType, ExcelFindOptions)

    Returns the first occurrence of the specified string value with the specified ExcelFindType and ExcelFindOptions.

    Declaration
    IRange FindFirst(string findValue, ExcelFindType flags, ExcelFindOptions findOptions)
    Parameters
    Type Name Description
    string findValue

    Value to search.

    ExcelFindType flags

    Type of value to search.

    ExcelFindOptions findOptions

    Way to search the value.

    Returns
    Type Description
    IRange

    First found cell, or Null if value was not found.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    string findvalue = "value";
    IRange result = workbook.FindFirst(findvalue, ExcelFindType.Text, ExcelFindOptions.None);

    FindFirst(TimeSpan)

    Returns the first occurrence of the specified TimeSpan value.

    Declaration
    IRange FindFirst(TimeSpan findValue)
    Parameters
    Type Name Description
    TimeSpan findValue

    Value to search.

    Returns
    Type Description
    IRange

    First found cell, or Null if value was not found.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    TimeSpan timeSpan = new TimeSpan(2, 30, 30);
    IRange result = workbook.FindFirst(timeSpan);

    FindStringEndsWith(string, ExcelFindType)

    Returns the first occurrence that ends with the specified string value.

    Declaration
    IRange FindStringEndsWith(string findValue, ExcelFindType flags)
    Parameters
    Type Name Description
    string findValue

    Value to search.

    ExcelFindType flags

    Type of value to search.

    Returns
    Type Description
    IRange

    First found cell, or Null if value was not found.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    string value = "value";
    IRange result =  workbook.FindStringEndsWith(value, ExcelFindType.Text);

    FindStringEndsWith(string, ExcelFindType, bool)

    Returns the first occurrence that ends with the specified string value which ignores the case.

    Declaration
    IRange FindStringEndsWith(string findValue, ExcelFindType flags, bool ignoreCase)
    Parameters
    Type Name Description
    string findValue

    Value to search.

    ExcelFindType flags

    Type of value to search.

    bool ignoreCase

    true to ignore case wen comparing this string to the value;otherwise,false

    Returns
    Type Description
    IRange

    First found cell, or Null if value was not found.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    string value = "value";
    IRange result =  workbook.FindStringEndsWith(value, ExcelFindType.Text, true);

    FindStringStartsWith(string, ExcelFindType)

    Returns the first occurrence that starts with the specified string value.

    Declaration
    IRange FindStringStartsWith(string findValue, ExcelFindType flags)
    Parameters
    Type Name Description
    string findValue

    Value to search.

    ExcelFindType flags

    Type of value to search.

    Returns
    Type Description
    IRange

    First found cell, or Null if value was not found.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    string value = "value";
    IRange result =  workbook.FindStringStartsWith(value, ExcelFindType.Text);

    FindStringStartsWith(string, ExcelFindType, bool)

    Returns the first occurrence that starts with the specified string value which ignores the case.

    Declaration
    IRange FindStringStartsWith(string findValue, ExcelFindType flags, bool ignoreCase)
    Parameters
    Type Name Description
    string findValue

    Value to search.

    ExcelFindType flags

    Type of value to search.

    bool ignoreCase

    true to ignore case wen comparing this string to the value;otherwise,false

    Returns
    Type Description
    IRange

    First found cell, or Null if value was not found.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    string value = "value";
    IRange result =  workbook.FindStringStartsWith(value, ExcelFindType.Text, true);

    GetMarkdownDocument(MarkdownExportOptions)

    Converts and returns the current workbook into a MarkdownDocument using the specified export options.

    Declaration
    MarkdownDocument GetMarkdownDocument(MarkdownExportOptions markdownExportOptions = null)
    Parameters
    Type Name Description
    MarkdownExportOptions markdownExportOptions

    The MarkdownExportOptions that control how the workbook is converted to Markdown.

    Returns
    Type Description
    MarkdownDocument

    A MarkdownDocument containing the Markdown representation of the workbook, generated according to the provided export options.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    var options = new MarkdownExportOptions { UseDisplayText = true };
    MarkdownDocument document = workbook.GetMarkdownDocument(options);

    GetNearestColor(Color)

    Gets the nearest color with the specified Color structure from Workbook palette.

    Declaration
    ExcelKnownColors GetNearestColor(Color color)
    Parameters
    Type Name Description
    Color color

    system color.

    Returns
    Type Description
    ExcelKnownColors

    Returns Color index from workbook palette.

    Examples

    The following code illustrates how to get the indexed color from ExcelKnownColors for the given color from Color structure.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet worksheet = workbook.Worksheets[0];
    
        //Get color
        ExcelKnownColors color = workbook.GetNearestColor(System.Drawing.Color.Red);
    
        //Set color
        worksheet["B2"].CellStyle.ColorIndex = color;
    
        //Save and dispose
        workbook.SaveAs("CellFormats.xlsx");
        workbook.Close();
    }

    GetNearestColor(int, int, int)

    Gets the nearest color with the specified red, green, and blue color values from Workbook palette.

    Declaration
    ExcelKnownColors GetNearestColor(int r, int g, int b)
    Parameters
    Type Name Description
    int r

    Red component of the color.

    int g

    Green component of the color.

    int b

    Blue component of the color.

    Returns
    Type Description
    ExcelKnownColors

    Returns Color index from workbook palette.

    Examples

    The following code illustrates how to get the indexed color from ExcelKnownColors for the given color from Color structure.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet worksheet = workbook.Worksheets[0];
    
        //Get color
        ExcelKnownColors color = workbook.GetNearestColor(255, 0, 0);
    
        //Set color
        worksheet["B2"].CellStyle.ColorIndex = color;
    
        //Save and dispose
        workbook.SaveAs("CellFormats.xlsx");
        workbook.Close();
    }

    GetPaletteColor(ExcelKnownColors)

    Returns Color object from predefined colors by its index.

    Declaration
    Color GetPaletteColor(ExcelKnownColors color)
    Parameters
    Type Name Description
    ExcelKnownColors color

    Index from palette array.

    Returns
    Type Description
    Color

    RGB Color.

    Examples

    The following code illustrates how to get the RGB color value for the specified color from ExcelKnownColors enumeration.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet worksheet = workbook.Worksheets[0];
    
        //Get color
        System.Drawing.Color color = workbook.GetPaletteColor(ExcelKnownColors.Red);
    
        //Set color
        worksheet["B2"].CellStyle.Color = color;
    
        //Save and dispose
        workbook.SaveAs("CellFormats.xlsx");
        workbook.Close();
    }

    ImportXml(Stream)

    Imports XML data into workbook from the specified XML data stream.

    Declaration
    void ImportXml(Stream stream)
    Parameters
    Type Name Description
    Stream stream

    Stream of XML document.

    MarkAsFinal()

    Marks workbook as final. Read-Only.

    Declaration
    void MarkAsFinal()

    Protect(bool, bool)

    Sets protection for workbook.

    Declaration
    void Protect(bool bIsProtectWindow, bool bIsProtectContent)
    Parameters
    Type Name Description
    bool bIsProtectWindow

    Indicates if protect workbook window.

    bool bIsProtectContent

    Indicates if protect workbook content.

    Examples

    The following code snippet illustrates how to protect the workbook.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    workbook.Protect(true, true);

    Protect(bool, bool, string)

    Sets protection for workbook with specified password.

    Declaration
    void Protect(bool bIsProtectWindow, bool bIsProtectContent, string password)
    Parameters
    Type Name Description
    bool bIsProtectWindow

    Indicates if protect workbook window.

    bool bIsProtectContent

    Indicates if protect workbook content.

    string password

    Password to protect with.

    Examples

    The following code snippet illustrates how to protect the workbook using password.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    workbook.Protect(true, true, "Password");

    Replace(string, DataColumn, bool)

    Replaces string with the specified DataColumn value.

    Declaration
    void Replace(string oldValue, DataColumn newValues, bool isFieldNamesShown)
    Parameters
    Type Name Description
    string oldValue

    String value to replace.

    DataColumn newValues

    Data table with new data.

    bool isFieldNamesShown

    Indicates whether field name must be shown.

    Examples

    The following code snippet illustrates how to replace the string value with data table.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    // create the data table
    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];
    string oldvalue = "AB2";
    // Replace the value with data column.
    workbook.Replace(oldvalue, dataColumn, true);

    Replace(string, DataTable, bool)

    Replaces string with the specified data table value.

    Declaration
    void Replace(string oldValue, DataTable newValues, bool isFieldNamesShown)
    Parameters
    Type Name Description
    string oldValue

    String value to replace.

    DataTable newValues

    Data table with new data.

    bool isFieldNamesShown

    Indicates whether field name must be shown.

    Examples

    The following code snippet illustrates how to replace the string value with data table.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    // create the data table
    System.Data.DataTable table = new System.Data.DataTable();
    table.Columns.Add("Dosage", typeof(int));
    table.Rows.Add(1);
    string oldvalue = "AB2";
    // Replace the value with data table.
    workbook.Replace(oldvalue, table, true);

    Replace(string, DateTime)

    Replaces string with the specified DateTime value.

    Declaration
    void Replace(string oldValue, DateTime newValue)
    Parameters
    Type Name Description
    string oldValue

    The string to be replaced.

    DateTime newValue

    The DateTime to replace all occurrences of oldValue.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    string oldValue = "Find";
    DateTime dateTime = DateTime.Now;
    workbook.Replace(oldValue, dateTime);

    Replace(string, double)

    Replaces string with the specified double value.

    Declaration
    void Replace(string oldValue, double newValue)
    Parameters
    Type Name Description
    string oldValue

    The string to be replaced.

    double newValue

    The double value to replace all occurrences of oldValue.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    string oldValue = "Find";
    double newValue = 9.00;
    workbook.Replace(oldValue, newValue);

    Replace(string, double[], bool)

    Replaces specified string with the specified array of double values.

    Declaration
    void Replace(string oldValue, double[] newValues, bool isVertical)
    Parameters
    Type Name Description
    string oldValue

    The string to be replaced.

    double[] newValues

    Array of new values.

    bool isVertical

    Indicates whether array should be inserted vertically.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    string oldValue = "Find";
    double[] newValues = { 1.00, 3.00 };
    workbook.Replace(oldValue, newValues, true);

    Replace(string, int[], bool)

    Replaces specified string with the specified array of int values.

    Declaration
    void Replace(string oldValue, int[] newValues, bool isVertical)
    Parameters
    Type Name Description
    string oldValue

    The string to be replaced.

    int[] newValues

    Array of new values.

    bool isVertical

    Indicates whether array should be inserted vertically.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    string oldValue = "Find";
    int[] newValues = { 1, 2 };
    workbook.Replace(oldValue, newValues, true);

    Replace(string, string)

    Replaces string with the specified another string value.

    Declaration
    void Replace(string oldValue, string newValue)
    Parameters
    Type Name Description
    string oldValue

    The string to be replaced.

    string newValue

    The string to replace all occurrences of oldValue.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    string oldValue = "Find";
    string newValue = "NewValue";
    workbook.Replace(oldValue, newValue);

    Replace(string, string, ExcelFindOptions)

    Replaces string with the specified string value based on the given ExcelFindOptions.

    Declaration
    void Replace(string oldValue, string newValue, ExcelFindOptions findOptions)
    Parameters
    Type Name Description
    string oldValue

    The string to be replaced.

    string newValue

    The string to replace all occurrences of oldValue.

    ExcelFindOptions findOptions

    Specifies the find options for the oldValue.

    Examples

    The following code snippet illustrates how to replace the string with another string.

            <pre><code class="lang-csharp">ExcelEngine excelEngine = new ExcelEngine();
    

    IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Excel2013; IWorkbook workbook = application.Workbooks.Open("Sample.xlsx"); IWorksheet sheet = workbook.Worksheets[0]; string oldValue = "Find"; string newValue = "NewValue"; sheet.Replace(oldValue, newValue, ExcelFindOptions.MatchCase);

    Replace(string, string[], bool)

    Replaces specified string with the specified array of string values.

    Declaration
    void Replace(string oldValue, string[] newValues, bool isVertical)
    Parameters
    Type Name Description
    string oldValue

    The string to be replaced.

    string[] newValues

    Array of new values.

    bool isVertical

    Indicates whether array should be inserted vertically.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    string oldValue = "Find";
    string[] newValues = { "X values", "Y values" };
    workbook.Replace(oldValue, newValues, true);

    ResetPalette()

    Recover palette to default values.

    Declaration
    void ResetPalette()
    Examples

    The following code snippets illustrates how to reset the palette.

            using (ExcelEngine excelEngine = new ExcelEngine())
            {
                //Create worksheet
                IApplication application = excelEngine.Excel;
                application.DefaultVersion = ExcelVersion.Excel2013;
                IWorkbook workbook = application.Workbooks.Create(1);
                IWorksheet worksheet = workbook.Worksheets[0];
    
                //Get colors
                System.Drawing.Color[] colors = workbook.Palette;
    
                //Check color
                Console.WriteLine(colors[2].Name);
    
                //Set color
                colors[2] = System.Drawing.Color.Yellow;
    
                //Reset palette
                workbook.ResetPalette();
    
                //Check color
                Console.WriteLine(workbook.Palette[2].Name);
    
                //Save and dispose
                workbook.SaveAs("CellFormats.xlsx");
                workbook.Close();
                Console.ReadKey();
            }
    //Output will be
    //ffff0000
    //ffff0000

    SaveAs(Stream)

    Saves workbook as stream.

    Declaration
    void SaveAs(Stream stream)
    Parameters
    Type Name Description
    Stream stream

    Stream that will receive workbook data.

    Remarks

    This method is supported on Windows Forms, WPF, ASP.NET, ASP.NET MVC, ASP.NET Core, Blazor, and Xamarin platforms.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    Stream stream = new MemoryStream();
    workbook.SaveAs(stream);

    SaveAs(Stream, ExcelSaveType)

    Saves workbook as stream with specified ExcelSaveType.

    Declaration
    void SaveAs(Stream stream, ExcelSaveType saveType)
    Parameters
    Type Name Description
    Stream stream

    Stream that will receive workbook data.

    ExcelSaveType saveType

    Type of the Excel file.

    Remarks

    This method is supported on Windows Forms, WPF, ASP.NET, ASP.NET MVC, ASP.NET Core, Blazor, and Xamarin platforms.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    Stream stream = new MemoryStream();
    workbook.SaveAs(stream, ExcelSaveType.SaveAsXLS);

    SaveAs(Stream, MarkdownExportOptions)

    Saves the workbook as a Markdown file with specified options to a stream.

    Declaration
    void SaveAs(Stream stream, MarkdownExportOptions options)
    Parameters
    Type Name Description
    Stream stream

    The stream to save to.

    MarkdownExportOptions options

    Markdown export options.

    Examples

    The following code snippet illustrates how to save a workbook as Markdown to a stream with options.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    Stream stream = new MemoryStream();
    var options = new MarkdownExportOptions { UseDisplayText = true };
    workbook.SaveAs(stream, options);

    SaveAs(Stream, string)

    Saves workbook as stream using separator. Used only for CSV files.

    Declaration
    void SaveAs(Stream stream, string separator)
    Parameters
    Type Name Description
    Stream stream

    Stream to save.

    string separator

    Denotes separator for the CSV file types.

    Remarks

    This method is supported on Windows Forms, WPF, ASP.NET, ASP.NET MVC, ASP.NET Core, Blazor, and Xamarin platforms.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    Stream stream = new MemoryStream();
    workbook.SaveAs(stream, ",");

    SaveAs(Stream, string, Encoding)

    Saves workbook as stream with given separator and encoding. Used only for CSV files.

    Declaration
    void SaveAs(Stream stream, string separator, Encoding encoding)
    Parameters
    Type Name Description
    Stream stream

    Stream to save the CSV file.

    string separator

    Denotes separator for the CSV file types.

    Encoding encoding

    The name of a character encoding that is supported by the .NET Framework.

    Remarks

    This overloaded method can be used to apply encoding to the CSV file in particular. The default encoding type is UTF-8. Other encoding types include ASCII, UTF-7, and UTF-32.

    Examples
    using(ExcelEngine engine = new ExcelEngine())
    {
      IApplication application = engine.Excel;
      IWorkbook workbook = application.Workbooks.Create(1);
      IWorksheet worksheet = workbook.Worksheets[0];
      worksheet["A1"].Text = "This";
      worksheet["B1"].Text = "is";
      worksheet["C1"].Text = "a";
      worksheet["D1"].Text = "sample";
      worksheet["E1"].Text = "to";
      worksheet["F1"].Text = "set";
      worksheet["G1"].Text = "encoding";
      MemoryStream stream = new MemoryStream();
      workbook.SaveAs(stream, ",",Encoding.Unicode);
    }

    SaveAs(string)

    Saves workbook with the specified file name.

    Declaration
    void SaveAs(string Filename)
    Parameters
    Type Name Description
    string Filename

    Name of the file.

    Remarks

    This method is supported on Windows Forms, WPF, ASP.NET and ASP.NET MVC platforms only.

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    workbook.SaveAs("Output.xls");

    SaveAs(string, MarkdownExportOptions)

    Saves the workbook as a Markdown file with specified options to a respective file path

    Declaration
    void SaveAs(string fileName, MarkdownExportOptions mdOptions)
    Parameters
    Type Name Description
    string fileName

    Output file path for the Markdown file.

    MarkdownExportOptions mdOptions

    Markdown export options (null defaults to standard options).

    Examples
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    var options = new MarkdownExportOptions { UseDisplayText = true };
    workbook.SaveAs("output.md", options);

    SaveAs(string, string)

    Saves workbook with specified file name using separator. Used only for CSV files.

    Declaration
    void SaveAs(string fileName, string separator)
    Parameters
    Type Name Description
    string fileName

    Path to save.

    string separator

    Denotes separator for the CSV file types.

    Remarks

    This method is supported on Windows Forms, WPF, ASP.NET and ASP.NET MVC platforms only.

    Examples

    The following code snippet illustrates how to save as CSV.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    workbook.SaveAs("Output.csv", ",");

    SaveAs(string, string, Encoding)

    Saves workbook with specified file name with given separator and encoding. Used only for CSV files.

    Declaration
    void SaveAs(string fileName, string separator, Encoding encoding)
    Parameters
    Type Name Description
    string fileName

    Path to save the CSV file.

    string separator

    Denotes separator for the CSV file types.

    Encoding encoding

    The name of a character encoding that is supported by the .NET Framework.

    Remarks

    This overloaded method can be used to apply encoding to the CSV file in particular. The default encoding type is UTF-8. Other encoding types include ASCII, UTF-7, and UTF-32. This method is supported on Windows Forms, WPF, ASP.NET and ASP.NET MVC platforms only.

    Examples
    using(ExcelEngine engine = new ExcelEngine())
    {
      IApplication application = engine.Excel;
      IWorkbook workbook = application.Workbooks.Create(1);
      IWorksheet worksheet = workbook.Worksheets[0];
      worksheet["A1"].Text = "This";
      worksheet["B1"].Text = "is";
      worksheet["C1"].Text = "a";
      worksheet["D1"].Text = "sample";
      worksheet["E1"].Text = "to";
      worksheet["F1"].Text = "set";
      worksheet["G1"].Text = "encoding";
      workbook.SaveAs("Output.csv", ",",Encoding.Unicode);
    }

    SaveAsHtml(Stream)

    Saves as Html to the specified stream.

    Declaration
    void SaveAsHtml(Stream stream)
    Parameters
    Type Name Description
    Stream stream

    stream that will receive html data.

    Remarks

    This method is supported on Windows Forms, WPF, ASP.NET and ASP.NET MVC platforms only.

    Examples

    The following code snippets illustrates how to save as html to the specified stream.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    Stream stream = new MemoryStream();
    workbook.SaveAsHtml(stream);

    SaveAsHtml(Stream, HtmlSaveOptions)

    Saves as Html to the specified stream based on HtmlSaveOptions.

    Declaration
    void SaveAsHtml(Stream stream, HtmlSaveOptions saveOptions)
    Parameters
    Type Name Description
    Stream stream

    stream that will receive html data.

    HtmlSaveOptions saveOptions

    Save options in html

    Remarks

    This method is supported on Windows Forms, WPF, ASP.NET and ASP.NET MVC platforms only.

    Examples

    The following code snippets illustrates how to save as html to the specified stream.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    Stream stream = new MemoryStream();
    workbook.SaveAsHtml(stream,HtmlSaveOptions.Default);

    SaveAsHtml(string)

    Saves as Html to the specified stream.

    Declaration
    void SaveAsHtml(string filename)
    Parameters
    Type Name Description
    string filename

    filename that will receive html data.

    Remarks

    This method is supported on Windows Forms, WPF, ASP.NET and ASP.NET MVC platforms only.

    Examples

    The following code snippets illustrates how to save as html to the specified stream.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    workbook.SaveAsHtml("Output.html");

    SaveAsHtml(string, HtmlSaveOptions)

    Saves as Html to specified file name based on ExcelSaveType.

    Declaration
    void SaveAsHtml(string filename, HtmlSaveOptions saveOptions)
    Parameters
    Type Name Description
    string filename

    Name of the file.

    HtmlSaveOptions saveOptions

    Save options in html

    Remarks

    This method is supported on Windows Forms, WPF, ASP.NET and ASP.NET MVC platforms only.

    Examples

    The following code snippets illustrates how to save as html to the specified file name.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    workbook.SaveAsHtml("Output.html",HtmlSaveOptions.Default);

    SaveAsJson(Stream)

    Saves the workbook to a JSON file stream.

    Declaration
    void SaveAsJson(Stream stream)
    Parameters
    Type Name Description
    Stream stream

    Stream to save into.

    SaveAsJson(Stream, IRange)

    Saves the range to a JSON file stream.

    Declaration
    void SaveAsJson(Stream stream, IRange range)
    Parameters
    Type Name Description
    Stream stream

    Stream to save into.

    IRange range

    Range to save as JSON.

    SaveAsJson(Stream, IRange, bool)

    Saves the range to a JSON file stream as schema.

    Declaration
    void SaveAsJson(Stream stream, IRange range, bool IsSchema)
    Parameters
    Type Name Description
    Stream stream

    Stream to save into.

    IRange range

    Range to save as JSON.

    bool IsSchema

    SaveAsJson(Stream, IWorksheet)

    Saves the worksheet to a JSON file stream.

    Declaration
    void SaveAsJson(Stream stream, IWorksheet worksheet)
    Parameters
    Type Name Description
    Stream stream
    IWorksheet worksheet

    SaveAsJson(Stream, IWorksheet, bool)

    Saves the worksheet to a JSON file stream as schema.

    Declaration
    void SaveAsJson(Stream stream, IWorksheet worksheet, bool isSchema)
    Parameters
    Type Name Description
    Stream stream
    IWorksheet worksheet
    bool isSchema

    SaveAsJson(Stream, bool)

    Saves the workbook to a JSON file stream as schema.

    Declaration
    void SaveAsJson(Stream stream, bool isSchema)
    Parameters
    Type Name Description
    Stream stream

    Stream to save into.

    bool isSchema

    SaveAsJson(string)

    Saves the workbook to a JSON file.

    Declaration
    void SaveAsJson(string filename)
    Parameters
    Type Name Description
    string filename

    File name to save into.

    SaveAsJson(string, IRange)

    Saves the range to a JSON file.

    Declaration
    void SaveAsJson(string filename, IRange range)
    Parameters
    Type Name Description
    string filename

    File name to save into.

    IRange range

    Range to save as JSON.

    SaveAsJson(string, IRange, bool)

    Saves the range to a JSON file as schema.

    Declaration
    void SaveAsJson(string filename, IRange range, bool isSchema)
    Parameters
    Type Name Description
    string filename

    File name to save into.

    IRange range

    Range to save as JSON.

    bool isSchema

    SaveAsJson(string, IWorksheet)

    Saves the worksheet to a JSON file.

    Declaration
    void SaveAsJson(string filename, IWorksheet worksheet)
    Parameters
    Type Name Description
    string filename
    IWorksheet worksheet

    SaveAsJson(string, IWorksheet, bool)

    Saves the worksheet to a JSON file as schema.

    Declaration
    void SaveAsJson(string filename, IWorksheet worksheet, bool isSchema)
    Parameters
    Type Name Description
    string filename
    IWorksheet worksheet
    bool isSchema

    SaveAsJson(string, bool)

    Saves the workbook to a JSON file as schema.

    Declaration
    void SaveAsJson(string filename, bool isSchema)
    Parameters
    Type Name Description
    string filename

    File name to save into.

    bool isSchema

    SaveAsXml(Stream, ExcelXmlSaveType)

    Saves workbook as stream with specified ExcelXmlSaveType.

    Declaration
    void SaveAsXml(Stream stream, ExcelXmlSaveType saveType)
    Parameters
    Type Name Description
    Stream stream

    Stream to save into.

    ExcelXmlSaveType saveType

    Xml save type.

    Remarks

    This method is supported on Windows Forms, WPF, ASP.NET and ASP.NET MVC platforms only.

    Examples

    The following code snippet illustrates how to save the stream as Xml.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    Stream stream = new MemoryStream();
    workbook.SaveAsXml(stream, ExcelXmlSaveType.MSExcel);

    SaveAsXml(string, ExcelXmlSaveType)

    Saves workbook with the specified file name and ExcelXmlSaveType.

    Declaration
    void SaveAsXml(string strFileName, ExcelXmlSaveType saveType)
    Parameters
    Type Name Description
    string strFileName

    File name to save into.

    ExcelXmlSaveType saveType

    Xml save type.

    Remarks

    This method is supported on Windows Forms, WPF, ASP.NET and ASP.NET MVC platforms only.

    Examples

    The following code snippet illustrates how to save as Xml.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    workbook.SaveAsXml("Output.xml", ExcelXmlSaveType.MSExcel);

    SetColorOrGetNearest(Color)

    Sets the color or Gets nearest color.

    Declaration
    ExcelKnownColors SetColorOrGetNearest(Color color)
    Parameters
    Type Name Description
    Color color

    System color

    Returns
    Type Description
    ExcelKnownColors

    Color index from workbook palette.

    Remarks

    If there is at least one free color, define a new color; if not, search for the closest one to the specified Color structure from Workbook palette.

    Examples

    The following code illustrates how to get the indexed color from ExcelKnownColors for the given color from Color structure.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet worksheet = workbook.Worksheets[0];
    
        //Get color
        ExcelKnownColors color = workbook.SetColorOrGetNearest(System.Drawing.Color.Red);
    
        //Set color
        worksheet["B2"].CellStyle.ColorIndex = color;
    
        //Save and dispose
        workbook.SaveAs("CellFormats.xlsx");
        workbook.Close();
    }

    SetColorOrGetNearest(int, int, int)

    Sets the color or Gets nearest color with the specified red, green and blue color value.

    Declaration
    ExcelKnownColors SetColorOrGetNearest(int r, int g, int b)
    Parameters
    Type Name Description
    int r

    Red component of the color.

    int g

    Green component of the color.

    int b

    Blue component of the color.

    Returns
    Type Description
    ExcelKnownColors

    Color index from workbook palette.

    Remarks

    If there is at least one free color, define a new color; if not, search for the closest one to the specified by red, green, and blue values color from Workbook palette.

    Examples

    The following code snippet illustrates how to set color or get nearest color by red,green and blue.

    workbook.SetColorOrGetNearest(123,45,56);

    The following code illustrates how to get the indexed color from ExcelKnownColors for the given color from Color structure.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet worksheet = workbook.Worksheets[0];
    
        //Get color
        ExcelKnownColors color = workbook.SetColorOrGetNearest(255, 0, 0);
    
        //Set color
        worksheet["B2"].CellStyle.ColorIndex = color;
    
        //Save and dispose
        workbook.SaveAs("CellFormats.xlsx");
        workbook.Close();
    }

    SetPaletteColor(int, Color)

    Sets the palette color for the given index.

    Declaration
    void SetPaletteColor(int index, Color color)
    Parameters
    Type Name Description
    int index

    Index of Color in array.

    Color color

    New color which must be set.

    Examples

    The following code snippet illustrates how to set palette color.

    using (ExcelEngine excelEngine = new ExcelEngine())
    {
        //Create worksheet
        IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        IWorkbook workbook = application.Workbooks.Create(1);
        IWorksheet worksheet = workbook.Worksheets[0];
    
        //Set palette color
        workbook.SetPaletteColor(10, System.Drawing.Color.Red);
    
        //Set color
        worksheet["B2"].CellStyle.Color = workbook.Palette[10];
    
        //Save and dispose
        workbook.SaveAs("CellFormats.xlsx");
        workbook.Close();
    }

    SetSeparators(char, char)

    Sets separators for formula parsing.

    Declaration
    void SetSeparators(char argumentsSeparator, char arrayRowsSeparator)
    Parameters
    Type Name Description
    char argumentsSeparator

    Arguments separator to set.

    char arrayRowsSeparator

    Array rows separator to set.

    Examples

    The following code illustrates how to set separators.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    workbook.SetSeparators(',', ';');

    SetWriteProtectionPassword(string)

    Sets write protection for workbook using password.

    Declaration
    void SetWriteProtectionPassword(string password)
    Parameters
    Type Name Description
    string password

    Password to set.

    Examples

    The following code snippet illustrates how to set write protection password.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
     workbook.SetWriteProtectionPassword("Password");

    Unprotect()

    Unprotects workbook.

    Declaration
    void Unprotect()
    Examples

    The following code illustrates how to unprotect a workbook.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    //Unprotects the password.
    workbook.Unprotect();

    Unprotect(string)

    Unprotects workbook using password.

    Declaration
    void Unprotect(string password)
    Parameters
    Type Name Description
    string password

    Password to unprotect workbook.

    Remarks

    Throws ArgumentOutOfRangeException when password is wrong.

    Examples

    The following code illustrates how to unprotect a workbook using password.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
    //Unprotects the password using password.
    workbook.Unprotect("Password");

    Events

    OnFileSaved

    This event is fired after workbook is successfully saved.

    Declaration
    event EventHandler OnFileSaved
    Event Type
    Type
    EventHandler

    OnReadOnlyFile

    This event is fired when trying to save to a Read-only file.

    Declaration
    event ReadOnlyFileEventHandler OnReadOnlyFile
    Event Type
    Type
    ReadOnlyFileEventHandler
    In this article
    Back to top Generated by DocFX
    Copyright © 2001 - 2026 Syncfusion Inc. All Rights Reserved