Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   StringGrid speichern (https://www.delphipraxis.net/189118-stringgrid-speichern.html)

strom 5. Mai 2016 20:53


StringGrid speichern
 
hallo,

habe das Problem, dass im Textfile ein Zeilenumbruch ausführt wird??? Warum???
Liegt es an CommaText?

Delphi-Quellcode:
procedure SaveStringGridToFile(StringGrid: TStringGrid; const FileName: String);
var
   F: TStringList;
   i: Integer;
begin
   F := TStringList.Create;
   try
     F.Add(IntToStr(StringGrid.RowCount));
     F.Add(IntToStr(StringGrid.ColCount));
     for i := 0 to (StringGrid.RowCount - 1) do
       F.Add(StringGrid.Rows[i].CommaText);
     F.SaveToFile('Test.dat');
   finally
     F.Free;
   end;
end;
wie bekomme ich die Hochkommas rausgefiltert?

Delphi-Quellcode:
procedure TForm1.GlobalExceptionHandler(Sender: TObject; E: Exception);
 var
  i: integer;
  s: String;
begin
 StringGrid2.RowCount := StringGrid2.RowCount + 1;
  for i := StringGrid2.RowCount - 1 downto StringGrid2.FixedRows + 1 do
   StringGrid2.Rows [i].Assign (StringGrid2.Rows [i - 1]);
   StringGrid2.Rows [StringGrid2.FixedRows].Clear;
   StringGrid2.Cells [1,1] := FormatDateTime ('dd.mm.yyyy', Now);
   StringGrid2.Cells [2,1] := FormatDateTime ('hh:nn:ss', Now);
   StringGrid2.Cells [3,1] := 'eGrid Server [Error]';

   s:= E.Message;
   s := StringReplace(s,'´','',[rfReplaceAll]);

   StringGrid2.Cells [4,1] := s;
end;

Luckie 5. Mai 2016 21:32

AW: StringGrid speichern
 
Zitat:

Zitat von strom (Beitrag 1337570)
habe das Problem, dass im Textfile ein Zeilenumbruch ausführt wird??? Warum???
Liegt es an CommaText?

Weil die Methode Add in die Stringliste immer eine neue Zeile anfügt?


Zitat:

wie bekomme ich die Hochkommas rausgefiltert?
StringReplace?


Alle Zeitangaben in WEZ +1. Es ist jetzt 20:06 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz