Konuyu Oyla:
  • Derecelendirme: 4/5 - 1 oy
  • 1
  • 2
  • 3
  • 4
  • 5
DBGrid1 den Excel Veri Gönderme
#1
Arkadaşlar Merhaba; Bir konuda yardımınıza ihtiyacım var İnşallah bana yardımcı olursunuz. Sorum şu;

Formum var ve bu formda DBGrid1 e iki türlü veri çekiyorum bir normal iki Kümüle edilmiş. Normalde birinci aldığım rapor Excel e düzgün gidiyor hiçbir soru yok fakat CheckBox1 işaretlediğimde "Kümüle Rapor" için sadece DBGrid1 de iki alan yok adres ve telefon onları False ederek saklıyorum bu şekilde Excel e gönderdiğimde de hata alıyorum. Kod şu şekilde;

procedure TForm19.BitBtn2Click(Sender: TObject);
var ExcelApp, WBook, Excel, Sheet: OleVariant;
   Row, Col: Integer; // satır ve sütün için değişken
begin
 if BaBsRapor.IsEmpty then Exit;
 try
   Excel:='E';
   ExcelApp := CreateOleObject('Excel.Application');
   WBook := ExcelApp.WorkBooks.Add;
   Sheet := WBook.WorkSheets[1];
   Sheet.Range['A1', 'M1'].Merge;
   Sheet.Range['A1','M1'].Font.Bold:=True;
   Sheet.Range['A1','M1'].Font.Color:=clRed;
   Sheet.Cells[1,1].Value:='Netsis B Raporu' + '                             ' + ComboBox1.Text;
   Sheet.Cells[1,1].HorizontalAlignment := -4108;
   Sheet.Cells[1,1].Font.Size := 20;
   Sheet.Cells[2,1].Value:='AY';
   Sheet.Cells[2,2].Value:='Fatura Sayısı';
   Sheet.Cells[2,3].Value:='Cari İsim';
   Sheet.Cells[2,4].Value:='Cari Adres';   //// BU alan Kümüle ettiğimde gözükmüyor
   Sheet.Cells[2,5].Value:='Cari Tel';     //// BU alan Kümüle ettiğimde gözükmüyor
   Sheet.Cells[2,6].Value:='Vergi Dairesi';
   Sheet.Cells[2,7].Value:='Vergi Numarası';
   Sheet.Cells[2,8].Value:='TC Kimlik No';
   Sheet.Cells[2,9].Value:='Toplam Tutar';
   Sheet.Range['A2','M2'].Font.Bold:=True;
   Sheet.Range['A2','M2'].Font.Color:=clRed;
  except
   ShowMessage('Excel başlatılamıyor.'); Exit;
 end;
 try
 with BaBsRapor do                  //// Hata bur da veriyor
 begin
    Row := 3; // başlangıç 3. satır
    First;
    While not Eof do
    begin
      for Col := 0 to DBGrid1.FieldCount - 1 do
      begin
        Sheet.Cells[Row, Col + 1].Value := DBGrid1.Fields[Col].Value;
if Col + 1 >= 4 then
 begin
   case DBGrid1.Fields[Col].DataType of
     ftInteger, ftFloat:
     begin
       Sheet.Cells[Row, Col + 1].Value := DBGrid1.Fields[Col].AsFloat;
       Sheet.Cells[Row, Col + 1].NumberFormat := '#,###0.0000';
     end;
     else
     begin
       Sheet.Cells[Row, Col + 1].Value := DBGrid1.Fields[Col].Value;
     end;
   end;
 end;
end;
      Next;
      Inc(Row); // Row := Row + 1;
    end;
    Sheet.Cells[Row, 9].Formula := '=SUM(I3:I' + InttoStr(Row - 1) + ')';
    Sheet.Range['A' + InttoStr(Row), 'J' + InttoStr(Row)].Font.Color := 255;
    Sheet.Range['A' + InttoStr(Row), 'J' + InttoStr(Row)].Font.Bold := True;
 end;
 finally
   Sheet.Columns['A:L'].EntireColumn.AutoFit;
   ExcelApp.Visible := True;
   ExcelApp := Null; WBook := Null; Sheet := Null;
 end;
end;



Hata:
---------------------------
Debugger Exception Notification
---------------------------
Project MENU.exe raised exception class EAccessViolation with message 'Access violation at address 004F3BD7 in module ' MENU.exe'. Read of address 00000000'. Process stopped. Use Step or Run to continue.
---------------------------
OK   Help  
---------------------------
Cevapla


Konu ile Alakalı Benzer Konular
Konular Yazar Yorumlar Okunma Son Yorum
  Logo Go3 de döviz tablosunda Date_ alanına veri yazma cinarbil 3 48 3 saat önce
Son Yorum: hi_selamlar
  IEC 61850 Potokolünden veri alma shooterman 1 443 14-03-2024, Saat: 11:38
Son Yorum: shooterman
  Veri Tabanına Kontrollü Kayıt Yaptırma bünyamin68 15 794 08-03-2024, Saat: 00:06
Son Yorum: TuncayDelphi
  Problem - ZKTeco Cihazlardan Anlık Veri Alma mad85 16 8.153 25-12-2023, Saat: 11:35
Son Yorum: osiso
  Cas Terazi Veri gönderimi Delphi sürüm sorunu KUNTAY 12 4.418 08-11-2023, Saat: 00:06
Son Yorum: berkan



Konuyu Okuyanlar: 1 Ziyaretçi