Skip to content
Prev 295115 / 398506 Next

write.xls

Here is what it take to write out two sheets with XLConnect


# function to write out a sheet to an EXCEL file that I use
f.writeXLSheet <-
function (data, sheet, fileToWrite, rownames = NULL)
{
    require(XLConnect)
    writeWorksheetToFile(fileToWrite, data = data, sheet = sheet,
        rownames = rownames, styleAction = XLC$STYLE_ACTION.NONE)
}

df1 <- data.frame(c1=1:2, c2=3:4, c3=5:6)
df2 <- data.frame(c21=c(10.10101010101,20, 3), c22=c(50E50,60, 3) )
outFile <- 'df12.xls'

unlink(outFile)  # make sure there is no file to start with
f.writeXLSheet(df1, 'df1', outFile)
f.writeXLSheet(df2, 'df2', outFile)

I have attached the resulting Excel file (see how far it makes it).

On Sun, May 20, 2012 at 7:15 PM, Spencer Graves
<spencer.graves at structuremonitoring.com> wrote: