> > Sekalian mau tanya :
> > Bagaimana trik nya untuk memindahkan data dari DBGrid ke MS Excel ?
> > Sepertinya kita harus tahu "struktur Data di Clipboard" yg bisa
> > diterima Excel.
> > Bagaimana kita bisa tahu infromasi ini ?
> > Apakah ada rekan yg pernah berhasil ?
Actually, this is surprisingly easy to do. Format clipboard yang
diterima adalah sama seperti CSV (bisa dengan comma-separated,
atau tab-separated. ) Silakan lihat sourcecode dibawah.

Salam,
sugi.

...
procedure DatasetToClipboard( ds : tDataset ); 
const     CHAR_TAB = #9;
          CHAR_CR = #10;
var       bm : TbookmarkStr;
          str : string;
          i : integer;
          sl : TStringList;
begin
     //
     str := '';
     sl := TStringList.Create;

     try
     Screen.Cursor := crHourGlass;
     ds.DisableControls;
     bm := ds.Bookmark;

     ds.First;
     while ds.Eof = false do begin
           str := '';
           for i:=0 to ds.FieldCount-1 do begin
               str := str + ds.Fields[i].AsString + CHAR_TAB;
           end;
           sl.Add(str);
           ds.next;
           application.processmessages;
     end;

     Clipboard.AsText := sl.Text;

     finally
     sl.free;
     ds.Bookmark := bm;
     ds.EnableControls;
     Screen.Cursor := crDefault;
     end;
end;


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/CBxunD/vN2EAA/xGHJAA/i7folB/TM
---------------------------------------------------------------------~->

Berlangganan: [EMAIL PROTECTED]
Stop Berlangganan: [EMAIL PROTECTED]
Keluhan Milis(Unbouncing,spam,dll): [EMAIL PROTECTED] 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 


Kirim email ke