# CustomFunction

## Content

<div class="docapp-java-api-doc-main"><style>:not(h1, h2, h3, h4, h5, h6)>code,
:not(h1, h2, h3, h4, h5, h6)>tt {
    font-size: 14px;
    padding-top: 4px;
    margin-top: 8px;
    line-height: 1.4em;
}

.summary-table dt code {
    font-size: 14px;
    vertical-align: top;
    padding-top: 4px;
}

.tab {
    background-color: #0066FF;
    color: #ffffff;
    padding: 8px;
    width: 5em;
    font-weight: bold;
}

/*
 * Styles for page header and footer.
 */
.title {
    color: #2c4557;
    margin: 10px 0;
}

.sub-title {
    margin: 5px 0 0 0;
}

.header ul {
    margin: 0 0 15px 0;
    padding: 0;
}

.header ul li,
.footer ul li {
    list-style: none;
}

/*
 * Styles for headings.
 */
.summary h2,
.details h2,
h2,
.block-list h2 {
    padding: 0;
    margin: 15px 0;
}

.summary h3,
.details h3,
.summary .inherited-list h2 {
    background-color: var(--ds-product-color);
    color: #fff;
    border: 1px solid #d0d9e0;
    padding: 7px 5px;
}

.summary h3 a,
.details h3 a,
.summary .inherited-list h2 a {
    color: #fff !important;
}
/*
 * Styles for page layout containers.
 */
dl.notes>dt {
    font-size: 12px;
    font-weight: bold;
    margin: 10px 0 0 0;
    color: #4E4E4E;
}

dl.notes>dd {
    margin: 5px 10px 10px 0;
    font-size: 14px;
}

dl.name-value>dt {
    margin-left: 1px;
    font-size: 1.1em;
    display: inline;
    font-weight: bold;
}

dl.name-value>dd {
    margin: 0 0 0 1px;
    font-size: 1.1em;
    display: inline;
}

/*
 * Styles for lists.
 */
li.circle {
    list-style: circle;
}

ul.horizontal li {
    display: inline;
    font-size: 0.9em;
}

div.inheritance {
    margin: 0;
    padding: 0;
}

div.inheritance div.inheritance {
    margin-left: 2em;
}

ul.block-list,
ul.details-list,
ul.member-list,
ul.summary-list {
    margin: 10px 0 10px 0;
    padding: 0;
}

ul.block-list>li,
ul.details-list>li,
ul.member-list>li,
ul.summary-list>li {
    list-style: none;
    margin-bottom: 15px;
    line-height: 1.4;
}

.summary-table dl,
.summary-table dl dt,
.summary-table dl dd {
    margin-top: 0;
    margin-bottom: 1px;
}

ul.see-list,
ul.see-list-long {
    padding-left: 0;
    list-style: none;
}

ul.see-list li {
    display: inline;
}

ul.see-list li:not(:last-child):after,
ul.see-list-long li:not(:last-child):after {
    content: ", ";
    white-space: pre-wrap;
}

/*
 * Styles for tables.
 */
.summary-table,
.details-table {
    width: 100%;
    border-spacing: 0;
    border-left: 1px solid #EEE;
    border-right: 1px solid #EEE;
    border-bottom: 1px solid #EEE;
    padding: 0;
}

.caption {
    position: relative;
    text-align: left;
    background-repeat: no-repeat;
    color: #253441;
    font-weight: bold;
    clear: none;
    overflow: hidden;
    padding: 0;
    padding-top: 10px;
    padding-left: 1px;
    margin: 0;
    white-space: pre;
}

.caption a:link,
.caption a:visited {
    color: #1f389c;
}

.caption a:hover,
.caption a:active {
    color: #FFFFFF;
}

.caption span {
    white-space: nowrap;
    padding-top: 5px;
    padding-left: 12px;
    padding-right: 12px;
    padding-bottom: 7px;
    display: inline-block;
    background-color: var(--ds-product-color);
    color: #fff;
    border: none;
}

div.table-tabs {
    padding: 10px 0 0 1px;
    margin: 0;
}

div.table-tabs>button {
    border: none;
    cursor: pointer;
    padding: 5px 12px 7px 12px;
    font-weight: bold;
    margin-right: 3px;
}

div.table-tabs>button.active-table-tab {
    background: var(--ds-product-color);
    color: #fff;
}

div.table-tabs>button.table-tab {
    background: var(--ds-product-color);
    color: #FFFFFF;
    border-bottom: 1px solid #eee;
}

.two-column-summary {
    display: grid;
    grid-template-columns: minmax(15%, max-content) minmax(15%, auto);
}

.three-column-summary {
    display: grid;
    grid-template-columns: minmax(10%, max-content) minmax(15%, max-content) minmax(15%, auto);
}

.four-column-summary {
    display: grid;
    grid-template-columns: minmax(10%, max-content) minmax(10%, max-content) minmax(10%, max-content) minmax(10%, auto);
}

@media screen and (max-width: 600px) {
    .two-column-summary {
        display: grid;
        grid-template-columns: 1fr;
    }
}

@media screen and (max-width: 800px) {
    .three-column-summary {
        display: grid;
        grid-template-columns: minmax(10%, max-content) minmax(25%, auto);
    }

    .three-column-summary .col-last {
        grid-column-end: span 2;
    }
}

@media screen and (max-width: 1000px) {
    .four-column-summary {
        display: grid;
        grid-template-columns: minmax(15%, max-content) minmax(15%, auto);
    }
}

.summary-table>div,
.details-table>div {
    text-align: left;
    padding: 8px 3px 3px 7px;
}

.col-first,
.col-second,
.col-last,
.col-constructor-name,
.col-summary-item-name {
    vertical-align: top;
    padding-right: 0;
    padding-top: 8px;
    padding-bottom: 3px;
}

.table-header {
    background: var(--ds-product-color);
    color: #fff;
    font-weight: bold;
}

.col-first,
.col-first {
    font-size: 13px;
}

.col-second,
.col-second,
.col-last,
.col-constructor-name,
.col-summary-item-name,
.col-last {
    font-size: 13px;
}

.col-first,
.col-second,
.col-constructor-name {
    vertical-align: top;
    overflow: auto;
}

.col-last {
    white-space: normal;
}

.col-first a:link,
.col-first a:visited,
.col-second a:link,
.col-second a:visited,
.col-first a:link,
.col-first a:visited,
.col-second a:link,
.col-second a:visited,
.col-constructor-name a:link,
.col-constructor-name a:visited,
.col-summary-item-name a:link,
.col-summary-item-name a:visited,
.constant-values-container a:link,
.constant-values-container a:visited,
.all-classes-container a:link,
.all-classes-container a:visited,
.all-packages-container a:link,
.all-packages-container a:visited {
    font-weight: bold;
}

.table-sub-heading-color {
    background-color: #EEEEFF;
}

.even-row-color,
.even-row-color .table-header {
    background-color: #FFFFFF;
}

.odd-row-color,
.odd-row-color .table-header {
    background-color: #EEEEEF;
}

/*
 * Styles for contents.
 */
.deprecated-content {
    margin: 0;
    padding: 10px 0;
}

div.block {
    font-size: 14px;
}

.col-last div {
    padding-top: 0;
}

.col-last a {
    padding-bottom: 3px;
}

.module-signature,
.package-signature,
.type-signature,
.member-signature {
    font-size: 14px;
    margin: 14px 0;
    white-space: pre-wrap;
}

.module-signature,
.package-signature,
.type-signature {
    margin-top: 0;
}

.member-signature .type-parameters-long,
.member-signature .parameters,
.member-signature .exceptions {
    display: inline-block;
    vertical-align: top;
    white-space: pre;
}

.member-signature .type-parameters {
    white-space: normal;
}

/*
 * Styles for formatting effect.
 */
.source-line-no {
    color: green;
    padding: 0 30px 0 0;
}

h1.hidden {
    visibility: hidden;
    overflow: hidden;
    font-size: 10px;
}

.block {
    display: block;
    margin: 0 10px 5px 0;
    color: #474747;
}

.deprecated-label,
.descfrm-type-label,
.implementation-label,
.member-name-label,
.member-name-link,
.module-label-in-package,
.module-label-in-type,
.override-specify-label,
.package-label-in-type,
.package-hierarchy-label,
.type-name-label,
.type-name-link,
.search-tag-link,
.preview-label {
    font-weight: bold;
}

.deprecation-block {
    font-size: 14px;
    border-style: solid;
    border-width: thin;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 10px;
    margin-right: 10px;
    display: inline-block;
}

.preview-block {
    font-size: 14px;
    border-style: solid;
    border-width: thin;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 10px;
    margin-right: 10px;
    display: inline-block;
}

/*
 * Styles for user-provided tables.
 *
 * borderless:
 *      No borders, vertical margins, styled caption.
 *      This style is provided for use with existing doc comments.
 *      In general, borderless tables should not be used for layout purposes.
 *
 * plain:
 *      Plain borders around table and cells, vertical margins, styled caption.
 *      Best for small tables or for complex tables for tables with cells that span
 *      rows and columns, when the "striped" style does not work well.
 *
 * striped:
 *      Borders around the table and vertical borders between cells, striped rows,
 *      vertical margins, styled caption.
 *      Best for tables that have a header row, and a body containing a series of simple rows.
 */

table.borderless,
table.plain,
table.striped {
    margin-top: 10px;
    margin-bottom: 10px;
}

table.borderless>caption,
table.plain>caption,
table.striped>caption {
    font-weight: bold;
    font-size: smaller;
}

table.borderless th,
table.borderless td,
table.plain th,
table.plain td,
table.striped th,
table.striped td {
    padding: 2px 5px;
}

table.borderless,
table.borderless>thead>tr>th,
table.borderless>tbody>tr>th,
table.borderless>tr>th,
table.borderless>thead>tr>td,
table.borderless>tbody>tr>td,
table.borderless>tr>td {
    border: none;
}

table.borderless>thead>tr,
table.borderless>tbody>tr,
table.borderless>tr {
    background-color: transparent;
}

table.plain {
    border-collapse: collapse;
    border: 1px solid black;
}

table.plain>thead>tr,
table.plain>tbody tr,
table.plain>tr {
    background-color: transparent;
}

table.plain>thead>tr>th,
table.plain>tbody>tr>th,
table.plain>tr>th,
table.plain>thead>tr>td,
table.plain>tbody>tr>td,
table.plain>tr>td {
    border: 1px solid black;
}

table.striped {
    border-collapse: collapse;
    border: 1px solid black;
}

table.striped>thead {
    background-color: #E3E3E3;
}

table.striped>thead>tr>th,
table.striped>thead>tr>td {
    border: 1px solid black;
}

table.striped>tbody>tr:nth-child(even) {
    background-color: #EEE
}

table.striped>tbody>tr:nth-child(odd) {
    background-color: #FFF
}

table.striped>tbody>tr>th,
table.striped>tbody>tr>td {
    border-left: 1px solid black;
    border-right: 1px solid black;
}

table.striped>tbody>tr>th {
    font-weight: normal;
}
</style><h1>Class CustomFunction</h1>
<!-- ======== START OF CLASS DATA ======== -->

<div class="inheritance" title="Inheritance Tree"><a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang">java.lang.Object</a>
<div class="inheritance">com.grapecity.documents.excel.CustomFunction</div>
</div>
<section class="class-description" id="class-description">
<dl class="notes">
<dt>Direct Known Subclasses:</dt>
<dd><code><a href="AsyncCustomFunction.html" title="class in com.grapecity.documents.excel">AsyncCustomFunction</a></code></dd>
</dl>
<hr>
<div class="type-signature"><span class="modifiers">public abstract class </span><span class="element-name type-name-label">CustomFunction</span>
<span class="extends-implements">extends <a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang">Object</a></span></div>
<div class="block">Represents the base type for a custom function. <p>Derive from this abstract class to define spreadsheet functions that behave like built-in  formula functions in GcExcel. A custom function supplies its function name, return type, and  optional parameter metadata through one of the  <code>CustomFunction</code> constructors, and must implement  <a href="#evaluate(java.lang.Object%5B%5D,com.grapecity.documents.excel.ICalcContext)"><code>evaluate(Object[],ICalcContext)</code></a> to calculate the result.</p><p>After a derived function is created, register it by using  <a href="Workbook.html#AddCustomFunction(com.grapecity.documents.excel.CustomFunction)"><code>Workbook.AddCustomFunction(CustomFunction)</code></a> or <a href="Workbook.html#AddCustomFunction(com.grapecity.documents.excel.CustomFunction,boolean)"><code>Workbook.AddCustomFunction(CustomFunction,boolean)</code></a> before using it in formulas.</p><p>Custom functions can be configured to participate in calculation caching and error  propagation. Use  <a href="#setIsVolatile(boolean)"><code>setIsVolatile(boolean)</code></a> to control whether repeated calls with the same arguments can reuse cached results, and use  <a href="#setAcceptErrors(boolean)"><code>setAcceptErrors(boolean)</code></a> to control whether error values such as  <code>#N/A</code> or <code>#VALUE!</code> are passed to the function for handling. By default, custom functions are not volatile and do not accept error arguments.</p> <p>This type is the synchronous custom-function base class. For asynchronous evaluation  scenarios, use  <a href="AsyncCustomFunction.html" title="class in com.grapecity.documents.excel"><code>AsyncCustomFunction</code></a>.</p>
<pre><code data-language="Java">
 CustomFunction function = new CustomFunction(
     "ADD2",
     FunctionValueType.Number,
     new Parameter[] {
         new Parameter(FunctionValueType.Number),
         new Parameter(FunctionValueType.Number)
     }) {
     public Object evaluate(Object[] arguments, ICalcContext context) {
         double left = ((Number) arguments[0]).doubleValue();
         double right = ((Number) arguments[1]).doubleValue();
         return left + right;
     }
 };
 Workbook.AddCustomFunction(function);
 worksheet.getRange("A1").setFormula("=ADD2(10,20)");
 Object sum = worksheet.getRange("A1").getValue();
 </code></pre></div>
</section>
<section class="summary">
<ul class="summary-list">
<!-- =========== FIELD SUMMARY =========== -->
<li>
<section class="field-summary" id="field-summary">
<h2>Field Summary</h2>
<div class="caption"><span>Fields</span></div>
<div class="summary-table three-column-summary">
<div class="table-header col-first">Modifier and Type</div>
<div class="table-header col-second">Field</div>
<div class="table-header col-last">Description</div>
<div class="col-first even-row-color"><code><a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang">String</a></code></div>
<div class="col-second even-row-color"><code><a class="member-name-link" href="#name">name</a></code></div>
<div class="col-last even-row-color">&nbsp;</div>
</div>
</section>
</li>
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<li>
<section class="constructor-summary" id="constructor-summary">
<h2>Constructor Summary</h2>
<div class="caption"><span>Constructors</span></div>
<div class="summary-table two-column-summary">
<div class="table-header col-first">Constructor</div>
<div class="table-header col-last">Description</div>
<div class="col-constructor-name even-row-color"><code><a class="member-name-link" href="#%3Cinit%3E(java.lang.String,com.grapecity.documents.excel.FunctionValueType)">CustomFunction</a><wbr>(<a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang">String</a>&nbsp;name,
 <a href="FunctionValueType.html" title="enum class in com.grapecity.documents.excel">FunctionValueType</a>&nbsp;result)</code></div>
<div class="col-last even-row-color">
<div class="block">Initializes an instance of a custom function.</div>
</div>
<div class="col-constructor-name odd-row-color"><code><a class="member-name-link" href="#%3Cinit%3E(java.lang.String,com.grapecity.documents.excel.FunctionValueType,com.grapecity.documents.excel.Parameter%5B%5D)">CustomFunction</a><wbr>(<a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang">String</a>&nbsp;name,
 <a href="FunctionValueType.html" title="enum class in com.grapecity.documents.excel">FunctionValueType</a>&nbsp;result,
 <a href="Parameter.html" title="class in com.grapecity.documents.excel">Parameter</a>[]&nbsp;parameters)</code></div>
<div class="col-last odd-row-color">
<div class="block">Initializes an instance of a custom function.</div>
</div>
<div class="col-constructor-name even-row-color"><code><a class="member-name-link" href="#%3Cinit%3E(java.lang.String,java.lang.String,com.grapecity.documents.excel.FunctionValueType,com.grapecity.documents.excel.Parameter%5B%5D)">CustomFunction</a><wbr>(<a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang">String</a>&nbsp;name,
 <a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang">String</a>&nbsp;description,
 <a href="FunctionValueType.html" title="enum class in com.grapecity.documents.excel">FunctionValueType</a>&nbsp;result,
 <a href="Parameter.html" title="class in com.grapecity.documents.excel">Parameter</a>[]&nbsp;parameters)</code></div>
<div class="col-last even-row-color">
<div class="block">Initializes an instance of a custom function.</div>
</div>
</div>
</section>
</li>
<!-- ========== METHOD SUMMARY =========== -->
<li>
<section class="method-summary" id="method-summary">
<h2>Method Summary</h2>
<div id="method-summary-table">
<div aria-orientation="horizontal" class="table-tabs" role="tablist"><button aria-controls="method-summary-table.tabpanel" aria-selected="true" class="active-table-tab" id="method-summary-table-tab0" onclick="show('method-summary-table', 'method-summary-table', 3)" onkeydown="switchTab(event)" role="tab" tabindex="0">All Methods</button><button aria-controls="method-summary-table.tabpanel" aria-selected="false" class="table-tab" id="method-summary-table-tab2" onclick="show('method-summary-table', 'method-summary-table-tab2', 3)" onkeydown="switchTab(event)" role="tab" tabindex="-1">Instance Methods</button><button aria-controls="method-summary-table.tabpanel" aria-selected="false" class="table-tab" id="method-summary-table-tab3" onclick="show('method-summary-table', 'method-summary-table-tab3', 3)" onkeydown="switchTab(event)" role="tab" tabindex="-1">Abstract Methods</button><button aria-controls="method-summary-table.tabpanel" aria-selected="false" class="table-tab" id="method-summary-table-tab4" onclick="show('method-summary-table', 'method-summary-table-tab4', 3)" onkeydown="switchTab(event)" role="tab" tabindex="-1">Concrete Methods</button></div>
<div id="method-summary-table.tabpanel" role="tabpanel">
<div aria-labelledby="method-summary-table-tab0" class="summary-table three-column-summary">
<div class="table-header col-first">Modifier and Type</div>
<div class="table-header col-second">Method</div>
<div class="table-header col-last">Description</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>abstract <a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang">Object</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a class="member-name-link" href="#evaluate(java.lang.Object%5B%5D,com.grapecity.documents.excel.ICalcContext)">evaluate</a><wbr>(<a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang">Object</a>[]&nbsp;arguments,
 <a href="ICalcContext.html" title="interface in com.grapecity.documents.excel">ICalcContext</a>&nbsp;context)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3">
<div class="block">Calculate the function.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>boolean</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a class="member-name-link" href="#getAcceptErrors()">getAcceptErrors</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Gets whether the function accepts error values as arguments.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>boolean</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a class="member-name-link" href="#getIsVolatile()">getIsVolatile</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Gets whether this custom function is volatile.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a class="member-name-link" href="#setAcceptErrors(boolean)">setAcceptErrors</a><wbr>(boolean&nbsp;acceptErrors)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Sets whether the function accepts error values as arguments.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a class="member-name-link" href="#setIsVolatile(boolean)">setIsVolatile</a><wbr>(boolean&nbsp;aVolatile)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Sets whether this custom function is volatile.</div>
</div>
</div>
</div>
</div>
<div class="inherited-list">
<h3 id="methods-inherited-from-class-java.lang.Object">Methods inherited from class&nbsp;java.lang.<a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang">Object</a></h3>
<code><a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#clone()" title="class or interface in java.lang">clone</a>, <a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang">equals</a>, <a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#finalize()" title="class or interface in java.lang">finalize</a>, <a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#getClass()" title="class or interface in java.lang">getClass</a>, <a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#hashCode()" title="class or interface in java.lang">hashCode</a>, <a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#notify()" title="class or interface in java.lang">notify</a>, <a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#notifyAll()" title="class or interface in java.lang">notifyAll</a>, <a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#toString()" title="class or interface in java.lang">toString</a>, <a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#wait()" title="class or interface in java.lang">wait</a>, <a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#wait(long)" title="class or interface in java.lang">wait</a>, <a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#wait(long,int)" title="class or interface in java.lang">wait</a></code></div>
</section>
</li>
</ul>
</section>
<section class="details">
<ul class="details-list">
<!-- ============ FIELD DETAIL =========== -->
<li>
<section class="field-details" id="field-detail">
<h2>Field Details</h2>
<ul class="member-list">
<li>
<section class="detail" id="name">
<h3>name</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang">String</a></span>&nbsp;<span class="element-name">name</span></div>
</section>
</li>
</ul>
</section>
</li>
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<li>
<section class="constructor-details" id="constructor-detail">
<h2>Constructor Details</h2>
<ul class="member-list">
<li>
<section class="detail" id="<init>(java.lang.String,com.grapecity.documents.excel.FunctionValueType)">
<h3>CustomFunction</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="element-name">CustomFunction</span><wbr><span class="parameters">(<a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang">String</a>&nbsp;name,
 <a href="FunctionValueType.html" title="enum class in com.grapecity.documents.excel">FunctionValueType</a>&nbsp;result)</span></div>
<div class="block">Initializes an instance of a custom function.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>name</code> - The name of the custom function.</dd>
<dd><code>result</code> - Specifies the return type for the custom function.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="<init>(java.lang.String,com.grapecity.documents.excel.FunctionValueType,com.grapecity.documents.excel.Parameter[])">
<h3>CustomFunction</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="element-name">CustomFunction</span><wbr><span class="parameters">(<a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang">String</a>&nbsp;name,
 <a href="FunctionValueType.html" title="enum class in com.grapecity.documents.excel">FunctionValueType</a>&nbsp;result,
 <a href="Parameter.html" title="class in com.grapecity.documents.excel">Parameter</a>[]&nbsp;parameters)</span></div>
<div class="block">Initializes an instance of a custom function. <p>This constructor passes  <code>null</code> as the description to <a href="#%3Cinit%3E(java.lang.String,java.lang.String,com.grapecity.documents.excel.FunctionValueType,com.grapecity.documents.excel.Parameter%5B%5D)"><code>CustomFunction(String,String,FunctionValueType,Parameter[])</code></a>.</p></div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>name</code> - The name of the custom function. Must not be <code>null</code> or empty.</dd>
<dd><code>result</code> - Specifies the return type for the custom function.</dd>
<dd><code>parameters</code> - Specifies the parameters for the custom function. Can be <code>null</code>.</dd>
<dt>Throws:</dt>
<dd><code><a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang">IllegalArgumentException</a></code> - if <code>name</code> is <code>null</code> or empty.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="<init>(java.lang.String,java.lang.String,com.grapecity.documents.excel.FunctionValueType,com.grapecity.documents.excel.Parameter[])">
<h3>CustomFunction</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="element-name">CustomFunction</span><wbr><span class="parameters">(<a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang">String</a>&nbsp;name,
 <a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang">String</a>&nbsp;description,
 <a href="FunctionValueType.html" title="enum class in com.grapecity.documents.excel">FunctionValueType</a>&nbsp;result,
 <a href="Parameter.html" title="class in com.grapecity.documents.excel">Parameter</a>[]&nbsp;parameters)</span></div>
<div class="block">Initializes an instance of a custom function.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>name</code> - The name of the custom function.</dd>
<dd><code>description</code> - The description of the custom function.</dd>
<dd><code>result</code> - Specifies the return type for the custom function.</dd>
<dd><code>parameters</code> - Specifies the parmeters for the custom function.</dd>
</dl>
</section>
</li>
</ul>
</section>
</li>
<!-- ============ METHOD DETAIL ========== -->
<li>
<section class="method-details" id="method-detail">
<h2>Method Details</h2>
<ul class="member-list">
<li>
<section class="detail" id="setAcceptErrors(boolean)">
<h3>setAcceptErrors</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">setAcceptErrors</span><wbr><span class="parameters">(boolean&nbsp;acceptErrors)</span></div>
<div class="block">Sets whether the function accepts error values as arguments. <p>If this property is set to  <code>true</code>, error values such as  <code>#N/A</code> and <code>#VALUE!</code> can be passed to <a href="#evaluate(java.lang.Object%5B%5D,com.grapecity.documents.excel.ICalcContext)"><code>evaluate(Object[],ICalcContext)</code></a> for custom handling. If it is set to  <code>false</code>, the calculation engine returns the error immediately  instead of passing the error argument to the custom function.</p>
<pre><code data-language="Java">
 CustomFunction function = new CustomFunction(
     "HANDLEERROR",
     FunctionValueType.Text,
     new Parameter[] { new Parameter(FunctionValueType.Object) }) {
     {
         setAcceptErrors(true);
     }

     public Object evaluate(Object[] arguments, ICalcContext context) {
         return arguments[0] instanceof CalcError ? "Handled error" : arguments[0];
     }
 };
 Workbook.AddCustomFunction(function, true);
 worksheet.getRange("A1").setFormula("=HANDLEERROR(1/0)");
 Object result = worksheet.getRange("A1").getValue();
 </code></pre></div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>acceptErrors</code> - <code>true</code> if error values are passed to the custom function as arguments; <code>false</code> if an error argument causes calculation to return the error immediately.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="getAcceptErrors()">
<h3>getAcceptErrors</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">boolean</span>&nbsp;<span class="element-name">getAcceptErrors</span>()</div>
<div class="block">Gets whether the function accepts error values as arguments. <p>If this property returns  <code>true</code>, error values such as  <code>#N/A</code> and <code>#VALUE!</code> can be passed to <a href="#evaluate(java.lang.Object%5B%5D,com.grapecity.documents.excel.ICalcContext)"><code>evaluate(Object[],ICalcContext)</code></a> for custom handling. If it returns  <code>false</code>, the calculation engine returns the error immediately  instead of passing the error argument to the custom function.</p>
<pre><code data-language="Java">
 CustomFunction function = new CustomFunction(
     "HANDLEERROR",
     FunctionValueType.Text,
     new Parameter[] { new Parameter(FunctionValueType.Object) }) {
     {
         setAcceptErrors(true);
     }

     public Object evaluate(Object[] arguments, ICalcContext context) {
         return arguments[0] instanceof CalcError ? "Handled error" : arguments[0];
     }
 };
 boolean acceptErrors = function.getAcceptErrors();
 Workbook.AddCustomFunction(function, true);
 worksheet.getRange("A1").setFormula("=HANDLEERROR(1/0)");
 Object result = worksheet.getRange("A1").getValue();
 </code></pre></div>
<dl class="notes">
<dt>Returns:</dt>
<dd><code>true</code> if error values are passed to the custom function as arguments; <code>false</code> if an error argument causes calculation to return the error immediately.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="getIsVolatile()">
<h3>getIsVolatile</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">boolean</span>&nbsp;<span class="element-name">getIsVolatile</span>()</div>
<div class="block">Gets whether this custom function is volatile. <p>If this property returns  <code>true</code>, formulas that call this custom  function are recalculated whenever calculation is triggered, even when the  arguments have not changed. If it returns  <code>false</code>, calculation can  reuse cached results for repeated calls with the same arguments.</p>
<pre><code data-language="Java">
 CustomFunction function = new CustomFunction("NEXTVALUE", FunctionValueType.Number) {
     private int calculationCount;
     {
         setIsVolatile(true);
     }

     public Object evaluate(Object[] arguments, ICalcContext context) {
         return (double) ++calculationCount;
     }
 };
 boolean isVolatile = function.getIsVolatile();
 Workbook.AddCustomFunction(function, true);
 worksheet.getRange("A1").setFormula("=NEXTVALUE()");
 Object firstValue = worksheet.getRange("A1").getValue();
 worksheet.getRange("A2").setValue("trigger recalculation");
 workbook.calculate();
 Object recalculatedValue = worksheet.getRange("A1").getValue();
 </code></pre></div>
<dl class="notes">
<dt>Returns:</dt>
<dd><code>true</code> if this custom function is volatile, <code>false</code> otherwise.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="setIsVolatile(boolean)">
<h3>setIsVolatile</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">setIsVolatile</span><wbr><span class="parameters">(boolean&nbsp;aVolatile)</span></div>
<div class="block">Sets whether this custom function is volatile. <p>By default, custom functions can reuse cached calculation results when they are evaluated  repeatedly with the same arguments. Set this property to  <code>true</code> to force the function to recalculate whenever the formula is evaluated instead of reusing a cached result. Set it  to  <code>false</code> to allow cached results to be reused.</p><p>Use  <a href="#getIsVolatile()"><code>getIsVolatile()</code></a> to get the current setting.</p>
<pre><code data-language="Java">
 CustomFunction function = new CustomFunction("NEXTVALUE", FunctionValueType.Number) {
     private int calculationCount;
     {
         setIsVolatile(true);
     }

     public Object evaluate(Object[] arguments, ICalcContext context) {
         return (double) ++calculationCount;
     }
 };
 Workbook.AddCustomFunction(function, true);
 worksheet.getRange("A1").setFormula("=NEXTVALUE()");
 Object firstValue = worksheet.getRange("A1").getValue();
 worksheet.getRange("A2").setValue("trigger recalculation");
 workbook.calculate();
 Object recalculatedValue = worksheet.getRange("A1").getValue();
 </code></pre></div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>aVolatile</code> - <code>true</code> to mark the custom function as volatile so it is recalculated every time it is evaluated;  <code>false</code> to allow cached results to be reused.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="evaluate(java.lang.Object[],com.grapecity.documents.excel.ICalcContext)">
<h3>evaluate</h3>
<div class="member-signature"><span class="modifiers">public abstract</span>&nbsp;<span class="return-type"><a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang">Object</a></span>&nbsp;<span class="element-name">evaluate</span><wbr><span class="parameters">(<a class="external-link" href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang">Object</a>[]&nbsp;arguments,
 <a href="ICalcContext.html" title="interface in com.grapecity.documents.excel">ICalcContext</a>&nbsp;context)</span></div>
<div class="block">Calculate the function.
 <pre><code data-language="Java">
 CustomFunction function = new CustomFunction("DOUBLE", FunctionValueType.Number) {
     public Object evaluate(Object[] arguments, ICalcContext context) {
         return ((Number) arguments[0]).doubleValue() * 2;
     }
 };
 ICalcContext calcContext = new ICalcContext() {
     public IWorksheet getWorksheet() { return worksheet; }
     public int getRow() { return 0; }
     public int getColumn() { return 0; }
 };
 Object result = function.evaluate(new Object[] { 21d }, calcContext);
 </code></pre></div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>arguments</code> - the value collection of the arguments</dd>
<dd><code>context</code> - the context of the calculation.</dd>
<dt>Returns:</dt>
<dd>the result of the function.</dd>
</dl>
</section>
</li>
</ul>
</section>
</li>
</ul>
</section>
<!-- ========= END OF CLASS DATA ========= -->
<script>var evenRowColor = "even-row-color";
var oddRowColor = "odd-row-color";
var tableTab = "table-tab";
var activeTableTab = "active-table-tab";

function show(tableId, selected, columns) {
    if (tableId !== selected) {
        document.querySelectorAll('div.' + tableId + ':not(.' + selected + ')')
            .forEach(function (elem) {
                elem.style.display = 'none';
            });
    }
    document.querySelectorAll('div.' + selected)
        .forEach(function (elem, index) {
            elem.style.display = '';
            var isEvenRow = index % (columns * 2) < columns;
            elem.classList.remove(isEvenRow ? oddRowColor : evenRowColor);
            elem.classList.add(isEvenRow ? evenRowColor : oddRowColor);
        });
    updateTabs(tableId, selected);
}

function updateTabs(tableId, selected) {
    document.querySelector('div#' + tableId + ' .summary-table')
        .setAttribute('aria-labelledby', selected);
    document.querySelectorAll('button[id^="' + tableId + '"]')
        .forEach(function (tab, index) {
            if (selected === tab.id || (tableId === selected && index === 0)) {
                tab.className = activeTableTab;
                tab.setAttribute('aria-selected', true);
                tab.setAttribute('tabindex', 0);
            } else {
                tab.className = tableTab;
                tab.setAttribute('aria-selected', false);
                tab.setAttribute('tabindex', -1);
            }
        });
}

function switchTab(e) {
    var selected = document.querySelector('[aria-selected=true]');
    if (selected) {
        if ((e.keyCode === 37 || e.keyCode === 38) && selected.previousSibling) {
            // left or up arrow key pressed: move focus to previous tab
            selected.previousSibling.click();
            selected.previousSibling.focus();
            e.preventDefault();
        } else if ((e.keyCode === 39 || e.keyCode === 40) && selected.nextSibling) {
            // right or down arrow key pressed: move focus to next tab
            selected.nextSibling.click();
            selected.nextSibling.focus();
            e.preventDefault();
        }
    }
}
</script></div>