在 rhandsontable 中合并多个单元格
Merging multiple cells in rhandsontable
我正在尝试使用 rhandsontable 创建一个 table 和多行合并单元格(每行不同的单元格)。
我正在尝试合并下面屏幕截图中指示的单元格...
我能够成功合并第一组单元格(第 11 行),但随后使用“列表列表”指定单元格的合并不起作用。我已经尝试了我能想到的“列表列表”语法的每一种排列;
示例的代表在这里...
library(shiny)
library(rhandsontable)
## Create the data set
DF = data.frame((Cycle = 1:13),
`A` = as.numeric(""),
`B` = as.numeric(""),
`C` = as.numeric(""),
`D` = as.numeric(""))
DF[11,1] = "Total"
DF[12,1] = ""
DF[13,1] = "Loss"
server <- shinyServer(function(input, output, session) {
output$hotTable <- renderRHandsontable({rhandsontable(DF,
width = 1500, height = 350, rowHeaders = FALSE) %>%
hot_cols(colWidths = c(100, 150, 150, 150, 150)) %>%
hot_col(c(1,3:5), readOnly = TRUE) %>%
hot_col(col = c(1:5), halign = "htCenter") %>%
hot_col(col = c(2:4), format = "0.0000") %>%
hot_col(col = 5, format = 0000) %>%
hot_table(mergeCells = list(list(row = 10, col = 2, rowspan = 1, colspan = 3),
list(row = 11, col = 1, rowspan = 1, colspan = 5),
list(row = 12, col = 3, rowspan = 1, colspan = 3)))})
})
ui <- basicPage(mainPanel(rHandsontableOutput("hotTable")))
shinyApp(ui, server)
我认为你应该更改一些参数如下:
mergeCells = list(list(row = 10, col = 2, rowspan = 1, colspan = 3),
list(row = 11, col = 0, rowspan = 1, colspan = 5),
list(row = 12, col = 2, rowspan = 1, colspan = 3))
因此您想要的 rhandsontable 将按您的意愿生成:
我正在尝试使用 rhandsontable 创建一个 table 和多行合并单元格(每行不同的单元格)。
我正在尝试合并下面屏幕截图中指示的单元格...
我能够成功合并第一组单元格(第 11 行),但随后使用“列表列表”指定单元格的合并不起作用。我已经尝试了我能想到的“列表列表”语法的每一种排列;
示例的代表在这里...
library(shiny)
library(rhandsontable)
## Create the data set
DF = data.frame((Cycle = 1:13),
`A` = as.numeric(""),
`B` = as.numeric(""),
`C` = as.numeric(""),
`D` = as.numeric(""))
DF[11,1] = "Total"
DF[12,1] = ""
DF[13,1] = "Loss"
server <- shinyServer(function(input, output, session) {
output$hotTable <- renderRHandsontable({rhandsontable(DF,
width = 1500, height = 350, rowHeaders = FALSE) %>%
hot_cols(colWidths = c(100, 150, 150, 150, 150)) %>%
hot_col(c(1,3:5), readOnly = TRUE) %>%
hot_col(col = c(1:5), halign = "htCenter") %>%
hot_col(col = c(2:4), format = "0.0000") %>%
hot_col(col = 5, format = 0000) %>%
hot_table(mergeCells = list(list(row = 10, col = 2, rowspan = 1, colspan = 3),
list(row = 11, col = 1, rowspan = 1, colspan = 5),
list(row = 12, col = 3, rowspan = 1, colspan = 3)))})
})
ui <- basicPage(mainPanel(rHandsontableOutput("hotTable")))
shinyApp(ui, server)
我认为你应该更改一些参数如下:
mergeCells = list(list(row = 10, col = 2, rowspan = 1, colspan = 3),
list(row = 11, col = 0, rowspan = 1, colspan = 5),
list(row = 12, col = 2, rowspan = 1, colspan = 3))
因此您想要的 rhandsontable 将按您的意愿生成: