From f3c66179a3f7806d39cba89172017a549f36b6d0 Mon Sep 17 00:00:00 2001 From: vvzh Date: Sat, 25 Oct 2014 08:54:33 +0000 Subject: [PATCH] fixed TrimEmptyCells removing empty cells in the middle of a row (patch from Reinier Olislagers) git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3688 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/csvdocument/csvdocument.pas | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/csvdocument/csvdocument.pas b/components/csvdocument/csvdocument.pas index 5c7bd35c0..72cbbb839 100644 --- a/components/csvdocument/csvdocument.pas +++ b/components/csvdocument/csvdocument.pas @@ -720,8 +720,14 @@ var begin MaxCol := FCells.Count - 1; for I := MaxCol downto 0 do - if (TCSVCell(FCells[I]).Value = '') and (FCells.Count > 1) then - FCells.Delete(I); + begin + if (TCSVCell(FCells[I]).Value = '') then + begin + if (FCells.Count > 1) then + FCells.Delete(I); + end else + break; // We hit the first non-empty cell so stop + end; end; procedure TCSVRow.SetValuesLineEnding(const ALineEnding: String);