Home > Back-end >  How to implement in Delphi will Excel data into database
How to implement in Delphi will Excel data into database

Time:10-14

How to implement in Delphi will Excel data into database

CodePudding user response:

Excel import database??/I only export to,,,
Excel import database to verify the data

CodePudding user response:

 
Const
CNNSTR='. The Provider=Microsoft Jet. The OLEDB. 4.0. The Data Source=% s. Extended Properties=8.0 Excel; Persist Security Info=False ';

Procedure btnLoadExcelClick (Sender: TObject);
Var
Filename: the String;
S_1: String;
S_2: String;
S_3: String;
The begin
Try
ADOQuery1. Close;
ADOQuery1. The ConnectionString:=Format (CNNSTR, [filename]);
//Sheet1 workbook for Excel file name
ADOQuery1. SQL. Text:='SELECT * FROM [Sheet1 $]'.
ADOQuery1. Open;

ADOQuery1. First;
While not ADOQuery1. Eof do
The begin
S_1:=ADOQuery1. Fields. The Fields [0]. AsString;
S_2:=ADOQuery1. Fields. The Fields [1]. The AsString;
S_3:=ADOQuery1. Fields. Fields. [2] AsString;

ADOQuery1. Next;
end;
The finally
ADOQuery1. Close;
end;
end;

//this value from the Excel, the rest of the written to the database, the original poster is yourself, insert or update

CodePudding user response:

Recommend the use of the third control, it is fast, second, do not use the Ole,

CodePudding user response:

Excel import database must first see you excel data formats whether accord with a standard, if your good excel data is according to the column row, or the first line is the column name, or the first row is data,
If accords with afore-mentioned conditions, can be directly imported with the method of the second floor,
If does not conform to, then can only read a single cell data to fill in,

Of course, also can write vba in excel import SQL, or SQL directly into excel,

CodePudding user response:

XLSReadWrite4
  • Related