writeWorkSheet function in R not pasting values into Excel -
i trying copy data r data frame (shipments
) excel file using writeworkbook
function in xlconnect
package. however, not copying excel file. execution doesn't result in error/warning appearing in console. doesn't copy.
i have loaded library xlconnect , made sure not loading library xlsx. column copied has been type-casted dataframe thought might issue.
wbnames
additional thing. directly wrote sheet name in writeworkbook , should have worked fine. wbnames
there hasn't been change in result.
i intended copy content macro file , run macro file r wasn't working. thought may because of macro file function not working on .xlsx itself.
so, not sure issue. grateful if can here. missing something?
library(xlconnect) library(rdcomclient) xlapp <- comcreate("excel.application") xlwbk <- xlapp$workbooks()$open(filepath+filename.xlsx) xlwb <- loadworkbook(filepath+filename.xlsx) wbnames <- as.vector(getsheets(xlwb)) # copy column existing data frame , paste first # sheet of filename.xlsx, starting @ row#6, no headers , no rownames: writeworksheet(xlwb, as.data.frame(shipments$shipment_id), sheet = wbnames[1], startrow = 6, header = f, rownames = null)
xlwb
r-object contains workbook. looks data has been written workbook, good. in order view in excel format, however, still need save workbook excel. add line after code , should see document called your_file_name.xlsx
data in working directory:
xlconnect::saveworkbook(xlwb, "your_file_name.xlsx")
Comments
Post a Comment