From gchappi at gmail.com  Mon Feb 12 10:50:43 2007
From: gchappi at gmail.com (Hans-Peter)
Date: Mon, 12 Feb 2007 10:50:43 +0100
Subject: [Rd] append within worksheet in write.xls
In-Reply-To: <45CC1E69.1070509@gmail.com>
References: <45CC1E69.1070509@gmail.com>
Message-ID: <47fce0650702120150n4a800e27p909adc0662456a83@mail.gmail.com>

Hi,

2007/2/9, Mark W Kimpel <mwkimpel at gmail.com>:
> I can currently append an entire worksheet with write.xls, but would
> also like to be able to append within the same worksheet. Is this
> possible?

Of course. Please see ?xls.open, ?xls.sheet and ?write.xls (note the
'keep' argument!). I give you a short example at the end of the email.

>It doesn't seem to work if I use append = T

I am not aware of an issue. Please post (better email) your code. BTW
the 'append' argument is only meant for single operations (the whole
sheet will be re-read and rewritten each time).

A last thing, such specific xlsReadWrite(Pro) questions are not very
on topic for the the r-devel list. I don't know for sure, but I
strongly suspect that this is not be appreciated here. It is probably
better you just email me.

Cheers,
Hans-Peter

--------
(the example is with read, but write is analogue)

rfile <- "TestReadDataFile.xls"

cat( "### TEST: xls.open and xls.close\n" )
exc <- xls.open( rfile )
res1 <- read.xls( exc,, 1, from = 3, cols = 1 )[[1]]
  # switch to character sheet, check and read
xls.sheet( exc, "select", "characterSheet" )
  # switch to logical sheet, check and read
xls.sheet( exc, "select", "logicalSheet" )
res1 <- read.xls( exc, type = "logical", from = 3, cols = 1 )
xls.close( exc )

cat( "### TEST: keep\n" )
  # read first column from first sheet
res1 <- read.xls( rfile,, 1, from = 3, cols = 1, keep = TRUE )[[1]]
  # switch to character sheet, check and read
xls.sheet( rfile, "select", "characterSheet", keep = TRUE )
  # switch to logical sheet, check and read
xls.sheet( , "select", "logicalSheet", keep = TRUE )
  # with the next command the file will be closed (without saving)
res1 <- read.xls( , type = "logical", from = 3, cols = 1, keep = FALSE )



[Rd] append within worksheet in write.xls
Hans-Peter