公式
公式是 Univer 的核心能力之一。使用者在單元格中寫入公式,由 Univer 計算其值。支援的函式與 Excel 一致,涵蓋數學、邏輯、文字、日期等型別。
工作簿中的公式較多時,公式計算可能長時間佔用主執行緒,頁面響應隨之變慢。把公式計算放到 Worker 中執行,可以減輕對渲染和使用者互動的影響。配置方式見 Web Workers。
initialFormulaComputing 控制工作簿載入時的公式計算方式。如果已儲存的公式結果已經過期,CalculationMode.FORCED 會重新計算這些結果。在預設模式下,該選項位於 formula 之下。
根據所採用的接入模式,把這些選項加入現有的初始化配置。其他外掛、語言、主題和容器設定保持原樣,同一個外掛不要註冊兩次。
CalculationMode.FORCED重新計算所有公式。CalculationMode.WHEN_EMPTY是預設值,只計算沒有已儲存v值的公式單元格。CalculationMode.NO_CALCULATION初始化時不計算公式。
外掛設定
UniverSheetsFormulaPlugin
initialFormulaComputingCalculationMode預設值:CalculationMode.WHEN_EMPTY設定工作簿開啟時公式的計算方式。
import { CalculationMode, UniverSheetsFormulaPlugin } from '@univerjs/sheets-formula'univer.registerPlugin(UniverSheetsFormulaPlugin, { initialFormulaComputing: CalculationMode.FORCED,})預設設定
UniverSheetsCorePreset
formulaobject設定公式函數、說明、計算模式與函數提示。initialFormulaComputingCalculationMode預設值:CalculationMode.WHEN_EMPTY設定工作簿開啟時公式的計算方式。
import { CalculationMode, UniverSheetsCorePreset } from '@univerjs/preset-sheets-core'import { createUniver } from '@univerjs/presets'const { univerAPI } = createUniver({ presets: [ UniverSheetsCorePreset({ formula: { initialFormulaComputing: CalculationMode.FORCED, }, }), ],})設定跨活頁簿繫結
如果應用需要把公式中的名稱與固定的文件 ID 關聯起來,可以使用 @univerjs-pro/engine-formula 提供的引用繫結 API。這是一項 Pro 擴充套件:需要先配置客戶端許可證,初始化時用 UniverProFormulaEnginePlugin 替換 UniverFormulaEnginePlugin,並引入 Pro Facade。公式引擎只能註冊一個。僅引入 Facade 不會註冊外掛。
跨活頁簿引用
跨工作簿公式從另一個工作簿讀取資料,例如在 Report 中彙總 Sales.xlsx 的銷售額。與引用同一工作簿中的其他工作表不同,跨工作簿公式還需要指明來源工作簿。
引用語法
| 情境 | 範例 | 意義 |
|---|---|---|
| 同一工作簿中的另一張工作表 | =SUM(Data!A1:A10) | 目前活頁簿的 Data 工作表 |
| 另一工作簿中的單元格區域 | =SUM('[Sales.xlsx]Data'!A1:A10) | Sales.xlsx 的 Data 工作表 |
| 其他活頁簿的表格 | =SUM(Sales.xlsx!SalesTable[Amount]) | 已存在的 SalesTable 表格的 Amount 欄 |
Sales.xlsx 是工作簿名稱,不是檔案路徑,也不是下載地址。寫入公式不會讀取檔案、下載 Excel 工作簿,也不會連線到另一個瀏覽器頁面中的編輯器。需要使用表格結構化引用時,先建立對應的表格。
引用同一實例中已載入的活頁簿
使用基礎公式引擎時,兩個工作簿必須載入到同一個 Univer 例項中,並處於同一個公式計算環境。下面的程式碼應在 Sheets 初始化之後執行。在外掛模式下,還需要按本頁的說明引入 Facade 擴充套件。
const source = univerAPI.createWorkbook({ id: 'sales-workbook', name: 'Sales.xlsx', sheetOrder: ['sales-data'], sheets: { 'sales-data': { id: 'sales-data', name: 'Data', rowCount: 100, columnCount: 20, cellData: { 0: { 0: { v: 100 } }, 1: { 0: { v: 200 } }, }, }, },}, { makeCurrent: false })const report = univerAPI.createWorkbook({ id: 'report-workbook', name: 'Report' })const resultCell = report.getActiveSheet().getRange('A1')resultCell.setFormula("=SUM('[Sales.xlsx]Data'!A1:A2)")const formula = univerAPI.getFormula()formula.executeCalculation()await formula.onCalculationResultApplied()console.log(resultCell.getValue()) // 300makeCurrent: false 使來源工作簿載入後不會成為當前工作簿。後續始終使用 source 和 report 這兩個顯式引用,即使活動工作簿發生變化,公式也不會被寫到其他工作簿。
名稱匹配不區分大小寫。優先按完整名稱匹配;如果沒有完整名稱匹配,則忽略 .xlsx、.xlsm 這類常見 Excel 副檔名後再匹配。名稱不存在,或者匹配到多個工作簿時,都會返回 #REF!。來源名稱應當明確且唯一。
綁定固定的來源 ID
使用前面配置好的 Pro 引擎,可以把公式中的名稱繫結到固定的文件 ID。
下面的範例沿用前面兩個工作簿,但執行在配置了 Pro 引擎的環境中:
import '@univerjs-pro/engine-formula/facade'const reference = univerAPI.getFormula().buildReference({ hostUnitId: report.getId(), unit: { unitId: source.getId(), formulaQualifier: 'Sales Source', }, target: { kind: univerAPI.Enum.FormulaReferenceType.SHEET_RANGE, sheetName: 'Data', range: { startRow: 0, endRow: 1, startColumn: 0, endColumn: 0 }, },})resultCell.setFormula(`=SUM(${reference})`)hostUnitId 表示包含該公式的工作簿。unit.unitId 是來源工作簿的固定 ID,formulaQualifier 是該工作簿在公式文字中使用的名稱。區域座標從 0 開始,且結束位置包含在內。
buildReference() 返回不帶 = 的引用片段,同時持久化儲存跨工作簿繫結。它不會載入來源工作簿,也不會觸發計算。來源資料仍然需要來自載入到計算環境中的工作簿,或者來自已配置的資料提供方。
如果公式文字由人工編寫或由應用生成,應先繫結來源,再寫入公式:
const formula = univerAPI.getFormula()const bound = formula.upsertExternalReference({ unitId: report.getId(), qualifier: 'Sales Source', sourceUnitId: source.getId(), sourceUnitType: univerAPI.Enum.UniverInstanceType.UNIVER_SHEET,})if (!bound) throw new Error('Could not bind Sales Source')resultCell.setFormula("=SUM('[Sales Source]Data'!A1:A2)")在同一個工作簿中重複寫入相同的繫結是冪等操作。qualifier 不要帶方括號或引號,也不要使用 1、2 這類正整數,因為 Excel 將這些編號保留給外部連結槽位,而不是用於應用文件 ID。從 Excel 匯入的外部連結還需要對應的連結資源,僅複製公式文字並不夠。
更新、儲存與卸載
透過 Facade 修改來源資料後,需要顯式執行計算,並在結果寫回之後再讀取目標值。setFormula() 或 setValue() 返回,並不表示非同步計算已經完成。
const sourceSheet = source.getSheetBySheetId('sales-data')if (!sourceSheet) throw new Error('Source sheet not found')sourceSheet.getRange('A1').setValue(150)formula.executeCalculation()await formula.onCalculationResultApplied()console.log(resultCell.getValue()) // 350使用 report.save() 儲存目標工作簿,可以保留完整的快照,其中包含引用繫結資源。如果只儲存單元格中的公式文字,公開名稱與來源 ID 之間的對映就會丟失。來源工作簿的資料需要單獨儲存和載入。
來源工作簿解除安裝後,普通的已載入工作簿引用就無法再讀取它。Pro 外部引用能否繼續計算,取決於已配置的資料提供方和可用快取是否能夠提供所需資料。繫結本身不包含來源資料,也不保證可以離線計算。此前顯示過的結果並不能證明當前資料仍然有效。
不再需要某個 Pro 繫結時,可以將其移除:
univerAPI.getFormula().removeExternalReference({ unitId: report.getId(), qualifier: 'Sales Source',})移除繫結不會刪除或改寫已有的公式,下一次計算會重新解析這些名稱。如果仍有同名工作簿處於載入狀態,引用可能繼續解析成功;如果沒有任何匹配,則返回 #REF!。如果要徹底停止引用該來源,還需要修改或清空相關單元格的公式。
完整參數和返回值見 FFormula 引用繫結 API。
三維引用
三維引用指同一工作簿中連續的一組工作表,與引用另一個工作簿不同:
=SUM(Jan:Mar!B2:C3)=SUM('Jan':'Mar'!B2)範圍包含 Jan、Mar 以及兩者之間的所有工作表,按工作簿中的排列順序計算,而不是按名稱排序。調整工作表順序後,需要重新確認彙總範圍。
已經支援的公式函數
AMORDEGRC 可計算餘額遞減折舊,EUROCONVERT 依歐元固定匯率換算參與貨幣。=ISO.CEILING(-4.3) 會向上取整為 -4。
Functions - (528)
| ARRAY_CONSTRAIN | Constrains an array result to a specified size. |
|---|---|
| FLATTEN | Flattens all the values from one or more ranges into a single column. |
| BETADIST | Returns the cumulative beta probability density function. The beta distribution is commonly used to study variation in the percentage of something across samples, such as the fraction of the day people spend watching television. |
| BETAINV | Returns the inverse of the cumulative beta probability density function for a specified beta distribution. That is, if probability = BETADIST(x,...), then BETAINV(probability,...) = x. The beta distribution can be used in project planning to model probable completion times given an expected completion time and variability. |
| BINOMDIST | Returns the individual term binomial distribution probability. Use BINOMDIST in problems with a fixed number of tests or trials, when the outcomes of any trial are only success or failure, when trials are independent, and when the probability of success is constant throughout the experiment. For example, BINOMDIST can calculate the probability that two of the next three babies born are male. |
| CHIDIST | Returns the right-tailed probability of the chi-squared distribution. The χ2 distribution is associated with a χ2 test. Use the χ2 test to compare observed and expected values. For example, a genetic experiment might hypothesize that the next generation of plants will exhibit a certain set of colors. By comparing the observed results with the expected ones, you can decide whether your original hypothesis is valid. |
| CHIINV | Returns the inverse of the right-tailed probability of the chi-squared distribution. If probability = CHIDIST(x,...), then CHIINV(probability,...) = x. Use this function to compare observed results with expected ones in order to decide whether your original hypothesis is valid. |
| CHITEST | Returns the test for independence. CHITEST returns the value from the chi-squared (χ2) distribution for the statistic and the appropriate degrees of freedom. You can use χ2 tests to determine whether hypothesized results are verified by an experiment. |
| CONFIDENCE | Returns the confidence interval for a population mean, using a normal distribution. |
| COVAR | Returns covariance, the average of the products of deviations for each data point pair in two data sets. |
| CRITBINOM | Returns the smallest value for which the cumulative binomial distribution is greater than or equal to a criterion value. Use this function for quality assurance applications. For example, use CRITBINOM to determine the greatest number of defective parts that are allowed to come off an assembly line run without rejecting the entire lot. |
| EXPONDIST | Returns the exponential distribution. Use EXPONDIST to model the time between events, such as how long an automated bank teller takes to deliver cash. For example, you can use EXPONDIST to determine the probability that the process takes at most 1 minute. |
| FDIST | Returns the (right-tailed) F probability distribution (degree of diversity) for two data sets. You can use this function to determine whether two data sets have different degrees of diversity. For example, you can examine the test scores of men and women entering high school and determine if the variability in the females is different from that found in the males. |
| FINV | Returns the inverse of the (right-tailed) F probability distribution. If p = FDIST(x,...), then FINV(p,...) = x. |
| FTEST | Returns the result of an F-test. An F-test returns the two-tailed probability that the variances in array1 and array2 are not significantly different. Use this function to determine whether two samples have different variances. For example, given test scores from public and private schools, you can test whether these schools have different levels of test score diversity. |
| GAMMADIST | Returns the gamma distribution. You can use this function to study variables that may have a skewed distribution. The gamma distribution is commonly used in queuing analysis. |
| GAMMAINV | Returns the inverse of the gamma cumulative distribution. If p = GAMMADIST(x,...), then GAMMAINV(p,...) = x. You can use this function to study a variable whose distribution may be skewed. |
| HYPGEOMDIST | Returns the hypergeometric distribution. HYPGEOMDIST returns the probability of a given number of sample successes, given the sample size, population successes, and population size. Use HYPGEOMDIST for problems with a finite population, where each observation is either a success or a failure, and where each subset of a given size is chosen with equal likelihood. |
| LOGINV | Returns the inverse of the lognormal cumulative distribution function of x, where ln(x) is normally distributed with parameters mean and standard_dev. If p = LOGNORMDIST(x,...) then LOGINV(p,...) = x. |
| LOGNORMDIST | Returns the cumulative lognormal distribution of x, where ln(x) is normally distributed with parameters mean and standard_dev. Use this function to analyze data that has been logarithmically transformed. |
| MODE | Let's say you want to find out the most common number of bird species sighted in a sample of bird counts at a critical wetland over a 30-year time period, or you want to find out the most frequently occurring number of phone calls at a telephone support center during off-peak hours. To calculate the mode of a group of numbers, use the MODE function. |
| NEGBINOMDIST | Returns the negative binomial distribution. NEGBINOMDIST returns the probability that there will be number_f failures before the number_s-th success, when the constant probability of a success is probability_s. This function is similar to the binomial distribution, except that the number of successes is fixed, and the number of trials is variable. Like the binomial, trials are assumed to be independent. |
| NORMDIST | The NORMDIST function returns the normal distribution for the specified mean and standard deviation. This function has a wide range of applications in statistics, including hypothesis testing. |
| NORMINV | Returns the inverse of the normal cumulative distribution for the specified mean and standard deviation. |
| NORMSDIST | Returns the standard normal cumulative distribution function. The distribution has a mean of 0 (zero) and a standard deviation of one. Use this function in place of a table of standard normal curve areas. |
| NORMSINV | Returns the inverse of the standard normal cumulative distribution. The distribution has a mean of zero and a standard deviation of one. |
| PERCENTILE | Returns the k-th percentile of values in a range. You can use this function to establish a threshold of acceptance. For example, you can decide to examine candidates who score above the 90th percentile. |
| PERCENTRANK | The PERCENTRANK function returns the rank of a value in a dataset as a percentage of the dataset -- essentially, the relative standing of a value within the whole dataset. For example, you could use PERCENTRANK to determine the standing of an individual's test score among the field of all scores for the same test. |
| POISSON | Returns the Poisson distribution. A common application of the Poisson distribution is predicting the number of events over a specific time, such as the number of cars arriving at a toll plaza in 1 minute. |
| QUARTILE | Returns the quartile of a data set. Quartiles often are used in sales and survey data to divide populations into groups. For example, you can use QUARTILE to find the top 25 percent of incomes in a population. |
| RANK | Returns the rank of a number in a list of numbers. The rank of a number is its size relative to other values in a list. (If you were to sort the list, the rank of the number would be its position.) |
| STDEV | Estimates standard deviation based on a sample. The standard deviation is a measure of how widely values are dispersed from the average value (the mean). |
| STDEVP | Calculates standard deviation based on the entire population given as arguments. The standard deviation is a measure of how widely values are dispersed from the average value (the mean). |
| TDIST | Returns the Percentage Points (probability) for the Student t-distribution where a numeric value (x) is a calculated value of t for which the Percentage Points are to be computed. The t-distribution is used in the hypothesis testing of small sample data sets. Use this function in place of a table of critical values for the t-distribution. |
| TINV | Returns the two-tailed inverse of the Student's t-distribution. |
| TTEST | Returns the probability associated with a Student's t-Test. Use TTEST to determine whether two samples are likely to have come from the same two underlying populations that have the same mean. |
| VAR | Estimates variance based on a sample. |
| VARP | Calculates variance based on the entire population. |
| WEIBULL | Returns the Weibull distribution. Use this distribution in reliability analysis, such as calculating a device's mean time to failure. |
| ZTEST | Returns the one-tailed probability-value of a z-test. For a given hypothesized population mean, μ0, ZTEST returns the probability that the sample mean would be greater than the average of observations in the data set (array) — that is, the observed sample mean. |
| CUBEKPIMEMBER | Returns a key performance indicator (KPI) property and displays the KPI name in the cell. A KPI is a quantifiable measurement, such as monthly gross profit or quarterly employee turnover, that is used to monitor an organization's performance. |
| CUBEMEMBER | Returns a member or tuple from the cube. Use to validate that the member or tuple exists in the cube. |
| CUBEMEMBERPROPERTY | The CUBEMEMBERPROPERTY function, one of the Cube functions in Excel, returns the value of a member property from a cube. Use it to validate that a member name exists within the cube, and to return the specified property for this member. |
| CUBERANKEDMEMBER | Returns the nth, or ranked, member in a set. Use to return one or more elements in a set, such as the top sales performer or the top 10 students. |
| CUBESET | Defines a calculated set of members or tuples by sending a set expression to the cube on the server, which creates the set, and then returns that set to Microsoft Excel. |
| CUBESETCOUNT | Returns the number of items in a set. |
| CUBEVALUE | Returns an aggregated value from the cube. |
| DAVERAGE | Averages the values in a field (column) of records in a list or database that match conditions you specify. |
| DCOUNT | Counts the cells that contain numbers in a field (column) of records in a list or database that match conditions that you specify. |
| DCOUNTA | Counts the nonblank cells in a field (column) of records in a list or database that match conditions that you specify. |
| DGET | Extracts a single value from a column of a list or database that matches conditions that you specify. |
| DMAX | Returns the largest number in a field (column) of records in a list or database that matches conditions you that specify. |
| DMIN | Returns the smallest number in a field (column) of records in a list or database that matches conditions that you specify. |
| DPRODUCT | Multiplies the values in a field (column) of records in a list or database that match conditions that you specify. |
| DSTDEV | Estimates the standard deviation of a population based on a sample by using the numbers in a field (column) of records in a list or database that match conditions that you specify. |
| DSTDEVP | Calculates the standard deviation of a population based on the entire population by using the numbers in a field (column) of records in a list or database that match conditions that you specify. |
| DSUM | In a list or database, DSUM provides the sum of the numbers in fields (columns) of records that match your specified conditions. |
| DVAR | Estimates the variance of a population based on a sample by using the numbers in a field (column) of records in a list or database that match conditions that you specify. |
| DVARP | Calculates the variance of a population based on the entire population by using the numbers in a field (column) of records in a list or database that match conditions that you specify. |
| DATE | Returns the serial number of a particular date |
| DATEDIF | Calculates the number of days, months, or years between two dates. This function is useful in formulas where you need to calculate an age. |
| DATEVALUE | Converts a date in the form of text to a serial number. |
| DAY | Returns the day of a date, represented by a serial number. The day is given as an integer ranging from 1 to 31. |
| DAYS | Returns the number of days between two dates. |
| DAYS360 | Calculates the number of days between two dates based on a 360-day year |
| EDATE | Returns the serial number that represents the date that is the indicated number of months before or after a specified date (the start_date). Use EDATE to calculate maturity dates or due dates that fall on the same day of the month as the date of issue. |
| EOMONTH | Returns the serial number of the last day of the month before or after a specified number of months |
| EPOCHTODATE | Converts a Unix epoch timestamp in seconds, milliseconds, or microseconds to a datetime in Universal Time Coordinated (UTC). |
| HOUR | Converts a serial number to an hour |
| ISOWEEKNUM | Returns the number of the ISO week number of the year for a given date |
| MINUTE | Returns the minutes of a time value. The minute is given as an integer, ranging from 0 to 59. |
| MONTH | Returns the month of a date represented by a serial number. The month is given as an integer, ranging from 1 (January) to 12 (December). |
| NETWORKDAYS | Returns the number of whole working days between start_date and end_date. Working days exclude weekends and any dates identified in holidays. Use NETWORKDAYS to calculate employee benefits that accrue based on the number of days worked during a specific term. |
| NETWORKDAYS_INTL | Returns the number of whole workdays between two dates using parameters to indicate which and how many days are weekend days |
| NOW | Returns the serial number of the current date and time. If the cell format was General before the function was entered, Excel changes the cell format so that it matches the date and time format of your regional settings. You can change the date and time format for the cell by using the commands in the Number group of the Home tab on the Ribbon. |
| SECOND | Returns the seconds of a time value. The second is given as an integer in the range 0 (zero) to 59. |
| TIME | Returns the decimal number for a particular time. If the cell format was General before the function was entered, the result is formatted as a date. |
| TIMEVALUE | Converts a time in the form of text to a serial number. |
| TO_DATE | Converts a provided number to a date. |
| TODAY | Returns the serial number of today's date |
| WEEKDAY | Converts a serial number to a day of the week |
| WEEKNUM | Converts a serial number to a number representing where the week falls numerically with a year |
| WORKDAY | Returns the serial number of the date before or after a specified number of workdays |
| WORKDAY_INTL | Returns the serial number of the date before or after a specified number of workdays using parameters to indicate which and how many days are weekend days |
| YEAR | Returns the year corresponding to a date. The year is returned as an integer in the range 1900-9999. |
| YEARFRAC | Returns the year fraction representing the number of whole days between start_date and end_date |
| BESSELI | Returns the modified Bessel function In(x) |
| BESSELJ | Returns the Bessel function Jn(x) |
| BESSELK | Returns the modified Bessel function Kn(x) |
| BESSELY | Returns the Bessel function Yn(x) |
| BIN2DEC | Converts a binary number to decimal |
| BIN2HEX | Converts a binary number to hexadecimal |
| BIN2OCT | Converts a binary number to octal. |
| BITAND | Returns a bitwise 'AND' of two numbers. |
| BITLSHIFT | Returns a value number shifted left by shift_amount bits |
| BITOR | Returns a bitwise OR of 2 numbers |
| BITRSHIFT | Returns a value number shifted right by shift_amount bits |
| BITXOR | Returns a bitwise 'Exclusive Or' of two numbers |
| COMPLEX | Converts real and imaginary coefficients into a complex number |
| CONVERT | Converts a number from one measurement system to another |
| DEC2BIN | Converts a decimal number to binary |
| DEC2HEX | Converts a decimal number to hexadecimal |
| DEC2OCT | Converts a decimal number to octal |
| DELTA | Tests whether two values are equal |
| ERF | Returns the error function |
| ERF_PRECISE | Returns the error function |
| ERFC | Returns the complementary error function |
| ERFC_PRECISE | Returns the complementary ERF function integrated between x and infinity |
| GESTEP | Tests whether a number is greater than a threshold value |
| HEX2BIN | Converts a hexadecimal number to binary |
| HEX2DEC | Converts a hexadecimal number to decimal |
| HEX2OCT | Converts a hexadecimal number to octal |
| IMABS | Returns the absolute value (modulus) of a complex number |
| IMAGINARY | Returns the imaginary coefficient of a complex number |
| IMARGUMENT | Returns the argument theta, an angle expressed in radians |
| IMCONJUGATE | Returns the complex conjugate of a complex number |
| IMCOS | Returns the cosine of a complex number |
| IMCOSH | Returns the hyperbolic cosine of a complex number |
| IMCOT | Returns the cotangent of a complex number |
| IMCOTH | The IMCOTH function returns the hyperbolic cotangent of the given complex number. For example, a given complex number "x+yi" returns "coth(x+yi)." |
| IMCSC | Returns the cosecant of a complex number |
| IMCSCH | Returns the hyperbolic cosecant of a complex number |
| IMDIV | Returns the quotient of two complex numbers in x + yi or x + yj text format. |
| IMEXP | Returns the exponential of a complex number in x + yi or x + yj text format. |
| IMLN | Returns the natural logarithm of a complex number |
| IMLOG | The IMLOG function returns the logarithm of a complex number for a specified base. |
| IMLOG10 | Returns the base-10 logarithm of a complex number |
| IMLOG2 | Returns the base-2 logarithm of a complex number |
| IMPOWER | Returns a complex number raised to an integer power |
| IMPRODUCT | Returns the product of from 1 to 255 complex numbers |
| IMREAL | Returns the real coefficient of a complex number |
| IMSEC | Returns the secant of a complex number |
| IMSECH | Returns the hyperbolic secant of a complex number |
| IMSIN | Returns the sine of a complex number |
| IMSINH | Returns the hyperbolic sine of a complex number |
| IMSQRT | Returns the square root of a complex number |
| IMSUB | Returns the difference between two complex numbers |
| IMSUM | Returns the sum of complex numbers |
| IMTAN | Returns the tangent of a complex number |
| IMTANH | The IMTANH function returns the hyperbolic tangent of the given complex number. For example, a given complex number "x+yi" returns "tanh(x+yi)." |
| OCT2BIN | Converts an octal number to binary |
| OCT2DEC | Converts an octal number to decimal |
| OCT2HEX | Converts an octal number to hexadecimal |
| ACCRINT | Returns the accrued interest for a security that pays periodic interest |
| ACCRINTM | Returns the accrued interest for a security that pays interest at maturity |
| AMORDEGRC | Returns the depreciation for each accounting period by using a depreciation coefficient |
| AMORLINC | Returns the depreciation for each accounting period |
| COUPDAYBS | Returns the number of days from the beginning of the coupon period to the settlement date |
| COUPDAYS | Returns the number of days in the coupon period that contains the settlement date |
| COUPDAYSNC | Returns the number of days from the settlement date to the next coupon date |
| COUPNCD | Returns the next coupon date after the settlement date |
| COUPNUM | Returns the number of coupons payable between the settlement date and maturity date |
| COUPPCD | Returns the previous coupon date before the settlement date |
| CUMIPMT | Returns the cumulative interest paid between two periods |
| CUMPRINC | Returns the cumulative principal paid on a loan between two periods |
| DB | Returns the depreciation of an asset for a specified period by using the fixed-declining balance method |
| DDB | Returns the depreciation of an asset for a specified period by using the double-declining balance method or some other method that you specify |
| DISC | Returns the discount rate for a security |
| DOLLARDE | Converts a dollar price, expressed as a fraction, into a dollar price, expressed as a decimal number |
| DOLLARFR | Converts a dollar price, expressed as a decimal number, into a dollar price, expressed as a fraction |
| DURATION | Returns the annual duration of a security with periodic interest payments |
| EFFECT | Returns the effective annual interest rate, given the nominal annual interest rate and the number of compounding periods per year. |
| FV | Returns the future value of an investment |
| FVSCHEDULE | Returns the future value of an initial principal after applying a series of compound interest rates |
| INTRATE | Returns the interest rate for a fully invested security. |
| IPMT | Returns the interest payment for a given period for an investment based on periodic, constant payments and a constant interest rate. |
| IRR | Returns the internal rate of return for a series of cash flows |
| ISPMT | Calculates the interest paid during a specific period of an investment |
| MDURATION | Returns the Macauley modified duration for a security with an assumed par value of $100 |
| MIRR | Returns the internal rate of return where positive and negative cash flows are financed at different rates |
| NOMINAL | Returns the annual nominal interest rate |
| NPER | Returns the number of periods for an investment |
| NPV | Returns the net present value of an investment based on a series of periodic cash flows and a discount rate |
| ODDFPRICE | Returns the price per $100 face value of a security with an odd first period |
| ODDFYIELD | Returns the yield of a security with an odd first period |
| ODDLPRICE | Returns the price per $100 face value of a security with an odd last period |
| ODDLYIELD | Returns the yield of a security with an odd last period |
| PDURATION | Returns the number of periods required by an investment to reach a specified value |
| PMT | Returns the periodic payment for an annuity |
| PPMT | Returns the payment on the principal for an investment for a given period |
| PRICE | Returns the price per $100 face value of a security that pays periodic interest |
| PRICEDISC | Returns the price per $100 face value of a discounted security |
| PRICEMAT | Returns the price per $100 face value of a security that pays interest at maturity |
| PV | Returns the present value of an investment |
| RATE | Returns the interest rate per period of an annuity |
| RECEIVED | Returns the amount received at maturity for a fully invested security |
| RRI | Returns an equivalent interest rate for the growth of an investment |
| SLN | Returns the straight-line depreciation of an asset for one period |
| SYD | Returns the sum-of-years' digits depreciation of an asset for a specified period |
| TBILLEQ | Returns the bond-equivalent yield for a Treasury bill |
| TBILLPRICE | Returns the price per $100 face value for a Treasury bill |
| TBILLYIELD | Returns the yield for a Treasury bill |
| VDB | Returns the depreciation of an asset for a specified or partial period by using a declining balance method |
| XIRR | Returns the internal rate of return for a schedule of cash flows that is not necessarily periodic |
| XNPV | Returns the net present value for a schedule of cash flows that is not necessarily periodic |
| YIELD | Returns the yield on a security that pays periodic interest |
| YIELDDISC | Returns the annual yield for a discounted security; for example, a Treasury bill |
| YIELDMAT | Returns the annual yield of a security that pays interest at maturity |
| CELL | Returns information about the formatting, location, or contents of a cell |
| ERROR_TYPE | Returns a number corresponding to an error type |
| INFO | Returns information about the current operating environment |
| ISBETWEEN | Checks whether a provided number is between two other numbers either inclusively or exclusively. |
| ISBLANK | Returns TRUE if the value is blank |
| ISDATE | The ISDATE function returns whether a value is a date. |
| ISEMAIL | To check if a value is a valid email address, use the ISEMAIL function. This checks if the value follows a commonly accepted format for email addresses but doesn’t verify its existence. |
| ISERR | Returns TRUE if the value is any error value except #N/A |
| ISERROR | Returns TRUE if the value is any error value |
| ISEVEN | Returns TRUE if number is even, or FALSE if number is odd. |
| ISFORMULA | Returns TRUE if there is a reference to a cell that contains a formula |
| ISLOGICAL | Returns TRUE if the value is a logical value |
| ISNA | Returns TRUE if the value is the #N/A error value |
| ISNONTEXT | Returns TRUE if the value is not text |
| ISNUMBER | Returns TRUE if the value is a number |
| ISODD | Returns TRUE if the number is odd |
| ISOMITTED | Checks whether the value in a LAMBDA is missing and returns TRUE or FALSE |
| ISREF | Returns TRUE if the value is a reference |
| ISTEXT | Returns TRUE if the value is text |
| ISURL | Checks whether a value is a valid URL. |
| N | Returns a value converted to a number |
| NA | Returns the error value #N/A |
| SHEET | Returns the sheet number of the referenced sheet |
| SHEETS | Returns the number of sheets in a workbook |
| TYPE | Returns a number indicating the data type of a value |
| AND | Returns TRUE if all of its arguments are TRUE |
| BYCOL | Applies a LAMBDA to each column and returns an array of the results |
| BYROW | Applies a LAMBDA to each row and returns an array of the results |
| FALSE | Returns the logical value FALSE. |
| IF | Specifies a logical test to perform |
| IFERROR | Returns a value you specify if a formula evaluates to an error; otherwise, returns the result of the formula |
| IFNA | Returns the value you specify if the expression resolves to #N/A, otherwise returns the result of the expression |
| IFS | Checks whether one or more conditions are met and returns a value that corresponds to the first TRUE condition. |
| LAMBDA | Use a LAMBDA function to create custom, reusable functions and call them by a friendly name. The new function is available throughout the workbook and called like native Excel functions. |
| LET | Assigns names to calculation results |
| MAKEARRAY | Returns a calculated array of a specified row and column size, by applying a LAMBDA |
| MAP | Returns an array formed by mapping each value in the array(s) to a new value by applying a LAMBDA to create a new value. |
| NOT | Reverses the logic of its argument. |
| OR | Returns TRUE if any of its arguments evaluate to TRUE, and returns FALSE if all of its arguments evaluate to FALSE. |
| REDUCE | Reduces an array to an accumulated value by applying a LAMBDA to each value and returning the total value in the accumulator. |
| SCAN | Scans an array by applying a LAMBDA to each value and returns an array that has each intermediate value. |
| SWITCH | Evaluates an expression against a list of values and returns the result corresponding to the first matching value. If there is no match, an optional default value may be returned. |
| TRUE | Returns the logical value TRUE. |
| XOR | Returns TRUE if an odd number of its arguments evaluate to TRUE, and FALSE if an even number of its arguments evaluate to TRUE. |
| ADDRESS | Obtain the address of a cell in a worksheet, given specified row and column numbers. For example, ADDRESS(2,3) returns $C$2. As another example, ADDRESS(77,300) returns $KN$77. You can use other functions, such as the ROW and COLUMN functions, to provide the row and column number arguments for the ADDRESS function. |
| AREAS | Returns the number of areas in a reference |
| CHOOSE | Chooses a value from a list of values. |
| CHOOSECOLS | Returns the specified columns from an array |
| CHOOSEROWS | Returns the specified rows from an array |
| COLUMN | Returns the column number of the given cell reference. |
| COLUMNS | Returns the number of columns in an array or reference. |
| DROP | Excludes a specified number of rows or columns from the start or end of an array |
| EXPAND | Expands or pads an array to specified row and column dimensions |
| FILTER | The FILTER function allows you to filter a range of data based on criteria you define. |
| FORMULATEXT | Returns the formula at the given reference as text |
| GETPIVOTDATA | Returns data stored in a PivotTable report |
| HLOOKUP | Searches for a value in the top row of a table or an array of values, and then returns a value in the same column from a row you specify in the table or array. Use HLOOKUP when your comparison values are located in a row across the top of a table of data, and you want to look down a specified number of rows. Use VLOOKUP when your comparison values are located in a column to the left of the data you want to find. |
| HSTACK | Appends arrays horizontally and in sequence to return a larger array |
| HYPERLINK | Creates a hyperlink inside a cell. |
| IMAGE | Current Channel |
| INDEX | The INDEX function returns a value or the reference to a value from within a table or range. |
| INDIRECT | Returns the reference specified by a text string. References are immediately evaluated to display their contents. |
| LOOKUP | When you need to look in a single row or column and find a value from the same position in a second row or column |
| MATCH | The MATCH function searches for a specified item in a range of cells, and then returns the relative position of that item in the range. |
| OFFSET | Returns a reference offset from a given reference |
| ROW | Returns the row number of a reference |
| ROWS | Returns the number of rows in an array or reference. |
| RTD | Retrieves real-time data from a program that supports COM automation |
| SORT | Sorts the contents of a range or array |
| SORTBY | Sorts the contents of a range or array based on the values in a corresponding range or array |
| TAKE | Returns a specified number of contiguous rows or columns from the start or end of an array |
| TOCOL | Returns the array in a single column |
| TOROW | Returns the array in a single row |
| TRANSPOSE | Returns the transpose of an array |
| UNIQUE | Returns a list of unique values in a list or range |
| VLOOKUP | Use VLOOKUP when you need to find things in a table or a range by row. For example, look up a price of an automotive part by the part number, or find an employee name based on their employee ID. |
| VSTACK | Appends arrays vertically and in sequence to return a larger array |
| WRAPCOLS | Wraps the provided row or column of values by columns after a specified number of elements |
| WRAPROWS | Wraps the provided row or column of values by rows after a specified number of elements |
| XLOOKUP | Searches a range or an array, and returns an item corresponding to the first match it finds. If a match doesn't exist, then XLOOKUP can return the closest (approximate) match. |
| XMATCH | Searches for a specified item in an array or range of cells, and then returns the item's relative position. |
| ABS | Returns the absolute value of a number. The absolute value of a number is the number without its sign. |
| ACOS | Returns the arccosine, or inverse cosine, of a number. The arccosine is the angle whose cosine is number. The returned angle is given in radians in the range 0 (zero) to pi. |
| ACOSH | Returns the inverse hyperbolic cosine of a number. The number must be greater than or equal to 1. The inverse hyperbolic cosine is the value whose hyperbolic cosine is number, so ACOSH(COSH(number)) equals number. |
| ACOT | Returns the principal value of the arccotangent, or inverse cotangent, of a number. |
| ACOTH | Returns the hyperbolic arccotangent of a number |
| AGGREGATE | Returns an aggregate in a list or database |
| ARABIC | Converts a Roman numeral to an Arabic numeral. |
| ASIN | Returns the arcsine, or inverse sine, of a number. The arcsine is the angle whose sine is number . The returned angle is given in radians in the range -pi/2 to pi/2. |
| ASINH | Returns the inverse hyperbolic sine of a number. The inverse hyperbolic sine is the value whose hyperbolic sine is number , so ASINH(SINH(number)) equals number . |
| ATAN | Returns the arctangent of a number. |
| ATAN2 | Returns the arctangent from x- and y-coordinates. |
| ATANH | Returns the inverse hyperbolic tangent of a number. Number must be between -1 and 1 (excluding -1 and 1). The inverse hyperbolic tangent is the value whose hyperbolic tangent is number , so ATANH(TANH(number)) equals number . |
| BASE | Converts a number into a text representation with the given radix (base). |
| CEILING | Rounds a number to the nearest integer or to the nearest multiple of significance |
| CEILING_MATH | Rounds a number up, to the nearest integer or to the nearest multiple of significance |
| CEILING_PRECISE | Rounds a number the nearest integer or to the nearest multiple of significance. Regardless of the sign of the number, the number is rounded up. |
| COMBIN | Returns the number of combinations for a given number of objects |
| COMBINA | Returns the number of combinations with repetitions for a given number of items |
| COS | Returns the cosine of a number. |
| COSH | Returns the hyperbolic cosine of a number |
| COT | Returns the cotangent of an angle |
| COTH | Returns the hyperbolic cotangent of a number |
| CSC | Returns the cosecant of an angle |
| CSCH | Returns the hyperbolic cosecant of an angle |
| DECIMAL | Converts a text representation of a number in a given base into a decimal number |
| DEGREES | Converts radians to degrees |
| EVEN | Rounds a number up to the nearest even integer |
| EXP | Returns e raised to the power of a given number |
| FACT | Returns the factorial of a number |
| FACTDOUBLE | Returns the double factorial of a number |
| FLOOR | Rounds a number down, toward zero |
| FLOOR_MATH | Rounds a number down, to the nearest integer or to the nearest multiple of significance |
| FLOOR_PRECISE | Rounds a number down to the nearest integer or to the nearest multiple of significance. Regardless of the sign of the number, the number is rounded down. |
| GCD | Returns the greatest common divisor |
| INT | Rounds a number down to the nearest integer |
| ISO_CEILING | Returns a number that is rounded up to the nearest integer or to the nearest multiple of significance |
| LCM | Returns the least common multiple |
| LN | Returns the natural logarithm of a number |
| LOG | Returns the logarithm of a number to a specified base |
| LOG10 | Returns the base-10 logarithm of a number |
| MDETERM | Returns the matrix determinant of an array |
| MINVERSE | Returns the matrix inverse of an array |
| MMULT | Returns the matrix product of two arrays |
| MOD | Returns the remainder after number is divided by divisor. The result has the same sign as divisor. |
| MROUND | Returns a number rounded to the desired multiple |
| MULTINOMIAL | Returns the multinomial of a set of numbers |
| MUNIT | Returns the unit matrix or the specified dimension |
| ODD | Rounds a number up to the nearest odd integer |
| PI | Returns the value of pi |
| POWER | Returns the result of a number raised to a power. |
| PRODUCT | Multiplies all the numbers given as arguments and returns the product. |
| QUOTIENT | Returns the integer portion of a division |
| RADIANS | Converts degrees to radians |
| RAND | Returns a random number between 0 and 1 |
| RANDARRAY | Returns an array of random numbers between 0 and 1. However, you can specify the number of rows and columns to fill, minimum and maximum values, and whether to return whole numbers or decimal values. |
| RANDBETWEEN | Returns a random number between the numbers you specify |
| ROMAN | Converts an Arabic numeral to Roman, as text |
| ROUND | Rounds a number to a specified number of digits |
| ROUNDBANK | Rounds a number in banker's rounding |
| ROUNDDOWN | Rounds a number down, toward zero |
| ROUNDUP | Rounds a number up, away from zero |
| SEC | Returns the secant of an angle |
| SECH | Returns the hyperbolic secant of an angle |
| SERIESSUM | Returns the sum of a power series based on the formula |
| SEQUENCE | Generates a list of sequential numbers in an array, such as 1, 2, 3, 4 |
| SIGN | Returns the sign of a number |
| SIN | Returns the sine of the given angle |
| SINH | Returns the hyperbolic sine of a number |
| SQRT | Returns a positive square root |
| SQRTPI | Returns the square root of (number * pi) |
| SUBTOTAL | Returns a subtotal in a list or database. |
| SUM | You can add individual values, cell references or ranges or a mix of all three. |
| SUMIF | Sum the values in a range that meet criteria that you specify. |
| SUMIFS | Adds all of its arguments that meet multiple criteria. |
| SUMPRODUCT | Returns the sum of the products of corresponding array components |
| SUMSQ | Returns the sum of the squares of the arguments |
| SUMX2MY2 | Returns the sum of the difference of squares of corresponding values in two arrays |
| SUMX2PY2 | Returns the sum of the sum of squares of corresponding values in two arrays |
| SUMXMY2 | Returns the sum of squares of differences of corresponding values in two arrays |
| TAN | Returns the tangent of a number. |
| TANH | Returns the hyperbolic tangent of a number. |
| TRUNC | Truncates a number to an integer |
| AVEDEV | Returns the average of the absolute deviations of data points from their mean. |
| AVERAGE | Returns the average (arithmetic mean) of the arguments. |
| AVERAGE_WEIGHTED | The AVERAGE.WEIGHTED function finds the weighted average of a set of values, given the values and the corresponding weights. |
| AVERAGEA | Returns the average of its arguments, including numbers, text, and logical values. |
| AVERAGEIF | Returns the average (arithmetic mean) of all the cells in a range that meet a given criteria. |
| AVERAGEIFS | Returns the average (arithmetic mean) of all cells that meet multiple criteria. |
| BETA_DIST | Returns the beta cumulative distribution function |
| BETA_INV | Returns the inverse of the cumulative distribution function for a specified beta distribution |
| BINOM_DIST | Returns the individual term binomial distribution probability |
| BINOM_DIST_RANGE | Returns the probability of a trial result using a binomial distribution |
| BINOM_INV | Returns the smallest value for which the cumulative binomial distribution is less than or equal to a criterion value |
| CHISQ_DIST | Returns the left-tailed probability of the chi-squared distribution. |
| CHISQ_DIST_RT | Returns the right-tailed probability of the chi-squared distribution. |
| CHISQ_INV | Returns the inverse of the left-tailed probability of the chi-squared distribution. |
| CHISQ_INV_RT | Returns the inverse of the right-tailed probability of the chi-squared distribution. |
| CHISQ_TEST | Returns the test for independence |
| CONFIDENCE_NORM | Returns the confidence interval for a population mean, using a normal distribution. |
| CONFIDENCE_T | Returns the confidence interval for a population mean, using a Student's t distribution |
| CORREL | Returns the correlation coefficient between two data sets |
| COUNT | Counts the number of cells that contain numbers, and counts numbers within the list of arguments. |
| COUNTA | Counts cells containing any type of information, including error values and empty text ("") If you do not need to count logical values, text, or error values |
| COUNTBLANK | Counts the number of blank cells within a range. |
| COUNTIF | Counts the number of cells within a range that meet the given criteria. |
| COUNTIFS | Counts the number of cells within a range that meet multiple criteria. |
| COVARIANCE_P | Returns population covariance, the average of the products of deviations for each data point pair in two data sets. |
| COVARIANCE_S | Returns the sample covariance, the average of the products of deviations for each data point pair in two data sets. |
| DEVSQ | Returns the sum of squares of deviations |
| EXPON_DIST | Returns the exponential distribution |
| F_DIST | Returns the F probability distribution |
| F_DIST_RT | Returns the (right-tailed) F probability distribution |
| F_INV | Returns the inverse of the F probability distribution |
| F_INV_RT | Returns the inverse of the (right-tailed) F probability distribution |
| F_TEST | Returns the result of an F-test |
| FISHER | Returns the Fisher transformation |
| FISHERINV | Returns the inverse of the Fisher transformation |
| FORECAST | Returns a value along a linear trend |
| FORECAST_ETS | Returns a future value based on existing (historical) values by using the AAA version of the Exponential Smoothing (ETS) algorithm |
| FORECAST_ETS_CONFINT | Returns a confidence interval for the forecast value at the specified target date |
| FORECAST_ETS_SEASONALITY | Returns the length of the repetitive pattern Excel detects for the specified time series |
| FORECAST_ETS_STAT | Returns a statistical value as a result of time series forecasting |
| FORECAST_LINEAR | Returns a future value based on existing values |
| FREQUENCY | Returns a frequency distribution as a vertical array |
| GAMMA | Returns the Gamma function value |
| GAMMA_DIST | Returns the gamma distribution |
| GAMMA_INV | Returns the inverse of the gamma cumulative distribution |
| GAMMALN | Returns the natural logarithm of the gamma function, Γ(x) |
| GAMMALN_PRECISE | Returns the natural logarithm of the gamma function, Γ(x) |
| GAUSS | Returns 0.5 less than the standard normal cumulative distribution |
| GEOMEAN | Returns the geometric mean |
| GROWTH | Returns values along an exponential trend |
| HARMEAN | Returns the harmonic mean |
| HYPGEOM_DIST | Returns the hypergeometric distribution |
| INTERCEPT | Returns the intercept of the linear regression line |
| KURT | Returns the kurtosis of a data set |
| LARGE | Returns the k-th largest value in a data set |
| LINEST | Returns the parameters of a linear trend |
| LOGEST | Returns the parameters of an exponential trend |
| LOGNORM_DIST | Returns the cumulative lognormal distribution |
| LOGNORM_INV | Returns the inverse of the lognormal cumulative distribution |
| MARGINOFERROR | This function calculates the margin of error from a range of values and a confidence level. |
| MAX | Returns the largest value in a set of values. |
| MAXA | Returns the maximum value in a list of arguments, including numbers, text, and logical values. |
| MAXIFS | Returns the maximum value among cells specified by a given set of conditions or criteria. |
| MEDIAN | Returns the median of the given numbers |
| MIN | Returns the smallest number in a set of values. |
| MINA | Returns the smallest value in a list of arguments, including numbers, text, and logical values |
| MINIFS | Returns the minimum value among cells specified by a given set of conditions or criteria. |
| MODE_MULT | Returns a vertical array of the most frequently occurring, or repetitive values in an array or range of data |
| MODE_SNGL | Returns the most common value in a data set |
| NEGBINOM_DIST | Returns the negative binomial distribution |
| NORM_DIST | Returns the normal cumulative distribution |
| NORM_INV | Returns the inverse of the normal cumulative distribution |
| NORM_S_DIST | Returns the standard normal cumulative distribution |
| NORM_S_INV | Returns the inverse of the standard normal cumulative distribution |
| PEARSON | Returns the Pearson product moment correlation coefficient |
| PERCENTILE_EXC | Returns the k-th percentile of values in a data set (Excludes 0 and 1). |
| PERCENTILE_INC | Returns the k-th percentile of values in a data set (Includes 0 and 1) |
| PERCENTRANK_EXC | Returns the percentage rank of a value in a data set (Excludes 0 and 1) |
| PERCENTRANK_INC | Returns the percentage rank of a value in a data set (Includes 0 and 1) |
| PERMUT | Returns the number of permutations for a given number of objects |
| PERMUTATIONA | Returns the number of permutations for a given number of objects (with repetitions) that can be selected from the total objects |
| PHI | Returns the value of the density function for a standard normal distribution |
| POISSON_DIST | Returns the Poisson distribution |
| PROB | Returns the probability that values in a range are between two limits |
| QUARTILE_EXC | Returns the quartile of a data set (Excludes 0 and 1) |
| QUARTILE_INC | Returns the quartile of a data set (Includes 0 and 1) |
| RANK_AVG | Returns the rank of a number in a list of numbers |
| RANK_EQ | Returns the rank of a number in a list of numbers |
| RSQ | Returns the square of the Pearson product moment correlation coefficient |
| SKEW | Returns the skewness of a distribution |
| SKEW_P | Returns the skewness of a distribution based on a population |
| SLOPE | Returns the slope of the linear regression line |
| SMALL | Returns the k-th smallest value in a data set |
| STANDARDIZE | Returns a normalized value |
| STDEV_P | Calculates standard deviation based on the entire population given as arguments (ignores logical values and text). |
| STDEV_S | Estimates standard deviation based on a sample (ignores logical values and text in the sample). |
| STDEVA | Estimates standard deviation based on a sample, including numbers, text, and logical values. |
| STDEVPA | Calculates standard deviation based on the entire population given as arguments, including text and logical values. |
| STEYX | Returns the standard error of the predicted y-value for each x in the regression |
| T_DIST | Returns the probability for the Student t-distribution |
| T_DIST_2T | Returns the probability for the Student t-distribution (two-tailed) |
| T_DIST_RT | Returns the probability for the Student t-distribution (right-tailed) |
| T_INV | Returns the inverse of the probability for the Student t-distribution |
| T_INV_2T | Returns the inverse of the probability for the Student t-distribution (two-tailed) |
| T_TEST | Returns the probability associated with a Student's t-test |
| TREND | Returns values along a linear trend |
| TRIMMEAN | Returns the mean of the interior of a data set |
| VAR_P | Calculates variance based on the entire population (ignores logical values and text in the population). |
| VAR_S | Estimates variance based on a sample (ignores logical values and text in the sample). |
| VARA | Estimates variance based on a sample, including numbers, text, and logical values |
| VARPA | Calculates variance based on the entire population, including numbers, text, and logical values |
| WEIBULL_DIST | Returns the Weibull distribution |
| Z_TEST | Returns the one-tailed probability-value of a z-test |
| ASC | Changes full-width (double-byte) English letters or katakana within a character string to half-width (single-byte) characters |
| ARRAYTOTEXT | Returns an array of text values from any specified range |
| BAHTTEXT | Converts a number to text, using the ß (baht) currency format |
| CHAR | Returns the character specified by the code number |
| CLEAN | Removes all nonprintable characters from text |
| CODE | Returns a numeric code for the first character in a text string |
| CONCAT | Combines the text from multiple ranges and/or strings, but it doesn't provide the delimiter or IgnoreEmpty arguments. |
| CONCATENATE | Joins several text items into one text item |
| DBCS | Changes half-width (single-byte) English letters or katakana within a character string to full-width (double-byte) characters |
| DOLLAR | Converts a number to text using currency format |
| EXACT | Checks to see if two text values are identical |
| FIND | Finds one text value within another (case-sensitive) |
| FINDB | Finds one text value within another (case-sensitive) |
| FIXED | Formats a number as text with a fixed number of decimals |
| LEFT | Returns the leftmost characters from a text value |
| LEFTB | Returns the leftmost characters from a text value |
| LEN | Returns the number of characters in a text string |
| LENB | Returns the number of bytes used to represent the characters in a text string. |
| LOWER | Converts text to lowercase. |
| MID | Returns a specific number of characters from a text string starting at the position you specify. |
| MIDB | Returns a specific number of characters from a text string starting at the position you specify |
| NUMBERSTRING | Convert numbers to Chinese strings |
| NUMBERVALUE | Converts text to number in a locale-independent manner |
| PHONETIC | Extracts the phonetic (furigana) characters from a text string |
| PROPER | Capitalizes the first letter in each word of a text value |
| REGEXEXTRACT | Extracts the first matching substrings according to a regular expression. |
| REGEXMATCH | Whether a piece of text matches a regular expression. |
| REGEXREPLACE | Replaces part of a text string with a different text string using regular expressions. |
| REPLACE | Replaces characters within text |
| REPLACEB | Replaces characters within text |
| REPT | Repeats text a given number of times |
| RIGHT | Returns the rightmost characters from a text value |
| RIGHTB | Returns the rightmost characters from a text value |
| SEARCH | Finds one text value within another (not case-sensitive) |
| SEARCHB | Finds one text value within another (not case-sensitive) |
| SUBSTITUTE | Substitutes new text for old text in a text string |
| T | Converts its arguments to text |
| TEXT | Formats a number and converts it to text |
| TEXTAFTER | Returns text that occurs after given character or string |
| TEXTBEFORE | Returns text that occurs before a given character or string |
| TEXTJOIN | Text: Combines the text from multiple ranges and/or strings |
| TEXTSPLIT | Splits text strings by using column and row delimiters |
| TRIM | Removes all spaces from text except for single spaces between words. |
| UNICHAR | Returns the Unicode character that is references by the given numeric value |
| UNICODE | Returns the number (code point) that corresponds to the first character of the text |
| UPPER | Converts text to uppercase |
| VALUE | Converts a text argument to a number |
| VALUETOTEXT | Returns text from any specified value |
| CALL | Calls a procedure in a dynamic link library or code resource |
| EUROCONVERT | Converts a number to euros, converts a number from euros to a euro member currency, or converts a number from one euro member currency to another by using the euro as an intermediary (triangulation) |
| REGISTER_ID | Returns the register ID of the specified dynamic link library (DLL) or code resource that has been previously registered |
| ENCODEURL | The ENCODEURL function returns a URL-encoded string, replacing certain non-alphanumeric characters with the percentage symbol (%) and a hexadecimal number. |
| FILTERXML | The FILTERXML function returns specific data from XML content by using the specified xpath. |
| WEBSERVICE | The WEBSERVICE function returns data from a web service on the Internet or Intranet. |
Facade API
完整的 Facade API 見 FFormula。
導入
外掛模式提示
只有外掛模式需要手動引入 Facade 包。預設模式已內建對應的 Facade 包,無需額外引入。
import '@univerjs/engine-formula/facade'import '@univerjs/sheets-formula/facade'import '@univerjs/sheets-formula-ui/facade'開啟範圍選擇器
@univerjs/sheets-formula-ui/facade 會新增 univerAPI.showRangeSelectorDialog。自定義 UI 需要使用者選擇一個或多個區域時,可以使用該 API,其開啟的選擇器與公式相關面板使用的是同一個。
const workbook = univerAPI.getActiveWorkbook()const worksheet = workbook?.getActiveSheet()if (workbook && worksheet) { await univerAPI.showRangeSelectorDialog({ unitId: workbook.getId(), subUnitId: worksheet.getSheetId(), initialValue: [ { unitId: workbook.getId(), sheetName: worksheet.getSheetName(), range: worksheet.getRange('A1:B2').getRange(), }, ], maxRangeCount: 2, supportAcrossSheet: true, callback: (ranges, isCancel) => { console.log(ranges, isCancel) }, })}執行公式計算
const formulaEngine = univerAPI.getFormula()formulaEngine.executeCalculation()停止公式計算
const formulaEngine = univerAPI.getFormula()formulaEngine.stopCalculation()公式開始計算
// 監聽公式計算開始事件const formulaEngine = univerAPI.getFormula()formulaEngine.calculationStart((forceCalculate) => { console.log(forceCalculate)})公式計算中
// 監聽公式計算中事件const formulaEngine = univerAPI.getFormula()formulaEngine.calculationProcessing((stageInfo) => { console.log(stageInfo)})公式計算結束
// 監聽公式計算結束事件const formulaEngine = univerAPI.getFormula()formulaEngine.calculationEnd((functionsExecutedState) => { console.log(functionsExecutedState)})公式計算結果應用
// 監聽公式計算結果應用事件const formulaEngine = univerAPI.getFormula()formulaEngine.calculationResultApplied((result) => { console.log(result)})// 等待公式計算結果應用完成await formulaEngine.onCalculationResultApplied()設定初始化資料時公式的計算模式
const formulaEngine = univerAPI.getFormula()formulaEngine.setInitialFormulaComputing(CalculationMode.FORCED)如果該 API 在 Starting 生命週期之後才被呼叫,則要等到下次建立 Univer Sheet 時才生效。
如果希望它在本次初始化時生效,可以在 Ready 生命週期之前呼叫,例如:
univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => { if (stage === LifecycleStages.Starting) { const formulaEngine = univerAPI.getFormula() formulaEngine.setInitialFormulaComputing(CalculationMode.FORCED) }})反覆運算
迭代計算按工作簿配置,儲存在快照的 calculationSettings 欄位中。該功能預設關閉,此時迴圈引用公式保留快取值,沒有快取值則使用零。僅在模型確實有意包含迴圈引用時才需要啟用。
| 選項 | 預設值 | 行為 |
|---|---|---|
iterativeCalculation | false | 對迴圈引用做迭代求值。 |
maxIterations | 100 | 1 到 32767 之間的整數。 |
maxChange | 0.001 | 有限的正數,用作收斂閾值。迴圈組中每個數值結果的變化都不超過這個值時停止迭代。 |
三個設定需要一起透過工作簿 Facade 提交。該命令支援撤銷、重做和協同,工作簿不存在或不可編輯時返回 false。無效的設定會歸一為預設值。
const workbook = univerAPI.getActiveWorkbook()if (!workbook) throw new Error('No active workbook')const applied = workbook.setCalculationSettings({ iterativeCalculation: true, maxIterations: 100, maxChange: 0.001,})if (!applied) throw new Error('Could not update calculation settings')console.log(workbook.getCalculationSettings())呼叫 createWorkbook() 時也可以傳入 calculationSettings。每個工作簿儲存各自的設定。公式工具欄的「計算選項」中提供了相同的控制元件。
計算結果顯示之後,才能讀取迴圈引用診斷資訊。getCircularReferences() 不會觸發計算,返回結果包含工作表 ID、從零開始的行列座標、迴圈組 ID、迭代次數,以及可取得時的收斂資訊。
const formula = univerAPI.getFormula()formula.executeCalculation()await formula.onCalculationResultApplied()console.table(workbook.getCircularReferences())取得公式字串的計算結果
非同步執行一批公式,並取得計算結果:
const formulaEngine = univerAPI.getFormula()const formulas = { Book1: { Sheet1: { 2: { 3: [ // 完整公式: '=SUM(A1:A10) + SQRT(D7)', // 分解後的子公式(每個都可以獨立計算): 'SUM(A1:A10)', // 子公式1 'SQRT(D7)', // 子公式2 'A1:A10', // 範圍參考 'D7', // 單元格參考 ], }, 4: { 5: ['=A2 + B2 + SQRT(C5)', 'A2', 'B2', 'SQRT(C5)'], }, }, },}const result = await formulaEngine.executeFormulas(formulas)console.log(result)自訂公式
Univer 支援自定義公式,實現方式見自定義公式。
常見問題
HYPERLINK 公式儲存格無法操作超連結
需要引入 Univer Sheets 的超連結外掛,詳見超連結。
公式值的語意
ISBLANK(A1) 檢查的是引用的單元格是否包含內容,而不僅僅是顯示結果是否為空。已清空的單元格(即使保留了格式)視為空,返回 "" 的公式則不算空。直接量 ISBLANK("") 同樣返回 FALSE。UNIQUE 比較文字時不區分大小寫,並保留首次出現的拼寫。PROPER 能識別 Unicode 字母,包括帶重音的拉丁字母、希臘字母和西裡爾字母。AVERAGE 會聚合 FILTER 等函式返回的完整陣列。
=ISBLANK("") → FALSE=UNIQUE({"Univer";"univer";"Sheets"}) → {"Univer";"Sheets"}=PROPER("élise müller") → Élise Müller=AVERAGE({3;7}) → 5你覺得這篇文檔如何?