AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1056752
Accepted
Ron Piggott
Ron Piggott
Asked: 2018-07-17 19:33:39 +0800 CST2018-07-17 19:33:39 +0800 CST 2018-07-17 19:33:39 +0800 CST

LibreOffice Calc 中的美元值

  • 772

我想知道是否有办法在 LibreOffice Calc 版本 6.0.3.2 中将美元值转换为单词

$1932.19

会成为

One Thousand Nine Hundred Thirty Two Dollars And Nineteen Cents

我找到了这个功能。它在 2010 年持续更新。它不兼容。给定的例子

=MONEYTEXT(25)

退货

ERR: 504

有没有人有替代建议?

libreoffice extension functions
  • 2 2 个回答
  • 1367 Views

2 个回答

  • Voted
  1. Best Answer
    Terrance
    2018-07-17T20:13:18+08:002018-07-17T20:13:18+08:00

    这适用于 18.04 LTS 中的 LibreCalc 6.0.3.2,我已经使用 16.04 LTS 中的 6.0.5.2 对其进行了测试。


    从https://extensions.libreoffice.org/extensions/numbertext-1下载扩展

    然后转到 LibreOffice Calc 中的工具 --> 扩展管理器

    单击添加,然后选择您下载的文件。

    在此处输入图像描述

    在此处输入图像描述


    如果扩展不起作用,请检查包libreoffice-script-provider-python是否已安装,如果缺少,请安装它。


    如果您希望文本小写,则只需这样做:

    =LOWER(MONEYTEXT(1932.19))
    

    对于大写,它会相对相同:

    =UPPER(MONEYTEXT(1932.19))
    

    希望这可以帮助!

    • 6
  2. WinEunuuchs2Unix
    2018-07-17T20:22:19+08:002018-07-17T20:22:19+08:00

    在 Libreoffice Calc 中,您可以打开“宏”,它使用类似于 Microsoft Excel 的“VBA”(Visual Basic for Applications)的“BASIC”(初学者通用符号指令代码)语言。

    使用自己的宏的好处是“面向未来”。支票/支票书写的英语不会改变,但过去的一些扩展插件今天不再起作用。

    可以在此处找到最受尊敬的 BASIC 宏指南摘要。


    来自 Apache Open Office(几乎与 LibreOffice 相同):Calc Basic 中的 SpellNumber。根据作者的说法,这仍然需要调试。


    对于 Microsoft Excel:如何在 Excel 中将数字拼写或转换为英文单词?. Libreoffice 为 Excel 的 VBA(Visual Basic for Applications)提供实验性支持。因此,您可以按原样实现下面的宏,或者将其转换为 Libre Office BASIC 语法。

    Function SpellNumberToEnglish(ByVal pNumber)
    'Updateby20131113
    Dim Dollars, Cents
    arr = Array("", "", " Thousand ", " Million ", " Billion ", " Trillion ")
    pNumber = Trim(Str(pNumber))
    xDecimal = InStr(pNumber, ".")
    If xDecimal > 0 Then
        Cents = GetTens(Left(Mid(pNumber, xDecimal + 1) & "00", 2))
        pNumber = Trim(Left(pNumber, xDecimal - 1))
    End If
    xIndex = 1
    Do While pNumber <> ""
        xHundred = ""
        xValue = Right(pNumber, 3)
        If Val(xValue) <> 0 Then
            xValue = Right("000" & xValue, 3)
            If Mid(xValue, 1, 1) <> "0" Then
                xHundred = GetDigit(Mid(xValue, 1, 1)) & " Hundred "
            End If
            If Mid(xValue, 2, 1) <> "0" Then
                xHundred = xHundred & GetTens(Mid(xValue, 2))
            Else
                xHundred = xHundred & GetDigit(Mid(xValue, 3))
            End If
        End If
        If xHundred <> "" Then
            Dollars = xHundred & arr(xIndex) & Dollars
        End If
        If Len(pNumber) > 3 Then
            pNumber = Left(pNumber, Len(pNumber) - 3)
        Else
            pNumber = ""
        End If
        xIndex = xIndex + 1
    Loop
    Select Case Dollars
        Case ""
            Dollars = "No Dollars"
        Case "One"
            Dollars = "One Dollar"
        Case Else
            Dollars = Dollars & " Dollars"
    End Select
    Select Case Cents
        Case ""
            Cents = " and No Cents"
        Case "One"
            Cents = " and One Cent"
        Case Else
            Cents = " and " & Cents & " Cents"
    End Select
    SpellNumberToEnglish = Dollars & Cents
    End Function
    Function GetTens(pTens)
    Dim Result As String
    Result = ""
    If Val(Left(pTens, 1)) = 1 Then
        Select Case Val(pTens)
            Case 10: Result = "Ten"
            Case 11: Result = "Eleven"
            Case 12: Result = "Twelve"
            Case 13: Result = "Thirteen"
            Case 14: Result = "Fourteen"
            Case 15: Result = "Fifteen"
            Case 16: Result = "Sixteen"
            Case 17: Result = "Seventeen"
            Case 18: Result = "Eighteen"
            Case 19: Result = "Nineteen"
            Case Else
        End Select
    Else
    Select Case Val(Left(pTens, 1))
        Case 2: Result = "Twenty "
        Case 3: Result = "Thirty "
        Case 4: Result = "Forty "
        Case 5: Result = "Fifty "
        Case 6: Result = "Sixty "
        Case 7: Result = "Seventy "
        Case 8: Result = "Eighty "
        Case 9: Result = "Ninety "
        Case Else
    End Select
    Result = Result & GetDigit(Right(pTens, 1))
    End If
    GetTens = Result
    End Function
    Function GetDigit(pDigit)
    Select Case Val(pDigit)
        Case 1: GetDigit = "One"
        Case 2: GetDigit = "Two"
        Case 3: GetDigit = "Three"
        Case 4: GetDigit = "Four"
        Case 5: GetDigit = "Five"
        Case 6: GetDigit = "Six"
        Case 7: GetDigit = "Seven"
        Case 8: GetDigit = "Eight"
        Case 9: GetDigit = "Nine"
        Case Else: GetDigit = ""
    End Select
    End Function
    

    印度十万和千万。

    此处发布了一个 Calc 基本宏,用于将数字转换为单词:

    REM  *****  BASIC  *****
    Option Explicit
    
    Sub Main
      Print getAmountInWords("999999999.99")
    End Sub
    
    
    '********************************************************************************************************
    'Function Name      :   getAmountInWords
    'Description        :   To convert the Amount value into words(formatted as "000000000.00")
    '                       (Maximum allowed limit 999999999.99)
    'Input Parameters   :   Amount
    'Returns            :   String
    'Creat by           :   Sanjeev Meher on 9th Feb 2013
    'Specific Logic used:   None
    '********************************************************************************************************
    Public Function getAmountInWords(strAmount As String) As String
        Dim strIntPart          As String
        Dim strDecPart          As String
        Dim strCroresPart       As String
        Dim strLakhsPart        As String
        Dim strThousandsPart    As String
        Dim strHundredsPart     As String
        Dim strTensPart         As String
        Dim strOnesPart         As String
        Dim strDecTensPart      As String
        Dim strDecOnesPart      As String
        Dim strAmtWords         As String
        Dim dblIntPart          As Double
        Dim intDecPart          As Integer
        Dim strDecWords         As String
        Dim iErr As Integer
    
        'handle for typemismatch error
        '??Err.Clear
        '??On Error Resume Next
        On Error Goto BadError
        strAmount = CDbl(strAmount)
        '??If Err.Number = "13" Then
        '??    getAmountInWords = ""
        '??    Exit Function
        '??End If
        '??Err.Clear
        strAmount = Format(Trim(strAmount), "000000000.00")
    
        'if the value is negative,zero above the limit then give error message
        If Val(strAmount) < 0 Then
            getAmountInWords = ""
            Exit Function
        ElseIf Val(strAmount) = 0 Then
            getAmountInWords = "Rupees Zero"
            Exit Function
        ElseIf Val(strAmount) > 999999999.99 Then
            getAmountInWords = ""
            Exit Function
        End If
    
        'store the integer and decimal parts separately
        strIntPart = Mid(strAmount, 1, 9)
        strDecPart = Mid(strAmount, 11, 2)
    
        'store the individual places in variables
        strCroresPart = Mid(strIntPart, 1, 2)
        strLakhsPart = Mid(strIntPart, 3, 2)
        strThousandsPart = Mid(strIntPart, 5, 2)
        strHundredsPart = Mid(strIntPart, 7, 1)
        strTensPart = Mid(strIntPart, 8, 1)
        strOnesPart = Mid(strIntPart, 9, 1)
        strDecTensPart = Mid(strDecPart, 1, 1)
        strDecOnesPart = Mid(strDecPart, 2, 1)
    
        strAmtWords = ""
        'To make the Crores Part
        If Val(strCroresPart) <> 0 Then
            strAmtWords = strAmtWords & getCroresPart(strCroresPart)
        End If
    
        'To make the Lakhs Part
        If Val(strLakhsPart) <> 0 Then
            strAmtWords = strAmtWords & getLakhsPart(strLakhsPart)
        End If
    
        'To make the Thousands Part
        If Val(strThousandsPart) <> 0 Then
            strAmtWords = strAmtWords & getThousandsPart(strThousandsPart)
        End If
    
        'To make the hundreds Part
        If Val(strHundredsPart) <> 0 Then
            strAmtWords = strAmtWords & getOnesColumn(Format(strHundredsPart, "00")) & " Hundred "
        End If
    
        'To make Tens and Ones part
        If Val(strTensPart & strOnesPart) <> 0 And Val(strAmount) > 100 Then
            strAmtWords = strAmtWords & "and " & getTensOnesPart(strAmount, strTensPart, strOnesPart)
        Else
            strAmtWords = strAmtWords & getTensOnesPart(strAmount, strTensPart, strOnesPart)
        End If
    
        strDecWords = ""
        'To make Tens and Ones part in the decimal part
        If Val(strDecTensPart & strDecOnesPart) <> 0 Then
            strDecWords = strDecWords & getTensOnesPart(Val(strAmount), strDecTensPart, strDecOnesPart)
        End If
    
        'If both integer and decimal part are not Zero then add Rupees and Paise only
        If Val(strDecPart) <> 0 And Val(strIntPart) <> 0 Then
            getAmountInWords = "Rupees " & strAmtWords & " and " & strDecWords & " Paise only"
        'If deciaml part is zero then add Rupees and only
        ElseIf Val(strIntPart) <> 0 And Val(strDecPart) = 0 Then
            getAmountInWords = "Rupees " & strAmtWords & " Only"
        'If Integer part is zero then add Paise only
        ElseIf Val(strIntPart) = 0 And Val(strDecPart) <> 0 Then
            getAmountInWords = strDecWords & " Paise Only"
        End If
        '??Replace is not supported in OOo Basic
        '??getAmountInWords = Trim(Replace(getAmountInWords, "  ", " "))
        getAmountInWords = Trim(getAmountInWords, "  ", " ")
        Exit Function
    BadError:
       iErr = Err
       If Err = 13 Then
         getAmountInWords = ""
         Exit Function
       Else
         REM OK, do what?
         getAmountInWords = ""
         Print "Did not expect to get here with err " & iErr
       End If
    End Function
    
    '********************************************************************************************************
    'Function Name      :   getOnesColumn
    'Description        :   To convert the number in ones column into words
    'Input Parameters   :   String(ones value formated as "00")
    'Returns            :   String
    'Creat by           :   Sanjeev Meher on 9th Feb 2013
    'Specific Logic used:   None
    '********************************************************************************************************
    Public Function getOnesColumn(strValue As String) As String
        Select Case strValue
            Case "01"
                getOnesColumn = "One"
            Case "02"
                getOnesColumn = "Two"
            Case "03"
                getOnesColumn = "Three"
            Case "04"
                getOnesColumn = "Four"
            Case "05"
                getOnesColumn = "Five"
            Case "06"
                getOnesColumn = "Six"
            Case "07"
                getOnesColumn = "Seven"
            Case "08"
                getOnesColumn = "Eight"
            Case "09"
                getOnesColumn = "Nine"
        End Select
    End Function
    
    '********************************************************************************************************
    'Function Name      :   getTensColumnWithOne
    'Description        :   To convert the number in tens and ones column into words
    '                       if the combined(tens+ones) value is between 10 and 19
    'Input Parameters   :   String
    'Returns            :   String
    'Creat by           :   Sanjeev Meher on 9th Feb 2013
    'Specific Logic used:   None
    '********************************************************************************************************
    Public Function getTensColumnWithOne(strValue As String) As String
        Select Case strValue
            Case "10"
                getTensColumnWithOne = "Ten"
            Case "11"
                getTensColumnWithOne = "Eleven"
            Case "12"
                getTensColumnWithOne = "Twelve"
            Case "13"
                getTensColumnWithOne = "Thirteen"
            Case "14"
                getTensColumnWithOne = "Fourteen"
            Case "15"
                getTensColumnWithOne = "Fifteen"
            Case "16"
                getTensColumnWithOne = "Sixteen"
            Case "17"
                getTensColumnWithOne = "Seventeen"
            Case "18"
                getTensColumnWithOne = "Eighteen"
            Case "19"
                getTensColumnWithOne = "Nineteen"
        End Select
    End Function
    
    '********************************************************************************************************
    'Function Name      :   getTensColumn
    'Description        :   To convert the number in tens column into words
    '                       if the combined(tens+ones) value is between 20 and 99
    'Input Parameters   :   String
    'Returns            :   String
    'Creat by           :   Sanjeev Meher on 9th Feb 2013
    'Specific Logic used:   None
    '********************************************************************************************************
    Public Function getTensColumn(strValue As String) As String
        Select Case strValue
            Case "2"
                getTensColumn = "Twenty"
            Case "3"
                getTensColumn = "Thirty"
            Case "4"
                getTensColumn = "Forty"
            Case "5"
                getTensColumn = "Fifty"
            Case "6"
                getTensColumn = "Sixty"
            Case "7"
                getTensColumn = "Seventy"
            Case "8"
                getTensColumn = "Eighty"
            Case "9"
                getTensColumn = "Ninety"
        End Select
    End Function
    
    '********************************************************************************************************
    'Function Name      :   getCroresPart
    'Description        :   To convert the crore part into words
    'Input Parameters   :   String(crore value)
    'Returns            :   String
    'Creat by           :   Sanjeev Meher on 9th Feb 2013
    'Specific Logic used:   None
    '********************************************************************************************************
    Public Function getCroresPart(strCrore As String) As String
        If Val(strCrore) < 10 Then
            If Val(strCrore) = 1 Then
                getCroresPart = getOnesColumn(strCrore) & " Crore "
            Else
                getCroresPart = getOnesColumn(strCrore) & " Crores "
            End If
        ElseIf Val(strCrore) < 20 Then
            getCroresPart = getCroresPart & getTensColumnWithOne(strCrore) & " Crores "
        Else
            getCroresPart = getCroresPart & getTensColumn(Mid(strCrore, 1, 1))
            If Mid(strCrore, 2, 1) <> "0" Then
                getCroresPart = getCroresPart & " " & _
                                getOnesColumn(Format(Mid(strCrore, 2, 1), "00"))
            End If
            getCroresPart = getCroresPart & " Crores "
        End If
    End Function
    
    '********************************************************************************************************
    'Function Name      :   getLakhsPart
    'Description        :   To convert the lakh part into words
    'Input Parameters   :   String(Lakh value)
    'Returns            :   String
    'Creat by           :   Sanjeev Meher on 9th Feb 2013
    'Specific Logic used:   None
    '********************************************************************************************************
    Public Function getLakhsPart(strLakh As String) As String
        If Val(strLakh) < 10 Then
            If Val(strLakh) = 1 Then
                getLakhsPart = getLakhsPart & getOnesColumn(strLakh) & " Lakh "
            Else
                getLakhsPart = getLakhsPart & getOnesColumn(strLakh) & " Lakhs "
            End If
        ElseIf Val(strLakh) < 20 Then
            getLakhsPart = getLakhsPart & getTensColumnWithOne(strLakh) & " Lakhs "
        Else
            getLakhsPart = getLakhsPart & getTensColumn(Mid(strLakh, 1, 1))
            If Mid(strLakh, 2, 1) <> "0" Then
                getLakhsPart = getLakhsPart & " " & _
                                getOnesColumn(Format(Mid(strLakh, 2, 1), "00"))
            End If
            getLakhsPart = getLakhsPart & " Lakhs "
        End If
    End Function
    
    '********************************************************************************************************
    'Function Name      :   getThousandsPart
    'Description        :   To convert the thousand part into words
    'Input Parameters   :   String(thousand value)
    'Returns            :   String
    'Creat by           :   Sanjeev Meher on 9th Feb 2013
    'Specific Logic used:   None
    '********************************************************************************************************
    Public Function getThousandsPart(strThousand As String) As String
        If Val(strThousand) < 10 Then
            getThousandsPart = getThousandsPart & getOnesColumn(strThousand) & " Thousand "
        ElseIf Val(strThousand) < 20 Then
            getThousandsPart = getThousandsPart & getTensColumnWithOne(strThousand) & " Thousand "
        Else
            getThousandsPart = getThousandsPart & getTensColumn(Mid(strThousand, 1, 1))
            If Mid(strThousand, 2, 1) <> "0" Then
                getThousandsPart = getThousandsPart & " " & _
                                getOnesColumn(Format(Mid(strThousand, 2, 1), "00"))
            End If
            getThousandsPart = getThousandsPart & " Thousand "
        End If
    End Function
    
    '********************************************************************************************************
    'Function Name      :   getTensOnesPart
    'Description        :   To convert the tens and ones part into words
    'Input Parameters   :   actual total amount,tens value,ones value
    'Returns            :   String
    'Creat by           :   Sanjeev Meher on 9th Feb 2013
    'Specific Logic used:   None
    '********************************************************************************************************
    Public Function getTensOnesPart(strAmount As String, strTensPart As String, strOnesPart As String) As String
        If Val(strTensPart & strOnesPart) < 10 Then
            getTensOnesPart = getTensOnesPart & getOnesColumn(strTensPart & strOnesPart)
        ElseIf Val(strTensPart & strOnesPart) < 20 Then
            getTensOnesPart = getTensOnesPart & getTensColumnWithOne(strTensPart & strOnesPart)
        Else
            getTensOnesPart = getTensOnesPart & getTensColumn(strTensPart)
            If Mid(strOnesPart, 2, 1) <> "0" Then
                getTensOnesPart = getTensOnesPart & " " & getOnesColumn(Format(strOnesPart, "00"))
            End If
        End If
    End Function
    

    这个宏的货币单位是“十万”和“千万”。您可以根据需要修改代码。

    • 5

相关问题

  • OpenOffice 和新创建的 LibreOffice 有什么区别?

  • 随着 Xmarks 的关闭,有什么好的选择?

  • 更改 TreeStyleTab 选项卡栏中使用的字体 [关闭]

  • 如何调试 Nautilus 扩展?

  • 如何强制面板不在顶部?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve