#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2007
    Posts
    169
    Rep Power
    37

    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!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2010
    Posts
    68
    Rep Power
    5
    Hi
    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.

    Dimiter
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2008
    Posts
    356
    Rep Power
    7
    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

    • Dimixx agrees
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    1
    Rep Power
    0
    good ......
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0

    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.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2007
    Posts
    169
    Rep Power
    37

    Re


    VAR
    S, T, U, V:STRING;
    vTemp:string;
    newpos:integer;
    begin

    S := Clipboard.AsText;

    while s <> '' do
    begin
    t := copy(s, 1, pos(#9, s) - 1);
    //to get the columns, parse "t"
    ShowMessage(T);

    vTemp := Copy(S, pos(#9, S) + 1, Length(S));
    u := copy(vTemp, 1, pos(#9, vTemp) - 1);
    ShowMessage(u);

    vTemp := Copy(u, pos(#9, u) + 1, Length(u));
    v := vtemp;
    ShowMessage(v);
    end;


    i am trying to get each character that i have in excel..my excel file looks like this

    1,2,3
    4,5,6
    7,8,9

    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.

    Any ideas?

IMN logo majestic logo threadwatch logo seochat tools logo