【问题标题】:Change the separator in the button extension更改按钮扩展中的分隔符
【发布时间】:2019-10-16 07:14:50
【问题描述】:

我使用 R 包 DT 作为 DataTables 的 R 接口。

如何调整“按钮扩展”以便在导出到 csv/Excel 时使用分号而不是逗号作为分隔符?

library(DT)
m = cbind(matrix(rnorm(60, 1e5, 1e6), 20), runif(20), rnorm(20, 100))
m[, 1:3] = round(m[, 1:3])
m[, 4:5] = round(m[, 4:5], 7)
colnames(m) = head(LETTERS, ncol(m))

datatable(
  m, extensions = 'Buttons', options = list(
    dom = 'Bfrtip',
    buttons = c('copy', 'csv', 'excel')
  )
)

【问题讨论】:

    标签: r datatables dt


    【解决方案1】:
    datatable(
      m, extensions = 'Buttons', options = list(
        dom = 'Bfrtip',
        buttons = list(
          'copy', 
          'excel', 
          list(
            extend = 'csv', 
            fieldSeparator = ';'
          )
        )
      )
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-28
      • 1970-01-01
      • 2015-06-22
      • 1970-01-01
      • 1970-01-01
      • 2012-10-31
      相关资源
      最近更新 更多