Burada her bir hücreye 3,4 veya 10 vs. gibi sayısal değerler gönderdiğimde
excelde bu hücreler hesaplanabilir integer değerler olarak oluşmuyor.İlgili her bir hücreye excelde tıklanıp yanında beliren sarı ikona tıklamak ve "Sayıya Dönüştür" denilmesi gerekiyor.
Aşağıdaki kod bloğunu kullanark integer değerleri hesaplanabilir şekilde excele göndermenin yolu nedir.Ya da koda nasıl bir ilave yapmak gerekiyor.
İlgili kolon 4. numaralı kolon ve if col=4 then sheet.Cells[row, col].NumberFormat:='0,000'; şeklinde göndremelerde işer yaramıyor.
Yardımlarınız için şimdiden teşekkürler
Kod: Tümünü seç
XApp := CreateOleObject('Excel.Application');
XApp.Visible := true;
XApp.WorkBooks.Add(-4167);
XApp.WorkBooks[1].WorkSheets[1].Name := 'Sheet1';
sheet := XApp.WorkBooks[1].WorkSheets['Sheet1'];
dbKAynak := gridGorunum.DataController.DataSet;
for filName := 0 to dbKAynak.FieldCount - 1 do
begin
q := filName + 1;
sheet.Cells[1, q] := dbDenKolonAdBul(dbKAynak.fields[filName].FieldName);
end;
for r := 0 to dbKAynak.RecordCount - 1 do
begin
for c := 0 to dbKAynak.FieldCount - 1 do
begin
row := r + 2;
col := c + 1;
sheet.Cells[row, col] := dbKAynak.fields[c].AsString;
sheet.Cells[row, col].interior.Color := gorunumGunRengi(dbKAynak.fields[c].AsString);
end;
dbKAynak.Next;
end;
kayitSayisi := dbKAynak.RecordCount - 1;
if kayitSayisi = 0 then
exit;
XApp.WorkSheets['Sheet1'].Range['A1:AA1'].Font.Bold := true;
XApp.WorkSheets['Sheet1'].Range['A1:K1'].Borders.LineStyle := 13;
XApp.WorkSheets['Sheet1'].Range['A2:K' + inttostr(kayitSayisi - 1)]
.Borders.LineStyle := 1;
XApp.WorkSheets['Sheet1'].Columns[1].ColumnWidth := 25;
XApp.WorkSheets['Sheet1'].Columns[2].ColumnWidth := 7;
XApp.WorkSheets['Sheet1'].Columns[3].ColumnWidth := 19;
XApp.WorkSheets['Sheet1'].Columns[4].ColumnWidth := 10;
XApp.WorkSheets['Sheet1'].Columns[5].ColumnWidth := 10;
XApp.WorkSheets['Sheet1'].Columns[6].ColumnWidth := 10;
XApp.WorkSheets['Sheet1'].Columns[7].ColumnWidth := 10;
XApp.WorkSheets['Sheet1'].Columns[8].ColumnWidth := 10;
XApp.WorkSheets['Sheet1'].Columns[9].ColumnWidth := 10;
XApp.WorkSheets['Sheet1'].Columns[10].ColumnWidth := 10;
XApp.WorkSheets['Sheet1'].Columns[11].ColumnWidth := 10;