我的代码如下闪亮
DT::renderDataTable({
df()
, rownames=FALSE
,extensions = c('Responsive', 'Buttons')
, options = list(
# dom = 'C<"clear">T<"clear">lfrtip'
# , tableTools=list(sSwfPath = copySWF('www'))
dom = 'Bfrtip'
, buttons = c('pageLength'
, 'colvis'
, 'pdf')
, orientation ='landscape'
, lengthMenu = list(c(6, 12, 18, -1), c('6', '12', '18', 'All'))
, pageLength = 12
)
)
}
})
我想在横向下载pdf。我该怎么办
根据以下链接:https://datatables.net/reference/button/pdf我们可以将方向作为景观传递。但是,我无法做到。
我试过以下:
DT::renderDataTable({
df()
, rownames=FALSE
,extensions = c('Responsive', 'Buttons')
, options = list(
# dom = 'C<"clear">T<"clear">lfrtip'
# , tableTools=list(sSwfPath = copySWF('www'))
dom = 'Bfrtip'
, buttons = c('pageLength'
, 'colvis'
, list(extend: 'pdf', orientation='landscape')
, orientation ='landscape'
, lengthMenu = list(c(6, 12, 18, -1), c('6', '12', '18', 'All'))
, pageLength = 12
)
)
}
})
答案 0 :(得分:4)
这对我有用。由于您没有提供我使用虹膜数据集的数据。不是pdf是横向的,但表没有使用所有可用空间,但行为与datatables example中的行为相同。它不能在RStudio上运行,但它在浏览器中运行(Firefox 49.0)
这是代码:
library(shiny)
library(DT)
shinyApp(
ui = fluidPage(DT::dataTableOutput('tbl')),
server = function(input, output) {
output$tbl = DT::renderDataTable(
datatable(
iris,
rownames = FALSE,
extensions = c('Responsive', 'Buttons'), options = list(
pageLength = 12,
orientation ='landscape',
lengthMenu = list(c(6, 12, 18, -1), c('6', '12', '18', 'All')),
dom = 'Bfrtip',
buttons =
list('pageLength', 'colvis', list(
extend = 'pdf',
pageSize = 'A4',
orientation = 'landscape',
filename = 'tt'
))
))
)
}
)