
Burdan Excell Dosyasını Seçinçe Combobox Aktif Oluyor ve Çalışma Sayfalarını Listeliyor.

Burdaki Resimde İse Eşleştirme Yapıp SQL server veri Tabanına Aktarıyor.Ben Bunun Aynısını Paradox Veri Tabanı İçin Yapmak İstiyorum Yardımcı Olabilirmisiniz???
Hocanızın eposta adresini de verin, programı yazan arkadaş direk oraya mail atsın, size zahmet olmasınkaan_karabey yazdı:Proje dosyam bu kodlayabilirmisiniz proje ödevi teslim etmem gerekiyor
Vize yapmıyor hoca bu projenin bir bölümü sadece burası kaldı kodlayamadım vize notu olarak bu projeden not alacam yardımlarınızı bekliyorum
http://yadi.sk/d/i1C-09whEVgRz
Kod: Tümünü seç
USES ComObj;
Var
xstrExcelDosya : String;
xExcel : Olevariant;
xiSatir,xiSutun: Integer;
xiSutun_TC : Integer = 01; // Bu verilerin olduğu sütun varsayilanlari
xiSutun_Adi : Integer = 02; // 0 dersen <lütfen seçiniz> kalırlar...
xiSutun_Soyadi : Integer = 03;
xiSutun_DogTar : Integer = 04;
xiSutun_Cinsiyet : Integer = 05;
xiSutun_AnaAdi : Integer = 06;
xiSutun_BabaAdi : Integer = 07;
xiSutun_DogYer : Integer = 08;
xiSutun_Medeni : Integer = 09;
xiSutun_Eposta : Integer = 10;
xiSutun_KanGr : Integer = 11;
xiSutun_Tel : Integer = 12;
Procedure TForm1.ExcelDosyasiAc( strExcelDosyasi : String );
begin
Try
xExcel := CreateOleObject('Excel.Application'); // ComObj
xExcel.Workbooks.Open( strExcelDosyasi );
xExcel.Visible := True;
xExcel.WindowState := 2; // minimized
SetForegroundWindow(Application.Handle);
Except
MessageDlg('İşlem Başarısız...', mtError, [mbOk], 0);
Exit;
End;
end;
Procedure TForm1.CalismaSayfalari( ComboBox:TComboBox );
Const
xlCellTypeLastCell = $0000000B;
Var
iCalismaSayfasiSayisi,
iSayac : Integer;
strSayfa : String;
begin
ComboBox.Items.Clear;
ComboBox.Items.Add('<lütfen "Çalışma Sayfası" seçiniz>');
ComboBox.Style := csDropDownList;
iCalismaSayfasiSayisi := xExcel.Worksheets.Count;
For iSayac := 1 to iCalismaSayfasiSayisi do
begin
xiSatir := xExcel.Worksheets[iSayac].Cells.SpecialCells(xlCellTypeLastCell, EmptyParam).Row;
xiSutun := xExcel.Worksheets[iSayac].Cells.SpecialCells(xlCellTypeLastCell, EmptyParam).Column;
strSayfa := Format('Sayfa%d ( %d Satır %d Sütun )', [ iSayac, xiSatir, xiSutun ]);
ComboBox.Items.Add( strSayfa );
end;
if ComboBox.Items.Count > 0
then ComboBox.ItemIndex := 0;
end;
procedure TForm1.SpinEdit1Change(Sender: TObject);
begin
if TSpinEdit(sender).Value < 1 then TSpinEdit(sender).Value := 1;
ComboBox1Change(ComboBox1);
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
Const
iBasSatir = 03; // ilk veri satırı
Var
iSayac, iSutun: Integer;
begin
if ComboBox1.ItemIndex > 0 then
begin
SpinEdit1.Enabled := True;
BitBtn3.Enabled := True;
for iSayac := 0 to Self.ComponentCount-1 do
begin
if ( Self.Components[iSayac] is TComboBox )
AND ( TComboBox( Self.Components[iSayac] ) <> ComboBox1 )
then
begin
TComboBox( Self.Components[iSayac] ).Items.Clear;
TComboBox( Self.Components[iSayac] ).Items.Add('<lütfen seçiniz>');
TComboBox( Self.Components[iSayac] ).Style := csDropDownList;
TComboBox( Self.Components[iSayac] ).ItemIndex := 0;
end;
end;
iSayac := SpinEdit1.Value;
for iSutun := 1 to xiSutun do
begin
Application.ProcessMessages;
// Önce ComboBox2'ye iSayac satırdaki tüm sütunlar eklenir...
// Sonra bu diğer ComboBox'lara aktarılır...
ComboBox2.Items.Add( xExcel.Cells[iSayac, iSutun] );
end;
for iSayac := 0 to Self.ComponentCount-1 do
begin
if ( Self.Components[iSayac] is TComboBox ) // bir TComboBox
AND ( TComboBox( Self.Components[iSayac] ) <> ComboBox1 ) // çalışma sayfası listesi olan değil
AND ( TComboBox( Self.Components[iSayac] ) <> ComboBox2 ) // içi dolu olan değil
then
begin // geriye kalanlar...
TComboBox( Self.Components[iSayac] ).Items.Assign( ComboBox2.Items );
TComboBox( Self.Components[iSayac] ).ItemIndex := 0;
end;
end;
// Şimdi tüm combobox'larda aynı veri var.
ComboBox2.ItemIndex := xiSutun_TC ;
ComboBox3.ItemIndex := xiSutun_Adi ;
ComboBox4.ItemIndex := xiSutun_Soyadi ;
ComboBox5.ItemIndex := xiSutun_DogTar ;
ComboBox6.ItemIndex := xiSutun_Cinsiyet ;
ComboBox7.ItemIndex := xiSutun_AnaAdi ;
ComboBox8.ItemIndex := xiSutun_BabaAdi ;
ComboBox9.ItemIndex := xiSutun_DogYer ;
ComboBox10.ItemIndex := xiSutun_Medeni ;
ComboBox11.ItemIndex := xiSutun_Eposta ;
ComboBox12.ItemIndex := xiSutun_KanGr ;
ComboBox13.ItemIndex := xiSutun_Tel ;
end else
begin
SpinEdit1.Enabled := True;
BitBtn3.Enabled := False;
end;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
With TOpenDialog.Create(self) do
begin
Filter := 'Excel Dosyaları *.xls|*.xls';
FilterIndex := 1;
if Execute then
begin
xstrExcelDosya := FileName;
ExcelDosyasiAc( xstrExcelDosya );
CalismaSayfalari( ComboBox1 );
Free;
end;
end;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
Var
iSayac, iBas : Integer;
begin
if CheckBox1.Checked then
begin
With TQuery.Create(nil) do
begin
DatabaseName := Table1.DatabaseName;
SQL.Text := 'DELETE FROM KAYITLAR';
ExecSQL;
Free;
end;
Table1.Close;
Table1.Open;
end;
ProgressBar1.Max := xiSatir; // Excel Satır Sayısı
iBas := 1;
if CheckBox2.Checked then Inc(iBas); // Başlık satırı varmış bir sonrakinden başlıyoruz..
Table1.DisableControls;
for iSayac := iBas to xiSatir do
begin
ProgressBar1.Position := iSayac;
Table1.Insert;
if ComboBox2 .ItemIndex > 0 then
Table1.FieldByName('TC_Kimlik_No').AsString := xExcel.Cells[ iSayac, ComboBox2 .ItemIndex];
if ComboBox3 .ItemIndex > 0 then
Table1.FieldByName('Adi').AsString := xExcel.Cells[ iSayac, ComboBox3 .ItemIndex];
if ComboBox4 .ItemIndex > 0 then
Table1.FieldByName('Soyadi').AsString := xExcel.Cells[ iSayac, ComboBox4 .ItemIndex];
if ComboBox5 .ItemIndex > 0 then
Table1.FieldByName('Dogum_Tarihi').AsString := xExcel.Cells[ iSayac, ComboBox5 .ItemIndex];
if ComboBox6 .ItemIndex > 0 then
Table1.FieldByName('Cinsiyeti').AsString := xExcel.Cells[ iSayac, ComboBox6 .ItemIndex];
if ComboBox7 .ItemIndex > 0 then
Table1.FieldByName('Ana_Adi').AsString := xExcel.Cells[ iSayac, ComboBox7 .ItemIndex];
if ComboBox8 .ItemIndex > 0 then
Table1.FieldByName('Baba_Adi').AsString := xExcel.Cells[ iSayac, ComboBox8 .ItemIndex];
if ComboBox9 .ItemIndex > 0 then
Table1.FieldByName('Dogum_Yeri').AsString := xExcel.Cells[ iSayac, ComboBox9 .ItemIndex];
if ComboBox10 .ItemIndex > 0 then
Table1.FieldByName('Medeni_Hali').AsString := xExcel.Cells[ iSayac, ComboBox10.ItemIndex];
if ComboBox11 .ItemIndex > 0 then
Table1.FieldByName('E-Posta').AsString := xExcel.Cells[ iSayac, ComboBox11.ItemIndex];
if ComboBox12 .ItemIndex > 0 then
Table1.FieldByName('Kan_Grubu').AsString := xExcel.Cells[ iSayac, ComboBox12.ItemIndex];
if ComboBox13 .ItemIndex > 0 then
Table1.FieldByName('Telefonu').AsString := xExcel.Cells[ iSayac, ComboBox13.ItemIndex];
Table1.Post;
Application.ProcessMessages;
end;
Table1.EnableControls;
Table1.First;
end;
procedure TForm1.BitBtn4Click(Sender: TObject);
begin
With TQuery.Create(nil) do
begin
DatabaseName := Table1.DatabaseName;
SQL.Text := 'DELETE FROM KAYITLAR';
ExecSQL;
Free;
end;
Table1.Close;
Table1.Open;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if ComboBox1.Items.Count > 1 then
begin
xExcel.WorkBooks.Close;
xExcel := Unassigned;
end;
end;
@SimaWB haklı bir eleştiri yapmış, katılıyorum. Bu başlığı illa ki görecek öğrenciler olacaktır, tekrar altını çiziyorum. Bu ilk ve sondur. Proje son günü geldi vs. gerekçeler ile gelecekler, bunu altenatif olarak sunsunlar ama diğer türlü özel mesaj ile de gelinmesin lütfen. Direkt site adminine bildirilecektir.SimaWB yazdı:Hocanızın eposta adresini de verin, programı yazan arkadaş direk oraya mail atsın, size zahmet olmasın![]()
![]()
EK : Biraz önce olması gerektiği şekilde düzelttim, önceki mesajım ekinden yeniden indirebilirsiniz. Kaynak kodların açık halini de CODE tag içinde belirttim. Başlığı okuyanlar indirmeden de inceleyebilirsiniz.@mrmarman yazdı:Kodu değiştiriyorum. Amacı yanlış anlamışım... Düzeltiyorum....![]()