[R] Updating a worksheet in Excel file using RODBC
Prof Brian Ripley
ripley at stats.ox.ac.uk
Fri Mar 23 09:34:58 CET 2007
The problem is that way the ODBC driver exposes table names is not valid
SQL, and nor is the way quoting has to be used. You can get around this
via direct SQL sent by sqlQuery. In addition, by default the Excel ODBC
driver gives you read-only access to worksheets.
Searching the list archives, would help, for example this answer:
https://stat.ethz.ch/pipermail/r-help/2007-March/127851.html
Making a wrapper interface in RODBC is on my TODO list, but not anywhere
near the top.
On Fri, 23 Mar 2007, Moshe Olshansky wrote:
> Hello!
>
> I have no problem reading Excel files (each worksheet in the file is a "table" which can be read - at least in my case).
>
> What I would like to do is to read such a table, change it (just the contents, not the format) and write it back, and this I can not do. I am getting the following error messages (3 slightly different attempts):
>
>> sqlSave(con, x, tablename = "Chimaera20_3years$", append = FALSE,
> + rownames = FALSE, colnames = TRUE,
> + verbose = TRUE, oldstyle = FALSE,safer=FALSE)
> Query: CREATE TABLE Chimaera20_3years$ (Date varchar(255), 000Tax varchar(255), 1500Tax varchar(255), 3000Tax varchar(255), 4650Tax varchar(255))
> Error in sqlSave(con, x, tablename = "Chimaera20_3years$", append = FALSE, :
> [RODBC] ERROR: Could not SQLExecDirect
> 37000 -3551 [Microsoft][ODBC Excel Driver] Syntax error in CREATE TABLE statement.
>
>> sqlSave(con, x, tablename = "[Chimaera20_3years$]", append = FALSE,
> + rownames = FALSE, colnames = TRUE,
> + verbose = TRUE, oldstyle = FALSE,safer=FALSE)
> Query: CREATE TABLE [Chimaera20_3years$] (Date varchar(255), 000Tax varchar(255), 1500Tax varchar(255), 3000Tax varchar(255), 4650Tax varchar(255))
> Error in sqlSave(con, x, tablename = "[Chimaera20_3years$]", append = FALSE, :
> [RODBC] ERROR: Could not SQLExecDirect
> 37000 -3553 [Microsoft][ODBC Excel Driver] Syntax error in field definition.
>
>> sqlSave(con, x, tablename = "[Chimaera20_3years]", append = FALSE,
> + rownames = FALSE, colnames = TRUE,
> + verbose = TRUE, oldstyle = FALSE,safer=FALSE)
> Query: CREATE TABLE [Chimaera20_3years] (Date varchar(255), 000Tax varchar(255), 1500Tax varchar(255), 3000Tax varchar(255), 4650Tax varchar(255))
> Error in sqlSave(con, x, tablename = "[Chimaera20_3years]", append = FALSE, :
> [RODBC] ERROR: Could not SQLExecDirect
> 37000 -3553 [Microsoft][ODBC Excel Driver] Syntax error in field definition.
>
> Am I doing it wrong way or is there a problem with the Excel driver?
>
> Thank you in advance,
>
> Moshe Olshansky
> Chimaera Capital Group
>
>
> Moshe Olshansky
>
> Chimaera Capital Limited
> Level 4 / 349 Collins Street
> Melbourne, Victoria 3000
> Phone: +613 8614 8400
> Fax: +613 8614 8410
> Email: molshansky at chimaeracapital.com
>
> Disclaimer: This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Chimaera Capital Limited. E-mail transmissions cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice.
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
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
More information about the R-help
mailing list