Topic: How To Copy From Excel To TableGrid

How To Copy All Value From Excel  To Grid  in MVD  By Ctrl+C ,Ctrl+V

https://i.ibb.co/gT74Q1g/2019-01-22-001.png

My Visual Database : I Love You
Easy For Beginner Student For Me

Re: How To Copy From Excel To TableGrid

That's very very interesting how we can do that.

Re: How To Copy From Excel To TableGrid

I think try use function clipboardget  and splitter string but
i don't know use even  at tablegrid ???

My Visual Database : I Love You
Easy For Beginner Student For Me

Re: How To Copy From Excel To TableGrid

Do you want insert data to a TableGrid or to database after show it in a TableGrid?

Dmitry.

5 (edited by prahousefamily 2019-01-22 14:29:41)

Re: How To Copy From Excel To TableGrid

I want to copy value from excel to tablegrid and insert to table in database ...

excel --> tablegrid --> database

help increase speed  when input data

My Visual Database : I Love You
Easy For Beginner Student For Me

Re: How To Copy From Excel To TableGrid

This will be one of the best functions if it works. Can we get a quicker answer please...

Re: How To Copy From Excel To TableGrid

Example:

procedure Form1_TableGrid2_OnKeyDown (Sender: TObject; var Key: Word; Shift, Alt, Ctrl: boolean);
var
    sl: TStringList;
    arrFields: array of string;
    i: integer;
begin

    if (Ctrl) and (Key=86) then // Ctrl+V
    begin
        sl := TStringList.Create;
        sl.Text := ClipboardGet; // get text from clipboard

        // insert to database
        for i := 0 to sl.Count-1 do
        begin
            arrFields := SplitString(sl[i], #9); // tab separator
            if Length(arrFields)=2 then 
            begin
                SQLExecute('INSERT INTO groups (groupname) VALUES('''+escape_special_characters(arrFields[1])+''')');
            end;
        end;
        sl.Free;
    end;
    Form1.TableGrid2.dbUpdate;
end;
Dmitry.

Re: How To Copy From Excel To TableGrid

I have create an example but didn't work. I know that have a mistake somwhere  but can not find it. Is it possible to send us a simply example so I can study it ?
Thank you in advance

Re: How To Copy From Excel To TableGrid

Thank You Dmitry. Again
This Example Now use Ctrl+V only can not use right click Paste
https://i.ibb.co/N7rxP1H/2019-01-28-004.png


How To Use This  Effect
Step 1 Check Form Event
https://i.ibb.co/kSywC4y/2019-01-28-002.png
Step 2 Check Script (Next Example I try modify script support Field more 2)
https://i.ibb.co/6rWRmr5/2019-01-28-003.png
Setp 3 - 4 Copy and Use Ctrl+V
https://i.ibb.co/YZfSPJk/2019-01-28-005.png

Post's attachments

Attachment icon CopyScript.zip 434.32 kb, 447 downloads since 2019-01-28 

My Visual Database : I Love You
Easy For Beginner Student For Me

Re: How To Copy From Excel To TableGrid

Thank you so much, it's perfect.

Re: How To Copy From Excel To TableGrid

but paste not working for child table grid