我想创建一个闪亮的应用程序来执行数据库查询。 (简单)的想法是创建一个表格,在列上应用条件格式并允许报表保存为excel。我尝试了不同的解决方案,但使用数据表下载按钮似乎是最方便的。R数据表条件带条件格式的按钮
经过广泛的搜索,我设法应用下载按钮(从github更新dt-package)并在shiny-app的浏览器显示中应用特定的格式(formatStyle)。这将允许我将来为唯一列应用条件格式。但是,使用保存按钮时,此格式会在保存的文件中丢失(请参阅下面的代码片段)。
在我的理解中,原因是formatStyle函数仅适用于数据表调用之后。有没有办法在早些时候应用formatStyle函数?创建resulttab对象的原因是,formatStyle函数应用于通过名称选择的特定列,而tabelle函数是在闪亮的反应环境中生成的。
output$tab <- DT::renderDataTable({
resulttab <- tabelle()
datatable(resulttab, extensions = 'Buttons', options = list(
dom = 'Bfrtip',
buttons =
list('copy', 'print', list(
extend = 'collection',
buttons = list(list(extend='csv',
filename = 'blBericht'),
list(extend='excel',
filename = 'blBericht'),
list(extend='pdf',
filename= 'blBericht')),
text = 'Download')))) %>% formatStyle('Tribrommethan', color = 'red', backgroundColor = 'orange', fontWeight = 'bold')
})
您可以在哪里调用formatStyle并轻松条件格式化数据表?我正在寻找一个轻松做到这一点的功能,任何帮助将不胜感激 – AbeeCrombie