Registriert seit: 6. Sep 2023
5 Beiträge
|
Copy / Paste Anfrage
10. Jul 2025, 11:24
Dear Friends,
ich muss mit Rechtsklick aus einer PDF Datei 3 Zeilen Text koieren und in Stringgrid eifügen. Bovor ich einfüge es muss jeweils am Zeilenende ein Leerzeichen eingefügt werden. Wie kann ich es erledigen ?
Text Format ist wie folgt:
1111 11111 1111 111111 1111 11111
2222 22222 222 22222 2222 222
3333 333 3333 333333 3333 33333
Mein Code lautet:
procedure TfrmMain.BTN_InsertClick(Sender: TObject);
var
WordCount: Integer;
WordStart: Integer;
S: String;
I: Integer;
begin
//
WordCount := 0;
WordStart := 1;
S := Clipboard.AsText + ' ';
s := s.Replace(',', '', [rfReplaceAll, rfIgnoreCase]);
s := s.Replace('.', ',', [rfReplaceAll, rfIgnoreCase]);
for I := 1 to Length(S) do
if S[I] = ' ' then
begin
if WordStart <> I then
begin
StringGrid1.Cells[WordCount mod StringGrid1.ColCount, WordCount div StringGrid1.ColCount] :=
Copy(S, WordStart, I - WordStart);
Inc(WordCount);
end;
WordStart := I + 1;
end;
StringGrid1.RowCount := ((WordCount - 1) div StringGrid1.ColCount) + 1;
dbedit10.text := StringGrid1.Cells[0, 0];
dbedit11.text := StringGrid1.Cells[1, 0];
dbedit12.text := StringGrid1.Cells[2, 0];
dbedit13.text := StringGrid1.Cells[3, 0];
dbedit14.text := StringGrid1.Cells[4, 0];
dbedit15.text := StringGrid1.Cells[5, 0];
dbedit16.text := StringGrid1.Cells[0, 1];
dbedit17.text := StringGrid1.Cells[1, 1];
dbedit18.text := StringGrid1.Cells[2, 1];
dbedit19.text := StringGrid1.Cells[3, 1];
dbedit20.text := StringGrid1.Cells[4, 1];
dbedit21.text := StringGrid1.Cells[5, 1];
dbedit22.text := StringGrid1.Cells[0, 2];
dbedit23.text := StringGrid1.Cells[1, 2];
dbedit24.text := StringGrid1.Cells[2, 2];
dbedit25.text := StringGrid1.Cells[3, 2];
dbedit26.text := StringGrid1.Cells[4, 2];
dbedit27.text := StringGrid1.Cells[5, 2];
end;
Vielen Dank !
|