From 7416450bf4a525198323c7b28bf3bdca9d96077a Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Fri, 4 May 2018 07:43:48 +0000 Subject: [PATCH] fpspreadsheet: Avoid creating a blank cell if the row/col indexes passed to Worksheet.ReadAsText(row, col) are those of a non-existing cell (see https://forum.lazarus.freepascal.org/index.php/topic,41132.msg284876.html). git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6377 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/fpspreadsheet/source/common/fpspreadsheet.pas | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/fpspreadsheet/source/common/fpspreadsheet.pas b/components/fpspreadsheet/source/common/fpspreadsheet.pas index abe9fc6f7..4ce521a2d 100644 --- a/components/fpspreadsheet/source/common/fpspreadsheet.pas +++ b/components/fpspreadsheet/source/common/fpspreadsheet.pas @@ -2792,13 +2792,18 @@ end; @return The text representation of the cell -------------------------------------------------------------------------------} function TsWorksheet.ReadAsText(ARow, ACol: Cardinal): string; +var + cell: PCell; begin - Result := ReadAsText(GetCell(ARow, ACol)); + cell := FindCell(ARow, ACol); + if cell <> nil then Result := ReadAsText(cell) else Result := ''; + { avoid creating a blenk cell if the cell does not exist + Result := ReadAsText(GetCell(ARow, ACol)); } end; function TsWorksheet.ReadAsUTF8Text(ARow, ACol: Cardinal): string; begin - Result := ReadAsText(GetCell(ARow, ACol)); + Result := ReadAsText(ARow, ACol); end; {@@ ----------------------------------------------------------------------------