Package XLConnect
was able to extract the pertinent information. I think the problem here is that Window's ODBC drivers can't handle some of the ad-hoc flexibility from Excel such as enforcing column wide formatting of variables. Just a strawman argument for this wonky error.
Read Excel file with multiple headers using RODBC
سؤال
I have an Excel file which was very beautifully doctored up from which I am extracting some data. There are two layers of "column heads", for instance:
Date
Month Day Year
12 5 2012
12 6 2012
12 12 2012
Where month/day/year are all nested under date. The subheadings are clear enough that I don't need the nominal top row header. However, the bottom row is useful for identifying variables. Furthermore, when I read these using RODBC connections, to my chagrin I realize that the second row is treated as a data element and inconsistent with the labeling in the XLS schema. Any character variable has a header come through accurately, but numeric valued columns return missing values for the second header, regardless of how many rows I return from the query.
> X <- sqlFetch(my.xls, 'this table')
> head(X)
Date F2 F3
NA NA NA
12 5 2012
12 6 2012
12 12 2012
> X <- sqlQuery(my.xls, 'select top 1 * from "this table$"')
> X
NA NA NA
How can I get these literal values out of the second header?
المحلول