procedure TFormDataImport.ToolButton7Click(Sender: TObject);
Var
lMsg: String;
begin
lMsg := '';
OpenDialog1.Filter := 'Excel(*.xls)|*.xls';
if OpenDialog1.Execute then
begin
DataSetTargetDef.Open;
DataSetTargetDef.EmptyDataSet;
ExcelToTable.FileName := OpenDialog1.FileName;
ExcelToTable.StartRow := 1;
ExcelToTable.EndRow := 5000;
ExcelToTable.Execute(lMsg);
end;
end;
procedure TFormDataImport.ToolButton9Click(Sender: TObject);
begin
SaveDialog1.Filter := 'Excel(*.xls)|*.xls';
SaveDialog1.FileName := 'sheet1.xls';
if SaveDialog1.Execute then
DataGrid3.SaveToXLS(SaveDialog1.FileName+'.xls',true);
procedure TMainForm.Button1Click(Sender: TObject);
var
lExcelToTable:TExcelToTable;
lmsg:string;
begin
if OpenDialog1.Execute then
begin
lExcelToTable:=TExcelToTable.Create(self);
try
lExcelToTable.FileName := OpenDialog1.FileName;
lExcelToTable.DataSource:=DataSetBroker1;
if ExcelFieldMapFunc.ShowFieldMapEditor(lExcelToTable) then
begin
if not lExcelToTable.Execute(lmsg) then
begin
jsDialogs.ShowError(lmsg, '导入excel失败!');
end ;
end;
finally
lExcelToTable.free;
end;
end;
end;