[英]Select only filtered rows using select all button that comes with select extension in shiny's DT package
[英]DT Package PDF Extension Button
我有一個相當大的表,如果我將它放入DT
表並在其上打印 PDF ,則該列的某些部分將被切斷。 此外,我還想在將標題導出到 PDF 時調整其大小。 我應該如何 go 關於這個?
下面是我所說的當所有列都不適合一頁時的示例。 如何調整DT
表PDF里面的表大小和標題?
library("shiny")
library("DT")
data <- cbind(iris,iris,iris)
shinyApp(
ui = fluidPage(DT::dataTableOutput('tbl')),
server = function(input, output) {
output$tbl = DT::renderDataTable(
data,extensions="Buttons",options = list(dom = 'Bt',
buttons = list( list( extend = 'pdf',
pageSize = 'A4',
orientation = 'landscape',
filename = 'tt',
title= "A smaller title here")))
)
}
)
我嘗試過的幾件事:
capture
package : Will print the entire table to how I adjust and format the table in Shiny, but all in one PDF page, which is not ideal since I want the PDF to be printable over several A4 pages.DTOutput
中輸入width
參數:不會在 PDF 導出表中顯示調整。您可以使用pdf
擴展的customize
回調來更改pdfMake
選項,這是 pdf 渲染的主力。 例如,您可以設置列寬,使每列僅使用總寬度的百分比。
同樣,您可以用相同的想法更改標題的樣式:
library(shiny)
library(DT)
js_cb <- JS("function(pdf_opts, btn, dt) {
let n = pdf_opts.content[1].table.body[0].length;
// each column occupies a percentage of the total width
let widths = Array(n).fill(100 / n + '%');
pdf_opts.content[1].table.widths = widths;
pdf_opts.styles.title.fontSize = 8; // change fontsize
}")
data <- cbind(iris,iris,iris)
shinyApp(
ui = fluidPage(DT::dataTableOutput('tbl')),
server = function(input, output) {
output$tbl = DT::renderDataTable(
data,
extensions = "Buttons",
options = list(dom = "Bt",
buttons = list(list(extend = "pdf",
pageSize = "A4",
orientation = "landscape",
filename = "tt",
customize = js_cb,
title = "A smaller title here")))
)
}
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.