Created
May 18, 2017 07:02
-
-
Save davidgohel/eee684d003a04a6e1a5b19a044164f76 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ReporteRs) | |
test <- | |
structure(list(Grade1 = c(20, 30, 20, 10), | |
Grade2 = c(10, 5, 10, 20), | |
Grade3 = c(5, 2, 4, 5), | |
Grade4 = c(0, 0, 3, 0), | |
Grade5 = c(0, 0, 0, 1)), | |
.Names = c("1","20","300","4000","50000"), | |
row.names = c("A","B","C","D"), | |
class = "data.frame") | |
FTtest <- FlexTable(data=test, | |
header.columns=TRUE, | |
add.rownames=TRUE, | |
header.text.props = textProperties(font.weight="bold"), | |
header.cell.props=cellProperties(padding.left=10)) | |
FTtest[,1] <- textProperties(font.weight = "bold") | |
FTtest[1,to = "header"] <- parCenter() | |
FTtest[to = "body"] <- parCenter() | |
doc <- docx(title="testing") | |
doc <- addFlexTable(doc, FTtest) | |
writeDoc(doc, file="testing.docx") | |
library(flextable) | |
library(officer) | |
ft <- flextable(data=test) | |
ft <- bold(ft, part = "header") | |
ft <- align(ft, align = "center", part = "all") | |
ft <- autofit(ft) | |
doc <- read_docx() | |
doc <- body_add_flextable(doc, ft) | |
print(doc, target = "testing2.docx") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment