Section 5 Load and write to an excel sheet

5.1 Introduction

This section can be considered as a cheat sheet for loading and writing to an excel sheet.

5.2 Code

library(openxlsx)

# Put in HTML result table
source("utilities.R")
wb <- loadWorkbook("location/Your_Excel_File_Name.xlsx")
sheetname ="Sheet_name_that_you_want_to_write_on"
# You can write many table/content that you want in a sheet using writeData
writeData(wb, sheetname, table_you_want_to_write_on, startRow = 11, startCol = "F", colNames = F)
# Open a temporary version to check if we have the correct way that we want our data to be written in the Excel sheet file.
openXL(wb) 
# Then you can write the file with new/old name.
saveWorkbook(wb = wb, file = "location/Your_New/Old_Excel_File_Name.xlsx",overwrite = T)