procedure TForm1.BitBtn1Click(Sender: TObject); var sheetCount,i:Integer; begin if Not OpenDialog1.Execute then Exit; eclApp:=CreateOleObject('Excel.Application'); WorkBook:=eclApp.workBooks.Open(Trim(OpenDialog1.FileName)); sheetCount := workbook.Worksheets.Count; MLblComboBox1.Items.Clear; for i:=1 to sheetCount do MLblComboBox1.Items.Add(eclApp.sheets[i].Name); MLblComboBox1.Text:=eclApp.sheets[sheetCount].Name; end;
procedure TForm1.BitBtn2Click(Sender: TObject); begin if Trim(MLblComboBox1.Text)=' then Exit; Sheet:=WorkBook.Sheets[MLblComboBox1.Text]; Sheet.Activate; eclApp.Visible:=True; end; |