Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update table from Shiny #13

Closed
marciz opened this issue Jul 30, 2019 · 3 comments
Closed

Update table from Shiny #13

marciz opened this issue Jul 30, 2019 · 3 comments

Comments

@marciz
Copy link
Contributor

marciz commented Jul 30, 2019

Hi!
Thanks for your excelR package!
I am trying to update table content from Shiny but creates duplicate table rather than replaces existing one.

library(shiny)
library(excelR)
shinyApp(
  ui = fluidPage(
    radioButtons(inputId = 'data', label = 'Data', choices = c('iris', 'mtcars')),
    excelOutput("table")
  ),
    server = function(input, output, session) {
    output$table <- renderExcel({
      dt <- get(input$data)
      excelTable(data = dt)
    })
  }
)

Output:
image

sessionInfo:

R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=Latvian_Latvia.1257 LC_CTYPE=Latvian_Latvia.1257
[3] LC_MONETARY=Latvian_Latvia.1257 LC_NUMERIC=C
[5] LC_TIME=Latvian_Latvia.1257

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] excelR_0.2.0 shiny_1.3.2

loaded via a namespace (and not attached):
[1] Rcpp_1.0.1 digest_0.6.18 later_0.8.0 mime_0.6 R6_2.4.0
[6] xtable_1.8-4 jsonlite_1.6 magrittr_1.5 rlang_0.3.4 promises_1.0.1
[11] tools_3.6.0 htmlwidgets_1.3 httpuv_1.5.1 yaml_2.2.0 compiler_3.6.0
[16] htmltools_0.3.6

@Swechhya
Copy link
Owner

Swechhya commented Jul 30, 2019

Thank you @marciz for reposting the issue. You can download the development version of the package that resolves this issue. I'll close this issue now, if the problem persists in the development version you can reopen the issue again

@marciz
Copy link
Contributor Author

marciz commented Jul 30, 2019

Thanks @Swechhya , it works now
Ultimately I am trying to create table with calculated variable

library(shiny)
library(excelR)
dt <- iris
dt$mysum <- dt$Sepal.Length + dt$Sepal.Width
shinyApp(
  ui = fluidPage(
    excelOutput("table")
  ),
    server = function(input, output, session) {
    rv <- reactiveValues(
      dt = dt
    )
    output$table <- renderExcel(excelTable(data = rv$dt))
    observeEvent(input$table,{
      dt <- excel_to_R(input$table)
      dt$mysum <- dt$Sepal.Length + dt$Sepal.Width
      rv$dt <- dt
    })
  }
)

It works as expected, just small inconvenience from user perspective is that cells selection is lost when table updates (due to new jexcel)

@Swechhya
Copy link
Owner

Swechhya commented Jul 30, 2019

Yes, @marciz I can see that could be the inconvenience from user perspective. You can raise a new issue for that and I'll try to find a better solution(which could take some time) for table updation than currently implemented, until then this could be a workaround solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants