4:58 5 ˆl–Ãa¾”J_)â�zà^¸Ó*bÑ¿�þBg ‚+Àh­ÊçÉ ƒh¹ÈÆÅ 4:24 5ˆl–Ãa¾”J_)â�zà^¸ÓêbÑ¿�þBg ‚+ͼ˃�ùÊ ƒh¹ÉÇÆ4:60 5ˆl–Ãa¾”J_)â�zà^¸ËêbÑ¿�þBg ‚+¤eçBïóË ƒh¹ÊÈÇ0 7ˆl–Ãa¾”J_)â�zàš¸ÐTÅ£‘äÇò 8àd²6䀑ÏçÌ ƒh¹ËÉÈ7:131 ˆÆ�þZí¬Ü­<ûíe ?Ì „ �²ÏËÉÈ?÷## ----include=TRUE,tidy=TRUE, eval = FALSE ,highlight=TRUE--------------------- # ## write to working directory # library(openxlsx) # write.xlsx(iris, file = "writeXLSX1.xlsx") # write.xlsx(iris, file = "writeXLSXTable1.xlsx", asTable = TRUE) ## ----include=TRUE,tidy=TRUE, eval = FALSE ,highlight=TRUE--------------------- # ## write a list of data.frames to individual worksheets using list names as worksheet names # l <- list("IRIS" = iris, "MTCARS" = mtcars) # write.xlsx(l, file = "writeXLSX2.xlsx") # write.xlsx(l, file = "writeXLSXTable2.xlsx", asTable = TRUE) ## ----include=TRUE,tidy=TRUE, eval = FALSE ,highlight=TRUE--------------------- # options("openxlsx.borderColour" = "#4F80BD") # options("openxlsx.borderStyle" = "thin") # options("openxlsx.dateFormat" = "mm/dd/yyyy") # options("openxlsx.datetimeFormat" = "yyyy-mm-dd hh:mm:ss") # options("openxlsx.numFmt" = NULL) ## For default style rounding of numeric columns # # df <- data.frame("Date" = Sys.Date()-0:19, "LogicalT" = TRUE, # "Time" = Sys.time()-0:19*60*60, # "Cash" = paste("$",1:20), "Cash2" = 31:50, # "hLink" = "https://CRAN.R-project.org/", # "Percentage" = seq(0, 1, length.out=20), # "TinyNumbers" = runif(20) / 1E9, stringsAsFactors = FALSE) # # class(df$Cash) <- "currency" # class(df$Cash2) <- "accounting" # class(df$hLink) <- "hyperlink" # class(df$Percentage) <- "percentage" # class(df$TinyNumbers) <- "scientific" # # write.xlsx(df, "writeXLSX3.xlsx") # write.xlsx(df, file = "writeXLSXTable3.xlsx", asTable = TRUE) # # ## ----include=TRUE,tidy=TRUE, eval = FALSE ,highlight=TRUE--------------------- # hs <- createStyle(fontColour = "#ffffff", fgFill = "#4F80BD", # halign = "center", valign = "center", textDecoration = "Bold", # border = "TopBottomLeftRight", textRotation = 45) # # write.xlsx(iris, file = "writeXLSX4.xlsx", borders = "rows", headerStyle = hs) # write.xlsx(iris, file = "writeXLSX5.xlsx", borders = "columns", headerStyle = hs) # # write.xlsx(iris, "writeXLSXTable4.xlsx", asTable = TRUE, # headerStyle = createStyle(textRotation = 45)) # # ## ----include=TRUE,tidy=TRUE, eval = FALSE ,highlight=TRUE--------------------- # l <- list("IRIS" = iris, "colClasses" = df) # write.xlsx(l, file = "writeXLSX6.xlsx", borders = "columns", headerStyle = hs) # write.xlsx(l, file = "writeXLSXTable5.xlsx", asTable = TRUE, tableStyle = "TableStyleLight2") # # openXL("writeXLSX6.xlsx") # openXL("writeXLSXTable5.xlsx") ## ----include=TRUE,tidy=TRUE, eval = FALSE ,highlight=TRUE--------------------- # wb <- write.xlsx(iris, "writeXLSX6.xlsx") # setColWidths(wb, sheet = 1, cols = 1:5, widths = 20) # saveWorkbook(wb, "writeXLSX6.xlsx", overwrite = TRUE) ## ----include=TRUE,tidy=TRUE, eval = FALSE ,highlight=TRUE--------------------- # require(ggplot2) # wb <- createWorkbook() # options("openxlsx.borderColour" = "#4F80BD") # options("openxlsx.borderStyle" = "thin") # modifyBaseFont(wb, fontSize = 10, fontName = "Arial Narrow") ## ----include=TRUE,tidy=TRUE, eval = FALSE ,highlight=TRUE--------------------- # addWorksheet(wb, sheetName = "Motor Trend Car Road Tests", gridLines = FALSE) # addWorksheet(wb, sheetName = "Iris", gridLines = FALSE) ## ----include=TRUE,tidy=TRUE, eval = FALSE ,highlight=TRUE--------------------- # freezePane(wb, sheet = 1, firstRow = TRUE, firstCol = TRUE) ## freeze first row and column # writeDataTable(wb, sheet = 1, x = mtcars, # colNames = TRUE, rowNames = TRUE, # tableStyle = "TableStyleLight9") # # setColWidths(wb, sheet = 1, cols = "A", widths = 18) ## ----include=TRUE,tidy=TRUE,