首页 > 其他 > 详细

复制粘贴Excel数据列表到StringGrid

时间:2014-06-06 11:42:17      阅读:372      评论:0      收藏:0      [点我收藏+]

复制粘贴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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!