February 10th, 2012, 01:14 AM
Copy Excel into delphi
I want to know if it is possible to copy an excel spreadsheet into delphi.
What i want to do is to copy the sheet into the WINDOWS CLIPBOARD then somehow control it in my program. Is there a way of doing it?
Many thanks in advanced!
February 10th, 2012, 01:39 PM
you can read here Basic Clipboard Operations (Cut/Copy/Paste) using the TClipboard object. You don't mention how you want to present the information from the clip board in your program. If I have to guess you may want to add it in a grid. So you can load your clipboard in TStrings varaible or a TStringList and then manually add it in a ClientDataSet.
February 11th, 2012, 02:35 PM
You may want to look towards automating excel through OLE automation, rather than using the clipboard. Taking control of a user's clipboard is less than an optimal method.
By inserting something into the clipboard, you'd also be wiping out what may have been put there by a user, and they'd be left wondering what happened.
There's lots of good articles on automating excel from Delphi, here's one: http://edn.embarcadero.com/article/10126
Comments on this post
September 4th, 2012, 05:49 AM
September 30th, 2012, 11:37 AM
EOleSysError in Windows 7
I'm using Delphi 4 and in trying to open Excel through my Delphi program in Windows 7, I get an exception as the program is starting... "Exception EOleSysError in module MYPROGRAM.EXE at 000979C5, Class not registered." The code works just fine in an XP environment.
December 18th, 2012, 04:47 AM
S, T, U, V:STRING;
S := Clipboard.AsText;
while s <> '' do
t := copy(s, 1, pos(#9, s) - 1);
//to get the columns, parse "t"
vTemp := Copy(S, pos(#9, S) + 1, Length(S));
u := copy(vTemp, 1, pos(#9, vTemp) - 1);
vTemp := Copy(u, pos(#9, u) + 1, Length(u));
v := vtemp;
i am trying to get each character that i have in excel..my excel file looks like this
Is there a beter way. I just dont get what i want. Ideally i want "1", "2", "3" first line add it to a database then go the 2nd line "4", "5", "6". *without quotes.