I have a pre-formatted Microsoft Excel workbook which I am using as a template. I then want to paste my data.table into the workbook from R, leaving the column titles and formatting intact.
This should be feasible with the package XLConnect:
# Load library
library(XLConnect)
# Load pre-formatted MS Excel workbook
wb <- loadWorkbook("Myworkbook.xlsx")
# Write data.table to existing worksheet excluding column names:
writeWorksheet(wb, mydt, sheet = "Datasheet1", startRow = 3, startCol = 1, header = FALSE)
# Save the data to the workbook
saveWorkbook(wb)
However, when I run this I get the following java error:
Error: NoSuchMethodError (Java): org.apache.poi.ss.usermodel.Cell.setCellType(Lorg/apache/poi/ss/usermodel/CellType;)V
I'm using R version 3.4.0 with RStudio version 1.0.143 with XLConnect_0.2-13 and rJava_0.9-8, Java version is Java 8 Update 66 (64-bit) on a Windows 7 OS with Microsoft Office 2010.
Any ideas on why this might not be working would be much appreciated - I can create workbooks and worksheets from scratch so it seems just appending data to existing worksheets is affected.