Resmi Fatura No
792953.000
böyle olmasını istiyorum ama yapamadım ;
792953000
Yardımcı olur musunuz ?
Kod: Tümünü seç
procedure TForm12.BitBtn2Click(Sender: TObject);
var ExcelApp, WBook, Sheet: OleVariant;
Row, Col: Integer; // satır ve sütün için değişken
begin
// if DBGrid1.DataSource.DataSet.IsEmpty then Exit;
if NRapor1.IsEmpty then Exit; // ikiside aynı şey tmm
try
ExcelApp := CreateOleObject('Excel.Application');
WBook := ExcelApp.WorkBooks.Add;
Sheet := WBook.WorkSheets[1];
Sheet.Range['A1', 'K1'].Merge;
Sheet.Range['A1','K1'].Font.Bold:=True;
Sheet.Range['A1','K1'].Font.Color:=clRed;
Sheet.Cells[1,1].Value:='Netsis Ayrıntılı K.D.V. İcman Raporu';
Sheet.Cells[1,1].HorizontalAlignment := -4108;
Sheet.Cells[1,1].Font.Size := 20;
Sheet.Cells[2,1].Value:='Fatura No';
Sheet.Cells[2,2].Value:='Tarih';
Sheet.Cells[2,3].Value:='Cari İsim';
Sheet.Cells[2,4].Value:='Brüt Tutar';
Sheet.Cells[2,5].Value:='Satır İskontorsu';
Sheet.Cells[2,6].Value:='Genel İskonto';
Sheet.Cells[2,7].Value:='% 1 K.D.V.';
Sheet.Cells[2,8].Value:='% 8 K.D.V.';
Sheet.Cells[2,9].Value:='% 18 K.D.V.';
Sheet.Cells[2,10].Value:='Genel Toplam';
Sheet.Cells[2,11].Value:='Resmi Fatura No';
Sheet.Range['A2','K2'].Font.Bold:=True;
Sheet.Range['A2','K2'].Font.Color:=clRed;
except
ShowMessage('Excel başlatılamıyor.'); Exit;
end;
try
with NRapor1 do
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
Sheet.Cells[Row, Col + 1].NumberFormat := '#.##0,00';
end;
Next;
Inc(Row); // Row := Row + 1;
end;
Sheet.Cells[Row, 4].Formula := '=SUM(D3:D' + InttoStr(Row - 1) + ')';
Sheet.Cells[Row, 5].Formula := '=SUM(E3:E' + InttoStr(Row - 1) + ')';
Sheet.Cells[Row, 6].Formula := '=SUM(F3:F' + InttoStr(Row - 1) + ')';
Sheet.Cells[Row, 7].Formula := '=SUM(G3:G' + InttoStr(Row - 1) + ')';
Sheet.Cells[Row, 8].Formula := '=SUM(H3:H' + InttoStr(Row - 1) + ')';
Sheet.Cells[Row, 9].Formula := '=SUM(I3:I' + InttoStr(Row - 1) + ')';
Sheet.Cells[Row,10].Formula := '=SUM(J3:J' + 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:J'].EntireColumn.AutoFit;
ExcelApp.Visible := True;
ExcelApp := Null; WBook := Null; Sheet := Null;
end;
end;