Einzelnen Beitrag anzeigen

Whookie

Registriert seit: 3. Mai 2006
Ort: Graz
441 Beiträge
 
Delphi 10.3 Rio
 
#19

AW: Deutsche Dezimal-Zahl in englisches Format bringen

  Alt 16. Jan 2018, 16:55
Das Problem liegt darin, das die SaveToCSV Funktion nicht wirklich "weiß" welche Daten in den Zellen stehen und sie daher einfach so abspeichert wie sie (in Stringform) eben vorliegen.

Wenn das Grid wie folgt befüllt wird (stark vereinfacht, statt FillAdvGrid):

Delphi-Quellcode:
procedure DemoFill;
var
  iy: Integer;
  ix: Integer;
  LFmt: TFormatSettings;
begin
  LFmt := TFormatSettings.Create;
  LFmt.DecimalSeparator := '.';
  for iy := 0 to AGd.RowCount-1 do
  begin
    for ix := 0 to AGd.ColCount-1 do
    begin
      AGd.Cells[ix,iy] := Format('%.6f', [ Random], LFmt);
    end;
  end;
end;
Dann kann man den Inhalt entsprechend abspeichern:

Delphi-Quellcode:
  AGd.Delimiter := ',';
// AGd.QuoteEmptyCells := FALSE; // leere Zellen nicht quoten
  AGd.SaveToCSV('D:\test.csv');

Nachteil, auch die Darstellung am Bildschirm ist dann in diesem Format.
Whookie

Software isn't released ... it is allowed to escape!
  Mit Zitat antworten Zitat