fpspreadsheet: Ignore content detection when a cell is formatted as text (nfText).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7063 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2019-07-20 20:54:26 +00:00
parent fa6e9d2f0d
commit 42926f53d3

View File

@ -5254,23 +5254,44 @@ begin
DeleteFormula(ACell);
// Empty cell
if AValue = '' then
begin
WriteText(ACell, '');
exit;
end;
{
// Force text format by putting an apostrophe at the text beginning
if AValue[1] = '''' then
begin
Delete(AValue, 1, 1);
WriteNumberFormat(ACell, nfText);
end;
}
// Typing an apostrophe in front of the text bypasses format detection and
// takes the text literally.
if AValue[1] = '''' then begin
WriteText(ACell, Copy(AValue, 2, MaxInt));
exit;
end;
// Cell format
fmtIndex := GetEffectiveCellFormatIndex(ACell);
fmt := Workbook.GetCellFormat(fmtIndex);
numFmtParams := Workbook.GetNumberFormat(fmt.NumberFormatIndex);
ACell^.FormatIndex := fmtIndex;
// Handle some cases first in which content autodetection is not wanted.
if not (soAutoDetectCellType in FOptions) then begin
// Write text content if the cell has number format nfText
if IsTextFormat(numFmtParams) then begin
WriteText(ACell, AValue);
exit;
end;
end;
isPercent := Pos('%', AValue) = Length(AValue);
if isPercent then Delete(AValue, Length(AValue), 1);