0

我有以下代码使用 excelR 输出 mtcars 表。我想让列名在垂直位置而不是水平位置,我该怎么做?它需要在 excelR 包中,因为用户需要更新一些信息。谢谢!

library(shiny)
library(excelR)

ui <- fluidPage(
  excelOutput("v1")
)

server <- function(input, output, session) {
  df <- reactive({mtcars})

  output$v1 = renderExcel({
    excelTable(df())
  })
}

shinyApp(ui, server)

编辑:

非常感谢 gdevaux 的以下回答,他向我展示了它可以在他的电脑上运行。但不知何故,我们无法弄清楚它在我的 Mac 或 Windows 上不起作用的问题,尝试了 safari 和 chrome,R 版本已更新并尝试从外部浏览器打开。

其他人可以运行下面的代码以查看是否有效,如果有人知道它对我不起作用的原因可能是什么?

4

1 回答 1

0

你可以用 CSS 来做到这一点。查看有关 text-orientation 属性的 CSS 文档以了解方向的各种可能性。

library(shiny)
library(excelR)

ui <- fluidPage(
  
  # add CSS
  tags$head(
    tags$style(HTML("
    #your_table .resizable {
      writing-mode: vertical-rl;
      -webkit-text-orientation: sideways;
      text-orientation: sideways;
      }
    "))
  ),
  
  div(
    id = "your_table",
    excelOutput("v1")
  )
  
)

server <- function(input, output, session) {
  df <- reactive({mtcars})
  
  output$v1 = renderExcel({
    excelTable(df())
  })
}

shinyApp(ui, server)

编辑:不在 RStudio 查看器窗格或窗口中工作,您必须使用“运行外部”

于 2021-07-12T14:52:56.213 回答