【问题标题】:Separating thousands using gspread formatting使用 gspread 格式分隔数千
【发布时间】:2021-09-30 08:27:20
【问题描述】:

我有一个数字值,我正在尝试使用 gspread 和 gspread_formatting 在谷歌表格中将其格式化为带有千位分隔符的货币:

A

151644
56464

所需的输出应如下所示:

A

£ 151,644
£ 56,464

我试过了:

worksheet.format('A', {'numberFormat': {'type' : 'CURRENCY', 'pattern': '£#.##0.'}})
worksheet.format('A', {'numberFormat': {'type' : 'CURRENCY', 'pattern': '£###. ###0'}})
worksheet.format('A', {'numberFormat': {'type' : 'CURRENCY', 'pattern': '£#.###'}})
worksheet.format('A', {'numberFormat': {'type' : 'CURRENCY', 'pattern': '£#.#'}})
worksheet.format('A', {'numberFormat': {'type' : 'CURRENCY', 'pattern': '£###'}})

没有返回预期结果,我找不到有关格式化模式的文档以具有一千个分隔符。

我如何使用gspread_formatting 包来实现这一点?

【问题讨论】:

    标签: python google-sheets google-sheets-api gspread


    【解决方案1】:

    关于How could I achieve this using gspread_formatting package?,在这种情况下,下面的示例脚本怎么样?

    示例脚本:

    format_cell_range(worksheet, 'A', cellFormat(numberFormat={'type': 'CURRENCY', 'pattern': '£ #,###'}))
    

    注意:

    • 我将此答案添加为附加信息,因为我认为当显示各种方法时,它们可能对其他用户有用。

    参考资料:

    【讨论】:

      【解决方案2】:

      我能够使用以下方法实现格式:

      worksheet.format('A', 
      {'numberFormat': 
      {'type' : 'CURRENCY', 'pattern': '£ #,###'}})
      

      不确定这是否是理想的格式,但它有效。

      【讨论】:

        猜你喜欢
        • 2015-02-28
        • 2018-11-17
        • 1970-01-01
        • 1970-01-01
        • 2022-07-31
        • 1970-01-01
        • 1970-01-01
        • 2019-09-30
        • 2011-03-12
        相关资源
        最近更新 更多