Home > Back-end >  Delphi 7 works why transplanted into 10 data cannot be imported into the Delphi stringgrid
Delphi 7 works why transplanted into 10 data cannot be imported into the Delphi stringgrid

Time:11-06

 procedure CsvToGrid (Grid: TStringGrid); 
Var
CsvData: TStringList;
RowData: String;
ARow, ACol: Integer;
CommaPos: Integer;
The begin
CsvData:=TStringList. Create;
Try
CsvData. LoadFromFile (' shuju \ test CSV);
Form1. Grid1. RowCount:=csvdata. Count + 1;
Form1. Edit1. Text:=inttostr (csvdata. Count);
For ARow:=0 to CsvData. Do the Count - 1
The begin
ACol:=0;
RowData:=CsvData. ValueFromIndex [ARow];

CommaPos:=Pos (', 'RowData);
While (CommaPos> 0) do
The begin
The Grid. Cells [ARow ACol + 1, + 1] :=Copy (RowData, 1, CommaPos - 1);
RowData:=Copy (RowData, CommaPos + 1, Length (RowData) - CommaPos);
CommaPos:=Pos (', 'RowData);
ACol:=ACol + 1;
end;
end;
The finally
CsvData. Free;
end;

end;
  • Related