【问题标题】:How to set cell language for good number formatting in openpyxl?如何在openpyxl中设置单元格语言以获得良好的数字格式?
【发布时间】:2019-05-25 11:13:26
【问题描述】:

我尝试使用 openpyxl 在 xslx 文件中设置波兰货币格式。

我有:

xfile = openpyxl.load_workbook('myFile.xlsx')
    sheet = xfile.get_sheet_by_name('Sheet1')

locale.setlocale(locale.LC_ALL, 'pl_PL.utf8')
getcontext().prec = 3 #decimal precission

sheet[f'E1'].number_format = '# ##0,00 [$zł-415];-# ##0,00 [$zł-415]'
sheet[f'E1'] = Decimal(PRICENET) #PRICENET is 17.8

因此,当我在 OpenOffice Calc 中打开此文件并检查单元格格式时,我看到单元格是具有良好波兰货币格式的货币,但语言是“默认 - 英语(美国)”。单元格显示“018 zł”。当我将单元格语言更改为“波兰语”时,单元格中的“17,80 zł”是首选。有什么线索?

【问题讨论】:

    标签: python excel openpyxl openoffice-calc


    【解决方案1】:

    在 Excel 中,本地设置对于应用程序是全局的,而不是对于工作簿或工作表(您不能为单元格设置语言),因此即使您按原样设置货币,应用程序中的设置也会优先。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-27
      • 1970-01-01
      • 1970-01-01
      • 2021-10-14
      相关资源
      最近更新 更多