[英]How to format thousands separator when exporting from r to excel using xlsx package?
I am exporting some dataframes from r to excel using the xlsx
and rJava
packages, which works well.我正在使用
xlsx
和rJava
包从 r 到 excel 导出一些数据帧,效果很好。 However, I want the numbers in excel to be separated by thousands using dots, ie 1.000.000,00
.但是,我希望 excel 中的数字用点分隔数千,即
1.000.000,00
。 Can anybody provide some example code to achieve this?任何人都可以提供一些示例代码来实现这一点吗?
Here is a simple example.这是一个简单的例子。
library(xlsx)
wb <- createWorkbook()
sheet <- createSheet(wb, "Sheet1")
rows <- createRow(sheet, rowIndex=1)
cell.1 <- createCell(rows, colIndex=1)[[1,1]]
setCellValue(cell.1, 1234567.89)
cs = CellStyle(wb) +
DataFormat("#,##0.00")
setCellStyle(cell.1, cs)
saveWorkbook(wb, 'EuroFormatNumbers.xlsx')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.