码迷,mamicode.com
首页 > 其他好文 > 详细

复制粘贴Excel数据列表到StringGrid

时间:2014-06-06 11:43:14      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:c   style   blog   a   http   ext   

复制粘贴Excel数据列表到StringGrid(XE3下编写)

注意引用:Vcl.Clipbrd

procedure TDataEditDrFrm.Excel1Click(Sender: TObject);
var
Copystrings:Tstringlist;
daorustring,daorustring1,daorustring2:string;
i,j,row1,row2:Integer;
begin
daorustring:=(Clipboard.AsText);
daorustring1:=StringReplace(daorustring,#$D#$A,‘,‘,[rfReplaceAll]); // #$D#$A
daorustring2:=StringReplace(daorustring1,#9,‘,‘,[rfReplaceAll]);
Copystrings:=TStringList.Create;
for i := 1 to daorustring2.Length do
begin
if daorustring2[i]<>‘,‘ then
Copystrings.Add(daorustring2[i]);
end;
row1:=1;
row2:=0;
while(row1<=Round(Copystrings.Count/2)) do
begin
for j := 1 to 2 do
begin
strngrd1.Cells[j,row1]:=Copystrings[row2];
row2:=row2+1;
end;
row1:=row1+1;
if strngrd1.RowCount<Round(row1/2) then
strngrd1.RowCount:=strngrd1.RowCount+1
end;

end;

 

 

 

bubuko.com,布布扣

复制粘贴Excel数据列表到StringGrid,布布扣,bubuko.com

复制粘贴Excel数据列表到StringGrid

标签:c   style   blog   a   http   ext   

原文地址:http://www.cnblogs.com/xygzs/p/3767175.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!