Search code examples
shinyhandsontablerhandsontable

RHandsontable Incorrect Input Conversion, when format is used


I am facing a peculiar issue with RHandsontable (Version: 0.3.6). The issue I am facing is pertinent to the conversion of the input from the UI. When numerical inputs are entered (x), they are being stored correctly. However when percentage inputs are entered (x%),all the values except Zeroeth Percents(0%,0.0%,0.00% etc) are stored correctly. The Zeroeth Percents are converted into NULL values as visible from the excel downloads.

Reproducible Example Snapshot

Attaching a reproducible example of the observed behavior.

library(shiny)
library(openxlsx)
library(rhandsontable)

ui <- fluidPage(
      br(),
      rHandsontableOutput("table"),
      br(),
      downloadButton("download","Download"))

server <- function(input, output, session) {

   output$table <- renderRHandsontable({

   df <- data.frame("Growth" = c(0.1,0.02,0.06,0.24,0.08))

   rhandsontable(df, rowHeaders = NULL,colHeaders = c("Growth")) %>%
   hot_col(c("Growth"), format = "0.0%") %>%
   hot_validate_numeric(cols = c(1),min = 0.00, max = 1.00)

   })


   output$download <- downloadHandler(
   filename = function() {
   paste('Report.xlsx')
   },

   content <- function(file) {
   write.xlsx(hot_to_r(input$table),file)
   })

}

shinyApp(ui, server)

The inputs need to be changed in the UI, not the code itself. You can try inputting 0% (not 0) as an input in the UI, it will produce a NULL value in the excel extract, where "0%", "0.0%" etc are inserted. You can validate my findings by downloading the excel extracts. Is this a package related issue or Is this Code related? If later any pointers to debug are appreciated.


Solution

  • The issue is resolved with the newest version of the package rhandsontable, for more details visit this github link.

    https://github.com/jrowen/rhandsontable/issues/270