ይዞታዎች

# Using Calc Functions in Macros

In addition to the native BASIC functions, you can call Calc functions in your macros and scripts and set Calc functions in cell formulas.

## Calling Internal Calc functions in Basic

Use the CreateUnoService function to access the com.sun.star.sheet.FunctionAccess service.

### ለምሳሌ:

The example below creates a function named MyVlook that calls the VLOOKUP Calc function over a data array passed as argument and returns the value found by the function.

        Function MyVlook(Lookup, DataArray As Object, Index As Integer, SortedRangeLookup as Byte)
            Dim oService As Object
            Set oService = CreateUnoService("com.sun.star.sheet.FunctionAccess")
            ' Always use the function name in English
            MyVlook = oService.callFunction("VLOOKUP", Array(Lookup, DataArray, Index, SortedRangeLookup))
        End Function

The macro below presents an example of how the MyVlook function can be called. It first creates a 5-by-2 data array and then calls the function MyVlook and shows the returned value using MsgBox.

        Sub CallingMyVlook()
            ' Creates a 5 by 2 array and fills it with data
            Dim myData(1 to 5, 1 to 2) as Variant
            myData(1, 1) = 1 : myData(1, 2) = "Strongly disagree"
            myData(2, 1) = 3 : myData(2, 2) = "Disagree"
            myData(3, 1) = 5 : myData(3, 2) = "Undecided"
            myData(4, 1) = 7 : myData(4, 2) = "Agree"
            myData(5, 1) = 9 : myData(5, 2) = "Strongly agree"
            ' Looks up the data array
            Dim result as String
            result = MyVlook(4, myData, 2, 1)
            ' Shows the message "Disagree"
            MsgBox result
        End Sub

## Setting Cell Formulas Containing Internal Calc Functions

Use the formula text string to add a formula to a spreadsheet cell.

All Calc functions must be expressed with their English names.

### ለምሳሌ:

    Sub AssignFormulaToCell
    REM Add a formula to cell A1. Function name must be in English.
        oCell = ThisComponent.Sheets.getByIndex(0).getCellRangeByName("A1")
        oCell.Formula = "=SUM(B1:B10)"
    REM Cell A1 displays the localized function name
    End Sub

## Calling Add-In Calc Functions in BASIC

The Calc Add-In functions are in the UNO services com.sun.star.sheet.addin.Analysis, com.sun.star.sheet.addin.DateFunctions and com.sun.star.sheet.addin.PricingFunctions.

### ለምሳሌ:

    REM Example calling Add-in function SQRTPI
    Function MySQRTPI(arg as double) as double
       Dim oService as Object
       oService = CreateUnoService("com.sun.star.sheet.addin.Analysis")
       MySQRTPI = oService.getSqrtPi(arg)
    End Function

## Setting Cell Formulas with Add-In Functions

The Add-In function must be expressed by its UNO service name.

### ለምሳሌ:

    Sub AssignAddInFormulaToCell
    REM Add an Add-In formula to cell A1. Function name is the UNO service name.
        oCell = ThisComponent.Sheets.getByIndex(0).getCellRangeByName("A1")
        oCell.Formula = "=com.sun.star.sheet.addin.Analysis.getBin2Dec(B1)"
    REM Cell A1 displays the localized function name
    End Sub

## UNO Service Names for Analysis Add-In Functions

The table below presents a list of all Calc Analysis Add-In functions and their respective UNO service names.

Calc Function name | UNO service name
--- | ---
ACCRINT | com.sun.star.sheet.addin.Analysis.getAccrint
ውዝፍ ወለድ | com.sun.star.sheet.addin.Analysis.getAccrintm
የ እርጅና ጊዜ በ ዝግታ የሚቀንሰው | com.sun.star.sheet.addin.Analysis.getAmordegrc
እርጅና በ ተወሰነ ጊዜ ውስጥ | com.sun.star.sheet.addin.Analysis.getAmorlinc
ቤሴልI | com.sun.star.sheet.addin.Analysis.getBesseli
የ ቤሴልJ ተግባር ማስሊያ | com.sun.star.sheet.addin.Analysis.getBesselj
የ ቤሴልK | com.sun.star.sheet.addin.Analysis.getBesselk
የ ቤሴልY | com.sun.star.sheet.addin.Analysis.getBessely
ባይነሪ2ዴሲማል | com.sun.star.sheet.addin.Analysis.getBin2Dec
ባይነሪ2ሄክስ | com.sun.star.sheet.addin.Analysis.getBin2Hex
ባይነሪ2ኦክታል | com.sun.star.sheet.addin.Analysis.getBin2Oct
ውስብስብ | com.sun.star.sheet.addin.Analysis.getComplex
መቀየሪያ | com.sun.star.sheet.addin.Analysis.getConvert
የ ስምምነት ቀን የያዘው ቲኬት ያለፈው | com.sun.star.sheet.addin.Analysis.getCoupdaybs
የ ስምምነት ቀን የያዘው ቲኬት | com.sun.star.sheet.addin.Analysis.getCoupdays
የ ስምምነት ቀን የያዘው ቲኬት ማስማሚያ | com.sun.star.sheet.addin.Analysis.getCoupdaysnc
ከ ስምምነት ቀን በኋላ | com.sun.star.sheet.addin.Analysis.getCoupncd
የ ኩፖን ቁጥር | com.sun.star.sheet.addin.Analysis.getCoupnum
ከ ስምምነቱ በፊት ያለፈው ኩፖን ቀን | com.sun.star.sheet.addin.Analysis.getCouppcd
ከ ጠቅላላ እዳው የ ተከፈለው ወለድ | com.sun.star.sheet.addin.Analysis.getCumipmt
ጠቅላላ የ ተከፈለው ከ እዳው | com.sun.star.sheet.addin.Analysis.getCumprinc
ዴሲማል2ባይነሪ | com.sun.star.sheet.addin.Analysis.getDec2Bin
ዴሲማል2ሄክሳ ዴሲማል | com.sun.star.sheet.addin.Analysis.getDec2Hex
ዴሲማል2ኦክታል | com.sun.star.sheet.addin.Analysis.getDec2Oct
ሁለት ቁጥሮች እኩል እንደሆኑ ያለበዚያ 0 ይመልሳል | com.sun.star.sheet.addin.Analysis.getDelta
ቅናሽ | com.sun.star.sheet.addin.Analysis.getDisc
ዴሲማል ወደ ክፍልፋይ | com.sun.star.sheet.addin.Analysis.getDollarde
ዴሲማል ወደ ክፍልፋይ | com.sun.star.sheet.addin.Analysis.getDollarfr
የሚፈጀው ጊዜ | com.sun.star.sheet.addin.Analysis.getDuration
የ ቀን እና ወር ቁጥር | com.sun.star.sheet.addin.Analysis.getEdate
ውጤት | com.sun.star.sheet.addin.Analysis.getEffect
የ ወር መጨረሻ | com.sun.star.sheet.addin.Analysis.getEomonth
የ ስህተት ተግባር | com.sun.star.sheet.addin.Analysis.getErf
የ ስህተት ተግባር አስተያየት | com.sun.star.sheet.addin.Analysis.getErfc
የ ቁጥር ድርብ ፋክቶሪያል | com.sun.star.sheet.addin.Analysis.getFactdouble
የ ወደፊት ዋጋ እቅድ | com.sun.star.sheet.addin.Analysis.getFvschedule
ትልቁ የ ጋራ አካፋይ | com.sun.star.sheet.addin.Analysis.getGcd
ይበልጣል ወይንም እኩል ነው | com.sun.star.sheet.addin.Analysis.getGestep
ሄክሳ2ባይነሪ | com.sun.star.sheet.addin.Analysis.getHex2Bin
ሄክሳ2ዴሲማል | com.sun.star.sheet.addin.Analysis.getHex2Dec
ሄክሳ2ኦክታል | com.sun.star.sheet.addin.Analysis.getHex2Oct
ፍጹም ዋጋ ለ ውስብስብ ቁጥር | com.sun.star.sheet.addin.Analysis.getImabs
የ ውስብስብ ቁጥር ኢማጂነሪ አካል | com.sun.star.sheet.addin.Analysis.getImaginary
የ ውስብስብ ቁጥር ክርክር | com.sun.star.sheet.addin.Analysis.getImargument
ውስብስብ ማያያዣ ለ ውስብስብ ቁጥር | com.sun.star.sheet.addin.Analysis.getImconjugate
የ ውስብስብ ቁጥር ኮሳይን | com.sun.star.sheet.addin.Analysis.getImcos
የ ውስብስብ ቁጥር ሀይፐርቦሊክ ኮሳይን | com.sun.star.sheet.addin.Analysis.getImcosh
የ ውስብስብ ቁጥር ኮታንጀንት | com.sun.star.sheet.addin.Analysis.getImcot
የ ውስብስብ ቁጥር ኮሴካንት | com.sun.star.sheet.addin.Analysis.getImcsc
የ ውስብስብ ቁጥር ሀይፐርቦሊክ ኮሴካንት | com.sun.star.sheet.addin.Analysis.getImcsch
ውስብስብ ቁጥር ሲካፈል በ ሌላ | com.sun.star.sheet.addin.Analysis.getImdiv
የ ውስብስብ ቁጥር ኤክስፖነንት | com.sun.star.sheet.addin.Analysis.getImexp
ተፈጥሯዊ ሎጋሪዝም ለ ውስብስብ ቁጥር | com.sun.star.sheet.addin.Analysis.getImln
በ ቤዝ 10 ሎጋሪዝም ለ ውስብስብ ቁጥር | com.sun.star.sheet.addin.Analysis.getImlog10
በ ቤዝ 2 ሎጋሪዝም ለ ውስብስብ ቁጥር | com.sun.star.sheet.addin.Analysis.getImlog2
ውስብስብ ቁጥር ሲነሳ በ ሀይል | com.sun.star.sheet.addin.Analysis.getImpower
የ ውስብስብ ቁጥር ውጤት | com.sun.star.sheet.addin.Analysis.getImproduct
የ ውስብስብ ቁጥር ሪያል አካል | com.sun.star.sheet.addin.Analysis.getImreal
የ ውስብስብ ቁጥር ሴካንት | com.sun.star.sheet.addin.Analysis.getImsec
የ ውስብስብ ቁጥር ሀይፐርቦሊክ ሴካንት | com.sun.star.sheet.addin.Analysis.getImsech
የ ውስብስብ ቁጥር ሳይን | com.sun.star.sheet.addin.Analysis.getImsin
የ ውስብስብ ቁጥር ሀይፐርቦሊክ ሳይን | com.sun.star.sheet.addin.Analysis.getImsinh
ውስብስብ ስኴር ሩት | com.sun.star.sheet.addin.Analysis.getImsqrt
ልዩነት በ 2 ውስብስብ ቁጥር መካከል | com.sun.star.sheet.addin.Analysis.getImsub
የ ውስብስብ ቁጥር ድምር | com.sun.star.sheet.addin.Analysis.getImsum
የ ውስብስብ ቁጥር ታንጀንት | com.sun.star.sheet.addin.Analysis.getImtan
የ ወለድ መጠን | com.sun.star.sheet.addin.Analysis.getIntrate
ሙሉ ነው | com.sun.star.sheet.addin.Analysis.getIseven
ጎዶሎ ነው | com.sun.star.sheet.addin.Analysis.getIsodd
ትንሹ የ ጋራ አካፋይ | com.sun.star.sheet.addin.Analysis.getLcm
የተሻሻለው ደህንነት የሚፈጀው ጊዜ | com.sun.star.sheet.addin.Analysis.getMduration
ማጠጋጊያ ወደ ቅርቡ አካፋይ | com.sun.star.sheet.addin.Analysis.getMround
መልቲኖሚያል | com.sun.star.sheet.addin.Analysis.getMultinomial
የ ተጣሩ የ ስራ ቀኖች | com.sun.star.sheet.addin.Analysis.getNetworkdays
አነስተኛ | com.sun.star.sheet.addin.Analysis.getNominal
ኦክታል2ባይነሪ | com.sun.star.sheet.addin.Analysis.getOct2Bin
ኦክታል2ዴሲማል | com.sun.star.sheet.addin.Analysis.getOct2Dec
ኦክታል2ሄክሳ ዴሲማል | com.sun.star.sheet.addin.Analysis.getOct2Hex
ጎዶሎ ዋጋ | com.sun.star.sheet.addin.Analysis.getOddfprice
የ ደህንነት ትርፍ | com.sun.star.sheet.addin.Analysis.getOddfyield
ጎዶሎ ዋጋ | com.sun.star.sheet.addin.Analysis.getOddlprice
የ ደህንነት ትርፍ | com.sun.star.sheet.addin.Analysis.getOddlyield
ዋጋ | com.sun.star.sheet.addin.Analysis.getPrice
የ ዋጋ ቅናሽ | com.sun.star.sheet.addin.Analysis.getPricedisc
የ ደህንነት የ ፊት ዋጋ | com.sun.star.sheet.addin.Analysis.getPricemat
የ ክፍያ ውጤት | com.sun.star.sheet.addin.Analysis.getQuotient
በደፈናው መካከል | com.sun.star.sheet.addin.Analysis.getRandbetween
ተቀብያለሁ | com.sun.star.sheet.addin.Analysis.getReceived
ተከታታይ ድምር | com.sun.star.sheet.addin.Analysis.getSeriessum
ስኴር ሩት ፓይ | com.sun.star.sheet.addin.Analysis.getSqrtpi
የ ቦንድ ትርፍ ለ ትሬዠሪ | com.sun.star.sheet.addin.Analysis.getTbilleq
የ ተቀማጭ ገንዘብ ዋጋ | com.sun.star.sheet.addin.Analysis.getTbillprice
የ ተቀማጭ ገንዘብ ትርፍ | com.sun.star.sheet.addin.Analysis.getTbillyield
የ ሳምንት ቁጥር | com.sun.star.sheet.addin.Analysis.getWeeknum
የ ስራ ቀን | com.sun.star.sheet.addin.Analysis.getWorkday
የ ውስጥ ገንዘብ ስርአቱን ለማይከተል ይመልሳል | com.sun.star.sheet.addin.Analysis.getXirr
የ ኢንቬስትመንት ዋጋ ስርአት ለማይከተል | com.sun.star.sheet.addin.Analysis.getXnpv
አመት ክፍልፋይ | com.sun.star.sheet.addin.Analysis.getYearfrac
ትርፍ | com.sun.star.sheet.addin.Analysis.getYield
ምንም-ወለድ-የሌለው የ ተቀነሰ ቦንድ | com.sun.star.sheet.addin.Analysis.getYielddisc
ለ ቦንድ ትርፍ የሚከፈለውን ወለድ ማስሊያ በሚደርስ ጊዜ | com.sun.star.sheet.addin.Analysis.getYieldmat

## UNO Service Names for Date Add-In Functions

The table below presents a list of all Calc Date Add-In functions and their respective UNO service names.

Calc Function name | UNO service name
--- | ---
ቀኖች በ ወር ውስጥ | com.sun.star.sheet.addin.DateFunctions.getDaysInMonth
ቀኖች በ አመት ውስጥ | com.sun.star.sheet.addin.DateFunctions.getDaysInMonth
ወሮች | com.sun.star.sheet.addin.DateFunctions.getDiffMonths
ሳምንቶች | com.sun.star.sheet.addin.DateFunctions.getDiffWeeks
አመቶች | com.sun.star.sheet.addin.DateFunctions.getDiffYears
ማዞሪያ በ 13 | com.sun.star.sheet.addin.DateFunctions.getRot13
ሳምንቶች በ አመት ውስጥ | com.sun.star.sheet.addin.DateFunctions.getWeeksInYear

## UNO Service Names for Pricing Add-In Functions

The table below presents a list of all Calc Pricing Add-In functions and their respective UNO service names.

Calc Function name | UNO service name
--- | ---
በ ምርጫ_መከልከያ | com.sun.star.sheet.addin.PrincingFunctions.getOptBarrier
ምናልባት_ንብረቱ_ገደብ ላይ ይደርስ እንደሆን | com.sun.star.sheet.addin.PrincingFunctions.getOptProbHit
ምናልባት_ንብረቱ_በ ክፍያ ጊዜ ገደብ ላይ ይደርስ እንደሆን | com.sun.star.sheet.addin.PrincingFunctions.getOptProbInMoney
በ ምርጫ_መንኪያ | com.sun.star.sheet.addin.PrincingFunctions.getOptTouch

የ ተዛመዱ አርእስቶች

CreateUnoService Function