电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

delphi批量导入数据

delphi批量导入数据_第1页
1/25
delphi批量导入数据_第2页
2/25
delphi批量导入数据_第3页
3/25
delp hi 批量导入数据 从Excel 中导入数据到Access 中: procedure TForm5.Button3Click(Sender: TObject); //excel 导入 var EXLfile:string; sheet,XLApp,workbook : variant; iRow,MaxRow:integer; begin if opendialog1.Execute then begin EXLfile:=opendialog1.FileName; screen.Cursor:=crHourGlass; try //创建对象 XLApp:=createOleObject('Excel.Application'); XLApp.displayAlerts:=false; //运行宏时是否显示警告和消息 XLApp.ScreenUpdating:=false; //屏幕更新功能,提高速度; XLApp.WorkBooks.Add(EXLfile); workbook := XLApp.workbooks[1]; sheet:=workbook.worksheets[1]; //sheet:=XLApp.WorkBooks[1].worksheets[1]; //得到最大行数 maxRow XLApp.ActiveCell.SpecialCells(xlLastCell).Select; maxRow:=XLApp.ActiveCell.Row; //当前行数 //最大行数 //写数据到access 库 with Dm1.aq_temp do begin Close; SQL.Clear ; SQL.Add('select * from peo '); open ; for iRow:=1 to MaxRow do // 循环次数为excel 最大行数字-1,因为excel 的第1 行为ID name 表头。 begin Edit; Append; fieldByName('P_No').asString:=sheet.cells[iRow,1]; fieldByName('P_Name').asString:=sheet.cells[iRow,2]; //导入 post; end; end; finally if not VarIsEmpty(XLApp) then begin //释放对象 XLApp.displayAlerts:=false; XLApp.ScreenUpdating:=true; //结束后,ScreenUpdating 设回到 True XLApp.quit; end; screen.Cursor:=crDefault; end; end; end; 现在sql 里有book 的表,里面有 id 书名 价格 id bookname price 1 社会与科学 18 2 delphi 入门 25 3 百科 30 在delphi 里现在希望先把数据从ex cel 导入到dbgrid 中,然后点“批量插入”时,把刚才所有存到导入的dbgrid 的数据插入到sql 中,问一下大家怎么才能做到,有二个关键代码 1.button1:“从ex cel 导入到dbgrid 中”的关键代码 2.bu tton2:"批量插入dbgrid 数据到数据库中"的关键代码 如果利用 dbgrid 其实就是利用数据集来操作 从ex cel 读数据,然后利用 adoqu ery .append; adoqu ery .fieldby name('').v alu e := 读的值 .... ... 然后,对dbgrid 进行编辑. 最后adoqu ery .post;就达到了批量提交了. 但这...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

delphi批量导入数据

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部