Because work needs, need to operate Excel, first understand how to read Excel this, did a demo, notes here
One, read Excel
UnitUnit1;InterfaceusesWindows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms, Dialogs, stdctrls,comobj;typeTForm1=class(tform) Btn1:tbutton; Dlgopen1:topendialog; procedureBtn1click (Sender:tobject); Private {Private Declarations} Public {Public Declarations} End;varForm1:tform1;Implementation{$R *.DFM}procedureTform1.btn1click (sender:tobject);varexcelapp,workbook:olevariant; Excelrowcount,i:integer; Strname,strage:string;begin ifDlgopen1.execute Then beginExcelapp:= Createoleobject ('Excel.Application'); WorkBook:=ExcelApp.WorkBooks.Open (dlgopen1.filename); Excelrowcount:= workbook.worksheets[1]. UsedRange.Rows.Count; //ShowMessage (IntToStr (Excelrowcount)); fori:=1 toexcelrowcount+1 Do beginStrName:= Excelapp.cells[i,1]. Value; Strage:= Excelapp.cells[i,2]. Value; {exits if one row is empty} if((strname="') and(strage="')) ThenExitElse beginShowMessage (strName); ShowMessage (strage); End; End; End; {finally close the connection}Workbook.close; Excelapp.quit; Excelapp:=Unassigned; WorkBook:=Unassigned;End;End.
read out the data, insert the database statement, Baidu on the internet to.
with do begin Close; Sql.clear;sql.add (INSERT INTO Test (name,address) VALUES (: name,:address)); Parambyname ('name'). asstring: = excelx; Parambyname ('address'). asstring: = excely; Execsql; End;
Delphi-manipulating Excel