David Khabie-Zeitoune
2003-Jul-21 14:30 UTC
[R] RODBC: problem saving a new table in an "Excel database"
Hi I am using package RODBC version 1.0-1 under R version 1.7.1 on Windows XP Pro. I am having problems writing a new table to an (Excel) database using sqlSave. I connect to an empty Excel spreadsheet using odbcConnectExcel (which, I believe, uses the Microsoft Excel Driver DSN). Then I try and save a new table to the database(spreadsheet) using SqlSave, but obtain an error message. Below is some test code which reproduces the error (assuming that c:\test.xls is a standard "blank" Excel spreadsheet; i.e. Sheet1, Sheet2, Sheet3)> con = odbcConnectExcel("c:\\test.xls") > df = data.frame(x = rnorm(10), y = rnorm(10), z = letters[1:10]) > sqlSave(con, df)Error in sqlSave(con, df) : [RODBC] ERROR: Could not SQLExecute Where am I going wrong? Thanks, Dave
Prof Brian Ripley
2003-Jul-21 14:44 UTC
[R] RODBC: problem saving a new table in an "Excel database"
The driver does not support writing to Excel: did you check? On Mon, 21 Jul 2003, David Khabie-Zeitoune wrote:> Hi > > I am using package RODBC version 1.0-1 under R version 1.7.1 on Windows > XP Pro. I am having problems writing a new table to an (Excel) database > using sqlSave. > > I connect to an empty Excel spreadsheet using odbcConnectExcel (which, I > believe, uses the Microsoft Excel Driver DSN). Then I try and save a new > table to the database(spreadsheet) using SqlSave, but obtain an error > message. > > Below is some test code which reproduces the error (assuming that > c:\test.xls is a standard "blank" Excel spreadsheet; i.e. Sheet1, > Sheet2, Sheet3) > > > con = odbcConnectExcel("c:\\test.xls") > > df = data.frame(x = rnorm(10), y = rnorm(10), z = letters[1:10]) > > sqlSave(con, df) > Error in sqlSave(con, df) : [RODBC] ERROR: Could not SQLExecute > > Where am I going wrong? > > Thanks, > > Dave > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595