GemBox.Spreadsheet
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    CalculationOptions Class

    Namespace:
    GemBox.Spreadsheet.CalculationEngine
    Assembly:
    GemBox.Spreadsheet.dll

    Class represents various calculation engine options.

    • C#
    • VB.NET
    public sealed class CalculationOptions
    Public NotInheritable Class CalculationOptions
    Inheritance:
    System.Object
    CalculationOptions

    Properties

    CalculationMode

    Gets or sets the calculation mode.

    • C#
    • VB.NET
    public CalculationMode CalculationMode { get; set; }
    Public Property CalculationMode As CalculationMode
    Property Value
    CalculationMode

    The calculation mode.

    Remarks

    The property has no effect on the calculation performed by one of the Calculate() methods.

    CultureInfo

    Gets or sets the culture used during the calculation.

    The default value is System.Globalization.CultureInfo.CurrentCulture.

    • C#
    • VB.NET
    public CultureInfo CultureInfo { get; set; }
    Public Property CultureInfo As CultureInfo
    Property Value
    System.Globalization.CultureInfo

    The culture used during the calculation.

    Remarks
    important

    .NET 5.0 and later versions use International Components for Unicode (ICU) libraries for globalization functionality when running on Windows 10 May 2019 Update or later.

    When running your application on .NET 5.0, you might see changes in calculation of some formulas, for example, when formatting currency (if CultureInfo is specified without country or region) or negative currency (because System.Globalization.NumberFormatInfo.CurrencyNegativePattern might differ between ICU and NLS which is used on .NET Framework and .NET Core 3.1 and lower).

    For more information about this .NET 5.0 breaking change and how to revert to using NLS globalization APIs, see the Globalization APIs use ICU libraries on Windows page.

    EnableCaching

    Gets or sets the value indicating whether the intermediate results of formulas should be cached. For some files, caching can decrease the time necessary to calculate formulas.

    • C#
    • VB.NET
    public bool EnableCaching { get; set; }
    Public Property EnableCaching As Boolean
    Property Value
    System.Boolean

    The value indicates whether the intermediate results of formulas should be cached. The default value is false.

    Remarks

    Use this property with caution, however. For most files, caching will not improve performance, but hurt it. Caching is useful only when there are repeated formulas (or expressions) that are always evaluated to the same result. So, even though some formulas can look the same, their results will be different; Thus, they are inapplicable for caching. An example of such a formula is

    =MAX(ROW(), COLUMN())
    , whose result will not be cached, because the result depends on the cell where the formula is placed.

    EnableIterativeCalculation

    Gets or sets a value indicating whether iterative calculation is enabled.

    • C#
    • VB.NET
    public bool EnableIterativeCalculation { get; set; }
    Public Property EnableIterativeCalculation As Boolean
    Property Value
    System.Boolean

    True if iterative calculation is enabled; otherwise, false.

    Remarks

    A circular reference is when a formula refers to itself directly or indirectly. Setting this property to true will allow circular references in cell formulas; otherwise a SpreadsheetParserException will be thrown for every circular reference in the calculation process.

    MaximumChange

    Gets or sets the maximum calculation change.

    • C#
    • VB.NET
    public double MaximumChange { get; set; }
    Public Property MaximumChange As Double
    Property Value
    System.Double

    The maximum calculation change.

    Remarks

    This property defines the maximum value change in circular reference iterations after which the calculation process is stopped.

    MaximumIterations

    Gets or sets the maximum calculation iterations.

    • C#
    • VB.NET
    public int MaximumIterations { get; set; }
    Public Property MaximumIterations As Integer
    Property Value
    System.Int32

    The maximum calculation iterations.

    Remarks

    This property defines the maximum number of formula recalculations for a circular reference.

    ResolveMathFunctionsWithDecimalType

    Gets or sets a value indicating whether mathematical operations should be resolved using System.Decimal values instead of System.Double values for increased precision, at the expense of performance.

    • C#
    • VB.NET
    public bool ResolveMathFunctionsWithDecimalType { get; set; }
    Public Property ResolveMathFunctionsWithDecimalType As Boolean
    Property Value
    System.Boolean

    True if mathematical operations should be resolved using decimal values; otherwise, false.

    Remarks

    The double type can on some rare occasions not be precise enough to represent a number correctly, for example, 78.975 as a System.Double is actually 78.974999999999994315658113919198513031005859375.
    Calling System.Math.Round(System.Decimal,System.Int32,System.MidpointRounding) with (System.Double)78.975, 2 and System.MidpointRounding.AwayFromZero will result in 78.97, which is incorrect.
    Calling System.Math.Round(System.Decimal,System.Int32,System.MidpointRounding) with (System.Decimal)78.975, 2 and System.MidpointRounding.AwayFromZero will result in 78.98, which is correct.
    If this option is set to true, mathematical operations that could trigger problems when used with double (for example, round) will be resolved with decimal, which can reduce performance.

    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.