我看了很多操作excel 的例子 不是很理想,我的目的是这样的 :
1:我的excel表格式不都是一样了,我要读取他们每一个的值, 然后汇总出来 写成一个新的excel
procedure TForm1.xpButton4Click(Sender: TObject);
var
SQLStr:string;
begin
if ((Excel.Text<>'')and(Access.Text<>'')and(e.Text<>'')and(a.Text<>'')) then
begin
adoconnection1.Connected:=false;
ADOConnection1.ConnectionString:=
'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+access.Text+';'
+'Persist Security Info=False';
//ww:='select * into 3 FROM [excel 8.0;database='+excel.Text+'].[Sheet1$]';
SQLStr:='select * into '+a.Text+' FROM [excel 8.0;database='+excel.Text+'].['+e.Text+'$]';
ADOConnection1.Execute(SQLStr);
adoconnection1.Connected:=true;
showmessage('数据转换成功,谢谢你使用该软件!');
end
else
begin
showmessage('请输入完整数据!');
end;
end;procedure TForm1.xpButton3Click(Sender: TObject);
var
SQLStr2:string;
begin
if ((Excel.Text<>'')and(Access.Text<>'')and(e.Text<>'')and(a.Text<>'')) then
begin
adoconnection1.Connected:=false;
ADOConnection1.ConnectionString:=
'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+access.Text+';'
+'Persist Security Info=False';
//SQLStr2:='Select* Into Sheet2 In "'+Excel_Dialog.FileName+'" "Excel 8.0;" From ppp ';
SQLStr2:='Select* Into '+e.Text+' In "'+Excel.Text+'" "Excel 8.0;" From '+a.Text;
ADOConnection1.Execute(SQLStr2);
adoconnection1.Connected:=true;
showmessage('数据转换成功,谢谢你使用该软件!');
end
else
begin
showmessage('请输入完整数据!');
end;
end;上面的这样的代码 根本不能解决 格式很复杂的excel 的,我寻的就是能够 读写 复杂 的excel 的
请各位指点
1:我的excel表格式不都是一样了,我要读取他们每一个的值, 然后汇总出来 写成一个新的excel
procedure TForm1.xpButton4Click(Sender: TObject);
var
SQLStr:string;
begin
if ((Excel.Text<>'')and(Access.Text<>'')and(e.Text<>'')and(a.Text<>'')) then
begin
adoconnection1.Connected:=false;
ADOConnection1.ConnectionString:=
'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+access.Text+';'
+'Persist Security Info=False';
//ww:='select * into 3 FROM [excel 8.0;database='+excel.Text+'].[Sheet1$]';
SQLStr:='select * into '+a.Text+' FROM [excel 8.0;database='+excel.Text+'].['+e.Text+'$]';
ADOConnection1.Execute(SQLStr);
adoconnection1.Connected:=true;
showmessage('数据转换成功,谢谢你使用该软件!');
end
else
begin
showmessage('请输入完整数据!');
end;
end;procedure TForm1.xpButton3Click(Sender: TObject);
var
SQLStr2:string;
begin
if ((Excel.Text<>'')and(Access.Text<>'')and(e.Text<>'')and(a.Text<>'')) then
begin
adoconnection1.Connected:=false;
ADOConnection1.ConnectionString:=
'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+access.Text+';'
+'Persist Security Info=False';
//SQLStr2:='Select* Into Sheet2 In "'+Excel_Dialog.FileName+'" "Excel 8.0;" From ppp ';
SQLStr2:='Select* Into '+e.Text+' In "'+Excel.Text+'" "Excel 8.0;" From '+a.Text;
ADOConnection1.Execute(SQLStr2);
adoconnection1.Connected:=true;
showmessage('数据转换成功,谢谢你使用该软件!');
end
else
begin
showmessage('请输入完整数据!');
end;
end;上面的这样的代码 根本不能解决 格式很复杂的excel 的,我寻的就是能够 读写 复杂 的excel 的
请各位指点
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货