cbailiss / basictabler Goto Github PK
View Code? Open in Web Editor NEWConstruct Rich Tables for Output to HTML/Excel
Construct Rich Tables for Output to HTML/Excel
The root cell and row/column headers have a rowspan/colspan specified even if not merged. Not strictly a bug, but untidy.
Repro:
library(pivottabler)
pt <- qpvt(bhmtrains, "TOC", "TrainCategory", "n()")
bt <- pt$asBasicTable()
bthtml <- as.character(bt$getHtml())
cat(bthtml)
Assigning a style to the same cell more than once is not possible, and yields the following error message:
Error in cell$setPropertyValues(declarations) :
attempt to apply non-function
Minimal reproducable example:
tbl <- BasicTable$new()
tbl$addData(data.frame(a = c(1)), columnNamesAsColumnHeaders = F)
tbl$setStyling(
declarations = list("font-weight" = "bold"),
cells = tbl$getCells(specifyCellsAsList = FALSE, rowNumbers = c(1), columnNumbers = c(1)))
tbl$setStyling(
declarations = list("text-align" = "center"),
cells = tbl$getCells(specifyCellsAsList = FALSE, rowNumbers = c(1), columnNumbers = c(1)))
tbl$renderTable()
Of course, one can overcome this by gathering all styles to be applied to a given cell, and apply it in a single call. However, it would be desirable to be able to do this in multiple runs as well.
Work-around:
tbl <- BasicTable$new()
tbl$addData(data.frame(a = c(1)), columnNamesAsColumnHeaders = F)
tbl$setStyling(
declarations = list("font-weight" = "bold", "text-align" = "center"),
cells = tbl$getCells(specifyCellsAsList = FALSE, rowNumbers = c(1), columnNumbers = c(1)))
tbl$renderTable()
Template:
#' @description
#' Return the contents of this object as JSON for debugging.
#' @return A JSON representation of various object properties.
asJSON = function() {
if (!requireNamespace("jsonlite", quietly = TRUE)) {
stop("The jsonlite package is needed to convert to JSON. Please install the jsonlite package.", call. = FALSE)
}
jsonliteversion <- utils::packageDescription("jsonlite")$Version
if(numeric_version(jsonliteversion) < numeric_version("1.1")) {
stop("Version 1.1 or above of the jsonlite package is needed to convert to JSON. Please install an updated version of the jsonlite package.", call. = FALSE)
}
return(jsonlite::toJSON(self$asList()))
}
And remove the @import jsonlite
lines from the inline documentation.
Compare arguments to pt$findCells().
Arguments:
Implementation:
Documentation note:
#' @param fmtFuncArgs If format
is a custom R function, then fmtFuncArgs
#' specifies any additional arguments (in the form of a list) that will be
#' passed to the custom function.
Bring inline with changes in pivottabler:
Rename to getSimpleColoredTheme
Add new theme argument.
See same function in pivottabler for details of the changes to make.
Does it support multiple columns (eg. column 1 to 3) to be row headers?
Hi, I'm making a table where one column includes URL adresses. I'm displaying the table inside a Shiny app.
Can I parse cell contents of that column (or specific cells) as valid HTML?
E.g.
'<a href="https://www.google.com/">https://www.google.com/</a>'
should display as a link to Google.
Also, by using the $getHtml()
method, I see that the cell contents look like this:
<a href="https://www.google.com/">https://www.google.com/</a>
Basically the < and > symbols are being interpreted literally, perhaps that is preventing the conversion to actual HTML?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.