那要求你的EXCEL的栏位要固定,然后你将工作表读出来,按栏位赋值到你EXE里的对应输入框就行了,(很多程式是通过XML实现的,可以方便的导出和导入),有段程式你按注释中的方法试试
procedure TMainForm.Button3Click(Sender: TObject);
var
oExcelApp, oSheet, oWorkBook : Variant;
cFileName : string;
iQty: integer;
begin
//iQty := StrToInt(QtyLabel.Caption);
try
oExcelApp := CreateOleObject('Excel.Application');
oExcelApp.Visible := False;
except
ShowMessage('Microsoft Excel⊿Τ?杆?叫??杆Excel');
Exit;
end;
GetDir(0,cFileName);
cFileName := cFileName + '/123.xls';
if FileExists(cFileName) then begin
oWorkBook := oExcelApp.WorkBooks.Open(cFileName);
oSheet := oWorkBook.Sheets[1];
end else begin
ShowMessage('隔畖'+cFileName+'ゼт?┮惠秨币ゅン');
Exit;
end;
// oSheet.Cells[4,3].Value := '*' + cPalletNo + '*' ;
//oSheet.Cells[5,3].Value := cPalletNo;
//oSheet.Cells[7,3].Value := cCountry;
//oSheet.Cells[9,3].Value := iQty;
//oSheet.Cells[11,3].Value := FormatDateTime('YYYY-MM-DD', Date);
oWorkBook.PrintOut;
oWorkBook.Close(False);
oExcelApp.Quit;
oExcelApp := 'NULL' ;
end;