The objective is to apply borders to parts of a table using openxlsx. Next I will show the desired output, builded in a way that is not the desired one: printing parts of the table and formating it in each step:
library(openxlsx)
library(tidyverse)
set.seed(15)
###create workbook
wb <- createWorkbook()
addWorksheet(wb, "test2")
#Sample a portion of iris to make it short
iris%>%dplyr::sample_n(15)->sample_iris
#split according to Species
sample_iris%>%filter(Species %in% "setosa")->p1
sample_iris%>%filter(Species %in% "versicolor")->p2
sample_iris%>%filter(Species %in% "virginica")->p3
##write each part and apply borders
writeData(wb, 1,p1, startRow = 1, startCol = 1,borders = "surrounding",borderStyle="thick")
writeData(wb, 1,p2, startRow = 1+dim(p1)[1], startCol = 1,borders = "surrounding",colNames =F,borderStyle="thick")
writeData(wb, 1,p3, startRow = 1+dim(p1)[1]+dim(p2)[1], startCol = 1,borders = "surrounding",colNames =F,borderStyle="thick")
saveWorkbook(wb, "test2.xlsx", overwrite = TRUE)
So "test2.xlsx" is the desired output. The thing is how to achieve it not by generating the file, but to modify an existing file. I mean, if the file "test1.xlsx" is created by
write.xlsx(sample_iris, file = "test1.xlsx")
then, how to apply borders as desired on the already existing file? Thanks for any guide on this
The objective is to apply borders to parts of a table using openxlsx. Next I will show the desired output, builded in a way that is not the desired one: printing parts of the table and formating it in each step:
So "test2.xlsx" is the desired output. The thing is how to achieve it not by generating the file, but to modify an existing file. I mean, if the file "test1.xlsx" is created by
write.xlsx(sample_iris, file = "test1.xlsx")
then, how to apply borders as desired on the already existing file? Thanks for any guide on this
Note: I posted the same question on https://stackoverflow.com/questions/50595559/how-to-apply-selectively-borders-to-an-existing-xlsx-using-openxlsx