Autor Beitrag
Lucky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 84

XP
Delphi 7
BeitragVerfasst: Di 04.03.08 17:41 
hi,
so jetzt bin ich schon wieder hier8) hab ein neues problem u. zwar übertrage ich dateien ans excel u. da MUSS in der 3. spalte "FALSE" drinnen stehen...aber excel macht mir immer aus meinem false ein falsch.... habt ihr ne idee?? (achja mein quellcode)8)
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
rocedure tform1.excel_fuellen;
var excel : variant;
    z : integer;
    format : OleVariant;
    zeichen : string;
begin
  excel := CreateOleObject('Excel.Application');
  excel.Application.sheetsinnewworkbook := 1;
  excel.workbooks.add;
  excel.sheets.add;
  excel.sheets[1].Name := 'Sheet1';
  excel.sheets['Sheet1'];
  excel.sheets['Sheet1'].cells[1,1].value := 'Kunden_USt-IdNr.';
  excel.sheets['Sheet1'].cells[1,2].value := 'Betrag';
  excel.sheets['Sheet1'].cells[1,3].value := 'Dreiecksgeschäft';
  excel.range['A1:C1'].select;
  excel.selection.font.bold := true;

  ADODataSet1.Recordset := ADOConnection1.Execute('Select * from bheuro.zmfiamt');
  ADODataSet1.Recordset.MoveFirst;
  zeichen := 'false';

  for z := 1 to ADODataSet1.RecordCount do begin
    excel.sheets['Sheet1'].cells[z+2,1].value := VarToStr(ADODataSet1.Recordset.Collect[0]);
    excel.sheets['Sheet1'].cells[z+2,2].value := VarToStr(ADODataSet1.Recordset.Collect[1]);
    excel.sheets['Sheet1'].cells[z+2,3].value := zeichen;
    excel.range['A1:C'+inttostr(z+2)].select;
    excel.selection.columns.autofit;
    ADODataSet1.Recordset.MoveNext;
  end;

  excel.activeworkbook.saveas('c:\ZM.xls');
 //excel.visible := true;
  excel.quit;
  excel := Unassigned;

end;
Agawain
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 460

win xp
D5, MySQL, devxpress
BeitragVerfasst: Di 04.03.08 17:51 
hi

versuch mal die betreffende Spalte explizit als Text zu formatieren.
Das sollte eigentlich funktionieren.
Was mich wundert, dass Excel hier FALSCH einsetzt, denn ansich ist FALSCH entweder
ein Rückgabewert einer Funktion, oder ein Parameter.

Das Problem läßt sich auch im Exceldialog von mir nicht reproduzieren.

Aber man sollte sich bei Excel sowieso nicht über allzu viel wundern

_________________
Gruß Aga
JoelH
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 806
Erhaltene Danke: 17

Win10
Delphi Alexandria 11.2 Patch 1
BeitragVerfasst: Di 04.03.08 18:36 
du könnstest auch einfach versuchen ein ' voran zu hängen, das hilft zumindest bei zahlen. Ansonsten ist der Tip von Agawain gut, einfach explizit der Zelle ein Format zuornen, ansonsten mach Excel für gewöhnlich dass was es leider am besten kann, nämlich was es will :(

_________________
mfg. Joel
Lucky Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 84

XP
Delphi 7
BeitragVerfasst: Mi 05.03.08 10:48 
ahh, jetzt klappts hab die spalte als txt formatiert8) thanks!!!