Add-in Functions

The following describes and lists some of the available add-in functions.

Add-In 概念

You will also find a description of the LibreOffice Calc add-in interface in the Help. In addition, important functions and their parameters are described in the Help for the .

隨附的 Add-In

LibreOffice 包含 LibreOffice Calc 的 Add-In 介面之範例。

分析函式第一部分

分析函式第二部份

DAYSINMONTH

計算輸入日期所在月份的天數。

Syntax

DaysInMonth(Date)

Date 是指所需年度相對應月份中任何的日期。Date 參數必須是根據 LibreOffice 之語言環境所設定的有效日期。

Example

若 A1 包含 1968 年 2 月的有效日期 1968-02-17,則 =DAYSINMONTH(A1) 會傳回 29 天。

Technical information

This function is not part of the Open Document Format for Office Applications (OpenDocument) Version 1.3. Part 4: Recalculated Formula (OpenFormula) Format standard. The name space is

ORG.OPENOFFICE.DAYSINMONTH

tip

DAYSINYEAR

計算輸入日期所在年度的天數。

Syntax

DaysInYear(Date)

Date 是指相對應年度中任何的日期。Date 參數必須是根據 LibreOffice 之語言環境設定的有效日期。

Example

若 A1 包含 1968 年的有效日期 1968-02-29,則 =DAYSINYEAR(A1) 會傳回 366 天。

Technical information

This function is not part of the Open Document Format for Office Applications (OpenDocument) Version 1.3. Part 4: Recalculated Formula (OpenFormula) Format standard. The name space is

ORG.OPENOFFICE.DAYSINYEAR

tip

ISLEAPYEAR

決定是否為閏年。如果是,函式會傳回值 1 (TRUE);如果不是則會傳回 0 (FALSE)。

Syntax

ISLEAPYEAR("Date")

Date specifies whether a given date falls within a leap year. The Date parameter must be a valid date.

warning

Microsoft Excel wrongly assumes year 1900 to be a leap year and considers the inexistent day of 1900-02-29 as valid in date calculations. Dates prior to 1900-03-01 are therefore different in Excel and Calc.


Example

若 A1 包含 1968-02-29 (使用您語言環境設定的有效日期 1968 年 2 月 29 日),則 =ISLEAPYEAR(A1) 會傳回 1。

You may also use =ISLEAPYEAR(DATE(1968;2;29)) or =ISLEAPYEAR("1968-02-29") giving the date string in the ISO 8601 notation.

請勿使用 =ISLEAPYEAR(2/29/68),因為這會先計算 2 除以 29 除以 68,然後再以此小數目作為連續日期數字,來計算 ISLEAPYEAR 函式。

Technical information

This function is not part of the Open Document Format for Office Applications (OpenDocument) Version 1.3. Part 4: Recalculated Formula (OpenFormula) Format standard. The name space is

ORG.OPENOFFICE.ISLEAPYEAR

tip

MONTHS

計算兩個日期相差的月數。

Syntax

MONTHS(StartDate; EndDate; Type)

StartDate 是指第一個日期

EndDate 是指第二個日期

Type 會指出差異值的類型。可能的值包括 0 (間隔) 與 1 (行事曆月份)。

Technical information

This function is not part of the Open Document Format for Office Applications (OpenDocument) Version 1.3. Part 4: Recalculated Formula (OpenFormula) Format standard. The name space is

ORG.OPENOFFICE.MONTHS

tip

ROT13

以字母順序移動字元 13 個位置以加密字元字串。 在字母 Z 之後,字母又重新開始 (旋轉)。再次將加密函式套用至結果代碼,您就可以解密文字。

Syntax

RED13(Text)

Text 是指要加密的字元字串。ROT13(ROT13(Text)) 會加密代碼。

Example

=ROT13("Gur Qbphzrag Sbhaqngvba jnf sbhaqrq va Frcgrzore 2010.") returns the string "The Document Foundation was founded in September 2010.". Notice how spaces, digits, and full stops are unaffected by ROT13.

Technical information

This function is not part of the Open Document Format for Office Applications (OpenDocument) Version 1.3. Part 4: Recalculated Formula (OpenFormula) Format standard. The name space is

ORG.OPENOFFICE.ROT13

tip

Refer to the ROT13 wiki page for more details about this function.


WEEKS

計算兩個日期相差的週數。

Syntax

WEEKS(StartDate; EndDate; Type)

StartDate is the start date in the interval.

EndDate is the end date in the interval. The end date must be greater than the start date, or else an error is returned.

Type specifies the type of difference to be calculated. Possible values are 0 (time interval) or 1 (calendar weeks).

If Type = 0 the function will assume that 7 days is equivalent to one week without considering any specific day to mark the beginning of a week.

If Type = 1 the function will consider Monday to be the first day of the week. Therefore, except for the start date, each occurrence of a Monday in the interval is counted as an additional week.

note

This function considers Monday to be the first day of the week regardless of the current locale settings.


Example

In the following examples, dates are passed as strings. However, they can also be stored in separate cells and be passed as references.

=WEEKS("01/12/2022","01/17/2022",0) returns 0 because Type was set to 0 and there are only 5 days in the interval.

=WEEKS("01/12/2022","01/19/2022",0) returns 1 because Type was set to 0 and there are 7 days in the interval.

=WEEKS("01/12/2022","01/17/2022",1) returns 1 because Type was set to 1 and the interval contains a Monday, since 01/12/2022 is a Wednesday and 01/17/2022 is a Monday.

=WEEKS("01/10/2022","01/15/2022",1) returns 0 because Type was set to 1 and the interval does not contain any Mondays, except for the start date.

Technical information

This function is not part of the Open Document Format for Office Applications (OpenDocument) Version 1.3. Part 4: Recalculated Formula (OpenFormula) Format standard. The name space is

ORG.OPENOFFICE.WEEKS

tip

WEEKSINYEAR

計算該年度中到指定日期的週數。 週數定義如下:橫跨兩年的那一週將會增加至佔有該週天數較多的那一年。

Syntax

WeeksInYear(Date)

Date 是指相對應年度中任何的日期。Date 參數必須是根據 LibreOffice 之語言環境設定的有效日期。

Example

若 A1 包含 1970 年的有效日期 1970-02-17,則 WEEKSINYEAR(A1) 會傳回 53。

Technical information

This function is not part of the Open Document Format for Office Applications (OpenDocument) Version 1.3. Part 4: Recalculated Formula (OpenFormula) Format standard. The name space is

ORG.OPENOFFICE.WEEKSINYEAR

tip

YEARS

計算兩個日期相差的年數。

Syntax

YEARS(StartDate; EndDate; Type)

StartDate 是指第一個日期

EndDate 是指第二個日期

Type 會指出差異值的類型。可能的值包括 0 (間隔) 與 1 (行事曆年度)。

Technical information

This function is not part of the Open Document Format for Office Applications (OpenDocument) Version 1.3. Part 4: Recalculated Formula (OpenFormula) Format standard. The name space is

ORG.OPENOFFICE.YEARS

tip

透過 LibreOffice API 的 Add-In

Add-ins can also be implemented through the LibreOffice API.

Please support us!