Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Importing / Linking / August 2004

Tip: Looking for answers? Try searching our database.

Data Types when using Jet.OLEDB.4.0 with Excel datasource

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Martin Newman - 13 Aug 2004 10:58 GMT
I have a fairly complex export routine that outputs data from access (an adp
actually) to a
Excel spreadsheet (v8 but actually deployed to and works happily with
Excel 2003).  This is done in code rather than as an export,  it is quite
a complex export and can't be done as a "straight" export, I don't think
(OK might be possible with a very complicated query and/or temporary
tables).

Anyway, it is a two part process in the first part my program creates the
field headers (i.e. row 1, a set of field names, obviously strings) and in
the second it works its way through a recordset extracting data items,
manipulating them and then writing what is required to the excel sheet.

And it works jolly well.

Except that any data that is "obviously" numeric is shoved out as strings
e.g 24 is output as '24, presumably because the oledb provider sees the
row headers (field names) as being strings and says the whole column must
be strings.  This is more of an annoyance than anything else, but it is a
serious annoyance and so is there a way round this?

M
John Nurick - 14 Aug 2004 14:36 GMT
Hi Martin,

IME if you need full control over what goes on in Excel it's best to
automate the Excel object model and address the cells directly, rather
than to treat the worksheet as a table.

That said, how are you creating the worksheet and inserting the field
names? Without having tested it thoroughly I get the impression that if
you create a worksheet, put the field names in the top row and then
execute queries to append the data you'll get the numbers-as-text effect
you're having. But if you create the worksheet with a make-table query
that returns the appropriate field types, subsequent append queries will
append number field values as numbers. This seems to be the case even if
the initial make-table query created a table with zero rows.

Here are the queries I just tried this with:

Make-table query that returns no records:

SELECT ID, FirstName, LastName INTO
 [Excel 8.0;HDR=Yes;Database=C:\Temp\XX.xls;].[Sheet1]
FROM AddrNew WHERE False;

Append query:
INSERT INTO
 [Excel 8.0;HDR=Yes;Database=C:\Temp\XX.xls;].[Sheet1]
SELECT  ID, FirstName, LastName  
 FROM AddrNew;

>I have a fairly complex export routine that outputs data from access (an adp
>actually) to a
[quoted text clipped - 18 lines]
>
>M

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
Martin Newman - 14 Aug 2004 17:03 GMT
Well actually I am not even using a query - I am picking the data for the
spreadsheet up from loads of places in a way that I really can't even begin
to think how I would do in (T)SQL - it;s an adp by the way, the make table
query isn't an option AFAIAA - so I am using ADO addnew and filling the
recordset manually.

I am much less familiar with the Excel object model but what you are saying
is that I should be able to use that to ebnsure numeric values are numeric -
any clues, anyone, on how I do that? This may of course be obvious but I
have rarely played with Excel at the programatioc level.

Thanks for your helpful reposnse, John

M

> Hi Martin,
>
[quoted text clipped - 52 lines]
>
> Please respond in the newgroup and not by email.
Martin Newman - 14 Aug 2004 17:58 GMT
Forget that question - just seen one of your other postings

> Well actually I am not even using a query - I am picking the data for the
> spreadsheet up from loads of places in a way that I really can't even begin
[quoted text clipped - 69 lines]
> >
> > Please respond in the newgroup and not by email.
John Nurick - 14 Aug 2004 19:11 GMT
Glad to help.

>Forget that question - just seen one of your other postings
>
[quoted text clipped - 81 lines]
>> >
>> > Please respond in the newgroup and not by email.

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.