Excel sheet directly as an Source

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
ORACLE_1
Premium Member
Premium Member
Posts: 35
Joined: Mon Feb 16, 2009 1:19 pm

Excel sheet directly as an Source

Post by ORACLE_1 »

Hey Gurus ,

I am trying to to find out ways to read data from Excel Sheet on a windows box from the datastage tool (server installed on Unix box).
I can think of two ways -

1. ODBC - Not sure if this will work , and how? Do I require to download any other tools/driver on the server box?

2. Convert the Excel to CSV - This works fine but not able to automate the Excel to CSV conversion? Any other ways to do it? I am aware of the sharewares available online but any other way?

I did try to search on this topic but did not get any relevant information.

Thanks in Advance.
jcthornton
Premium Member
Premium Member
Posts: 79
Joined: Thu Mar 22, 2007 4:58 pm
Location: USA

Post by jcthornton »

Even with the ODBC option, you would still need to get the data accessible from the server. That would entail setting up the workstation (I am assuming since you are talking about Excel from Windows) to be accessible through ODBC as a server or as an FTP server.

Then you connect via ODBC or FTP.

Or you choose another option.

I have had a lot more success with CSV files saved off to a network share that is accessible to both the user updating the spreadsheet and DataStage.

Either train the user to save the CSV file off, or build a macro that can be easily triggered to save the file off to the correct location. It may even be possible to trigger the macro to work whenever the spreadsheet gets saved, if that is your preference (potential problems with this however).

Either way, have a read-only copy of the spreadsheet somewhere so that the correct layout can be recovered when somebody accidentally messes it up.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

And they will 'accidentally' mess it up. Repeatedly. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ORACLE_1
Premium Member
Premium Member
Posts: 35
Joined: Mon Feb 16, 2009 1:19 pm

Post by ORACLE_1 »

jcthornton wrote:...build a macro that can be easily triggered to save the file off to the correct location. It may even be possible to trigger the macro to work whenever the spreadsheet gets saved, if that is your preference (potential problems with this however).
I agree that CSV file is the best option to implement here which will make things lot more easy and transparent.
The excel that I am trying to read contains "formulaes" which point to other excel sheet. But not an issue I am still able to save it as CSV without an issue with all the data intact.
The issue is to automate this , the user enters data in the underlying sheets and not in the main excel , so running the macro at that time is not possible ( i think ). Also one of the resources developed this macro which is very unreliable when "Scheduled" to run. Is it possible if you can share an example or so to help?
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post by Kryt0n »

You can run a macro on just about any event but running a macro every time a user changes something would make it unworkable... and create one unhappy user!

Easiest method that springs to my mind is to override the save event (quick peek and I can see there is a Before Save event)... has the advantage that the user is expecting to wait at this point and you only ever write to the CSV what the user wants to save.
jcthornton
Premium Member
Premium Member
Posts: 79
Joined: Thu Mar 22, 2007 4:58 pm
Location: USA

Post by jcthornton »

So the changes would be made in a single workbook, but the users would not be updating the worksheet that needs to be exported?

If this is the case that you are dealing with, I have not built such a macro, but it looks like it can be done using the BeforeSave event.

Worksheets("Sheetname").Activate
ActiveWorksheet.SaveAs "<targetfile>", fileformat:=xlCSV

This should point you in the right direction.
Post Reply