使用 gspread 格式分隔千位

Separating thousands using gspread formatting

我有一个数字值,我正在尝试使用 gspread 和 gspread_formatting:

在 google 工作表中将其格式化为带有千位分隔符的货币
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': '£###'}})

return 中的 none 是预期的结果,我找不到关于格式化模式的文档以使用千位分隔符。

我如何使用 gspread_formatting 包实现此目的?

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

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

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

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

示例脚本:

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

注:

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

参考文献: