Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Reading Excel
Message
De
13/10/2008 17:23:52
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01354695
Message ID:
01354701
Vues:
20
>Anyone have a link on how to read/iterate through a spreadsheet in code.

I think that after reading my introductory article on Excel Automation, and getting some practice, it should be fairly easy.

www.utmag.com, September 2002.

When reading you may need some additional controls (as opposed to writing to a spreadsheet) - for example, a cell that you expect to be character may suddenly be numeric, just because it happens to contain only digits.

However, the tricky part is not so much technical. The tricky part is educating your users to present the same information always in the same format. It is virtually impossible to do a decent import if the user suddenly adds an additional column, or expands the header (more rows), for example.

You should set up a document that describes, in detail, the expected format. It may be sensible to have the users sign something!

About the technical part: You fetch a cell value just as you write a value to a cell - with something like
lcSomeVariable = oSheet.Cells(1,1).Value
Remember, additional checks may be needed.

I don't remember exactly how to open a spreadsheet; try to save a macro and adapt the commands, as suggested in my article. I think you must get hold of some .ActiveSheet property or something.

If you don't manage to do it, I will search for some sample code from my previous work. Ask back for any additional doubts, but be sure to try saving a macro first, since that should solve about 90% of your questions.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform