Link to home
Start Free TrialLog in
Avatar of TheNeil
TheNeil

asked on

Excel Server: Why oh why oh why...

Ok experts, anyone fancy stopping me from commiting suicide?

I'm supposed to writing some code to import Excel data via the Excel Server component. Just one problem: I have no idea what is going on.

What I need to do is open a file, be able to extract data, modify the data, replace it, and save the data back out (possibly into another file).There's also the added bonus of possibly needing to create new tables and mess around with deleting/creating rows and columns.

Considering the fact that I don't even know which component I actually need, is there either a fantastic tutorial/demo or is some kindly soul in Ex-Ex land going to give me enough code samples to at least get me started.

Oh I can do without all this today...

The Neil
ASKER CERTIFIED SOLUTION
Avatar of RBertora
RBertora
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TheNeil
TheNeil

ASKER

That seems to beincedibly close to what I want with just one problem...I can't get it to work!

I've pasted your code in, and tried to create the type library but Delphi complains that the several of the types for Excel 8 already exist. I'm using Delphi 5 Enterprise and it already has the server components installed. I'm having trouble understanding how to use them

The Neil
Hmm I really can't help more than that as I don't have D5. You will just have to work it out from the D5 help, I hope its good help.. otherwise your'e gonna struggle for a while.
sorry I can't help any further
Rob.
Avatar of TheNeil

ASKER

Sorry Rob but there must be something going on in that switch from Delhi 4 to Delphi 5. I think I have a solution but this isn't an easy job using the Delphi help. If you still want the points then you can have them if you can give me a way to do one of the following (with example code if you can)

1. How do I save my data to a CSV file via Excel (either as a direct function/procedure or using the SendKeys function)

OR

2. How do I get the actual row and column counts (Rows.Count and Columns.Count just return stupid values)

The Neil

Hi,

1.

ExcelApp.WorkBooks[1].ActiveSheet.SaveAs('C:\WINNT\Profiles\RBertora\Personal\Book1.csv',6,False);


2. Rows.Count and Columns.Count will return the number of rows and columns that are highlited (ie the selected columns and rows) if nothing is selected/highlited this will return rubbish.

Rob.
Avatar of TheNeil

ASKER

Thanks Rob,

I didn't know you could just specify the file format in the filename - It all becomes so easy now.

As for the row/column count then nothing would have been selected which is why I was getting 256 columns and 65536 rows.

The Neil
thanks and
good luck in your project.
Rob.