急救!急救!急救!急救!急救!急救!急救! 请问怎么将EXCEL中的数据导入到SQL的数据表中? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 给你一个控制Excel的例子,你一行行读出来写到SQL里面去procedure TfrmSG.Button1Click(Sender: TObject); //uses Excel2000 , ComObjvar pc_i:integer; xlapp,sheet: variant; WBK: OleVariant;begin xlapp := createoleobject('excel.application'); xlapp.visible := True; //Excel是否可见 if Trim(Edit1.Text)='' then begin Application.MessageBox('文件名不能为空','警告',MB_OK); Exit; end; WBK := xlapp.workbooks.Open(Edit1.Text); sheet := xlapp.workbooks[1].worksheets['sheet1']; sheet.Cells.SpecialCells(XlCellTypeLastCell,EmptyParam).Activate; //showmessage(IntToStr(xlapp.ActiveCell.Row)); //showmessage(IntToStr(xlapp.ActiveCell.Column)); //excelworksheet2.UsedRange[1].Rows.Count)); //excelworksheet2.UsedRange[1].Columns.Count)); pc_i:=1; Edit2.Text := sheet.cells[pc_i,1]; //写入的话用 sheet.cells[pc_i,1] := Edit2.Tex; WBK.Close(SaveChanges := True); xlapp.Quit;end; 那你怎么来打开存在的EXCEL呢 //参考如下代码~~//可以处理成SQL插入语句~~var vTemplate: OleVariant; vCell: OleVariant; vCol, vRow: Integer;begin with TExcelApplication.Create(nil) do try Connect; Visible[0] := True; vTemplate := 'c:\temp\temp.xls'; Workbooks.Add(vTemplate, 0); for vCol := 1 to 3 do for vRow := 1 to 3 do begin vCell := Chr(Ord('A') + vCol - 1) + IntToStr(vRow); StringGrid1.Cells[vCol, vRow] := Range[vCell, vCell].Value; end; Disconnect; finally Free; end;end; 基于sql server 的midas问题 工厂管理系统项目寻求公司或个人合作开发 關於fastreport,怎樣顯示組的頁數的 大侠们看看问题出在哪儿 如何在同一表中同时增加两条或多条记录,在线等!!! 鼠标指向一个控件时,右下角显示一个说明框这个功能怎么实现?? 关于SQL SERVER中ntext,nvarchar类型字段使用问题 简单问题,进者有分! 数据标的查询 一个很弱智力的问题,不花高手10秒钟 请问如何用Locate方法多字段条件定位记录? 大家帮忙看看这段程序及编译后提示的出错信息,在线讨论。谢谢先~!
procedure TfrmSG.Button1Click(Sender: TObject); //uses Excel2000 , ComObj
var
pc_i:integer;
xlapp,sheet: variant;
WBK: OleVariant;
begin
xlapp := createoleobject('excel.application');
xlapp.visible := True; //Excel是否可见
if Trim(Edit1.Text)='' then
begin
Application.MessageBox('文件名不能为空','警告',MB_OK);
Exit;
end;
WBK := xlapp.workbooks.Open(Edit1.Text);
sheet := xlapp.workbooks[1].worksheets['sheet1'];
sheet.Cells.SpecialCells(XlCellTypeLastCell,EmptyParam).Activate; //showmessage(IntToStr(xlapp.ActiveCell.Row));
//showmessage(IntToStr(xlapp.ActiveCell.Column));
//excelworksheet2.UsedRange[1].Rows.Count));
//excelworksheet2.UsedRange[1].Columns.Count));
pc_i:=1;
Edit2.Text := sheet.cells[pc_i,1]; //写入的话用 sheet.cells[pc_i,1] := Edit2.Tex;
WBK.Close(SaveChanges := True);
xlapp.Quit;
end;
//可以处理成SQL插入语句~~
var
vTemplate: OleVariant;
vCell: OleVariant;
vCol, vRow: Integer;
begin
with TExcelApplication.Create(nil) do try
Connect;
Visible[0] := True;
vTemplate := 'c:\temp\temp.xls';
Workbooks.Add(vTemplate, 0);
for vCol := 1 to 3 do
for vRow := 1 to 3 do begin
vCell := Chr(Ord('A') + vCol - 1) + IntToStr(vRow);
StringGrid1.Cells[vCol, vRow] := Range[vCell, vCell].Value;
end;
Disconnect;
finally
Free;
end;
end;