Problem with DT export data to excel after formatCurrency(mark = ' ')

136 Views Asked by At

I use simple code of app.R. When I launch it on my local machine and export table by xls - it's ok. By when I launch it on server and do the same - all numeric columns are characters in xls. There are error "the number in this cell is formatted as text or preceded by an apostrophe". When I copy or export by csv - it's ok. Problem only with export by xls and only on server.

Main problem is param 'mark' in FormatCurrentcy. If I set it like '.' or ',' - it's ok. But I need ' ' (space). Maybe there some settings that different on my local machine and server.

Script is attached

library(shiny)
library( DT )
library(dplyr)
# Define UI for application that creates a datatables
ui <- fluidPage(
  # Application title
  titlePanel("Download Datatable")
  # Show a plot of the generated distribution
  , mainPanel(
    DT::dataTableOutput("fancyTable")
  ) # end of main panel
  
) # end of fluid page

# Define server logic required to create datatable
server <- function(input, output) {
  output$fancyTable <- DT::renderDataTable(
    datatable( data = mtcars * 1000
               , extensions = 'Buttons'
               , options = list( 
                 dom = "Blfrtip"
                 , buttons = 
                   list("copy", list(
                     extend = "collection"
                     , buttons = c("csv", "excel")
                     , text = "Download"
                   ) ) # end of buttons customization
                 # customize the length menu
                 , lengthMenu = list( c("All") # declare values
                                      # declare titles
                 ) # end of lengthMenu customization
                 , pageLength = 10
               ) # end of options
    ) %>%  # end of datatables
    formatCurrency(interval = 3, mark = ' ', columns = 1:ncol(mtcars), currency = '', digits = 0)
  )
} # end of server
# Run the application 
shinyApp(ui = ui, server = server)
0

There are 0 best solutions below