13-07-2019, Saat: 14:03
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;
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
---------------------------
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
---------------------------