Autor Beitrag
MasterEvil
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76


D7 Prof
BeitragVerfasst: Mo 06.03.06 15:17 
Hallo,

hab ein kleines Problem mit Excel 2003 und Ole.

Und zwar haben wir schon seit langem eine Funktion um eine Tabelle nach Excel zu exportieren.
In dieser Tabelle stehen Zahlenwerte (Float) drin, die wir beim Export Formatiert ausgeben.

Dies geschieht so:
ausblenden Delphi-Quelltext
1:
Excel.WorkSheet.Range[Range].NumberFormat:='#.###.##0,00'					


Dies funktioniert in allen alten Excel Versionen wunderbar.
Excel 2003 macht allerdings ein paar Probleme:
Die Werte stehen zwar richtig formatiert in der Excel-Tabelle, werden aber als "Fehlerhaft" Markiert - er meckert das die Felder als Texteigenschaft (Format - Zellen - Kategorie: Standard) gekennzeichnet sind und nicht als Zahl.
Das schlimme dadran ist, dass man mit den Felder nicht rechnen kann (z.B. die automatische Summenfunktion), sondern erst in jedes Feld reingehen muss oder die Zelle zur Zahl umbaut.

Jemand eine Idee? Hab auch schon mehrere andere NumberFormat's ausprobiert:
ausblenden Delphi-Quelltext
1:
2:
Excel.WorkSheet.Range[Range].NumberFormat:='€#,##0.00_);[Red](€#,##0.00)';
Excel.WorkSheet.Range[Range].NumberFormat:='#.##0,00 €';


greetz
Steffen
MasterEvil Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76


D7 Prof
BeitragVerfasst: Di 07.03.06 12:11 
Falls es jemanden Interessiert:
Hab eine Lösung gefunden.
Man muss, damit Excel 2003 es als Zahl erkennt, das Forumla Feld füllen.
Also entweder mit Formula:=Zahl oder mit einem VarArray anhand von FormulaArray:=DataArray;

greetz
Steffen
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Do 09.11.06 10:01 
Hallo,

merkwürdigerweise funktioniert es bei mir aber auch so in Excel 2003 (SP2). Der einzige Unterschied ist, daß ich das Numberformat explizit der Zelle zuweise:

ausblenden Delphi-Quelltext
1:
WorkSheet.Cells.Item[Row,Col+1].NumberFormat:='#.###.##0,00';					


Cu,
Udontknow
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 09.11.06 10:27 
Moin!

Ich mag mich irren, aber mußte man in Formatstrings Literale nicht quoten? (konkret das Euro-Zeichen) :gruebel:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.