fpspreadsheet: Fix reading of numbers formatted as text (@). See http://www.pilotlogic.com/sitejoom/index.php/forum/pl-fpspreadsheet/3656-pl-fpspreadsheet-wrong-reading-libre-office-calc-file
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5243 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
85187e4927
commit
4df9e5dc9b
@ -827,6 +827,15 @@ begin
|
|||||||
|
|
||||||
el := 0;
|
el := 0;
|
||||||
while (el < numEl) do begin
|
while (el < numEl) do begin
|
||||||
|
{
|
||||||
|
if section.Elements[el].Token = nftTextFormat then
|
||||||
|
begin
|
||||||
|
s := FloatToStrF(AValue, ffGeneral, 20, 20, fs);
|
||||||
|
if (sidx=0) and isNeg then s := '-' + s;
|
||||||
|
Result := Result + s;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
}
|
||||||
if section.Elements[el].Token = nftGeneral then
|
if section.Elements[el].Token = nftGeneral then
|
||||||
begin
|
begin
|
||||||
s := FloatToStrF(AValue, ffGeneral, 20, 20, fs);
|
s := FloatToStrF(AValue, ffGeneral, 20, 20, fs);
|
||||||
|
@ -2598,6 +2598,7 @@ var
|
|||||||
cell: PCell;
|
cell: PCell;
|
||||||
fmt: PsCellFormat;
|
fmt: PsCellFormat;
|
||||||
numFmt: TsNumFormatParams;
|
numFmt: TsNumFormatParams;
|
||||||
|
txtNode: TDOMNode;
|
||||||
begin
|
begin
|
||||||
if FIsVirtualMode then
|
if FIsVirtualMode then
|
||||||
begin
|
begin
|
||||||
@ -2637,6 +2638,12 @@ begin
|
|||||||
dmODS1900: cell^.DateTimeValue := cell^.NumberValue + DATEMODE_1900_BASE;
|
dmODS1900: cell^.DateTimeValue := cell^.NumberValue + DATEMODE_1900_BASE;
|
||||||
dmODS1904: cell^.DateTimeValue := cell^.NumberValue + DATEMODE_1904_BASE;
|
dmODS1904: cell^.DateTimeValue := cell^.NumberValue + DATEMODE_1904_BASE;
|
||||||
end;
|
end;
|
||||||
|
end else
|
||||||
|
if IsTextFormat(numFmt) then begin
|
||||||
|
// Cell has TEXT format @ --> store number as text
|
||||||
|
txtNode := ACellNode.FirstChild;
|
||||||
|
if txtNode.NodeName = 'text:p' then
|
||||||
|
FWorksheet.WriteText(cell, GetNodeValue(txtNode));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if FIsVirtualMode then
|
if FIsVirtualMode then
|
||||||
|
@ -1791,6 +1791,8 @@ begin
|
|||||||
ExtractNumberFormat(XF, nf, nfs);
|
ExtractNumberFormat(XF, nf, nfs);
|
||||||
if IsDateTime(lNumber, nf, nfs, lDateTime) then
|
if IsDateTime(lNumber, nf, nfs, lDateTime) then
|
||||||
FWorksheet.WriteDateTime(cell, lDateTime, nf, nfs)
|
FWorksheet.WriteDateTime(cell, lDateTime, nf, nfs)
|
||||||
|
else if nf=nfText then
|
||||||
|
FWorksheet.WriteText(cell, FloatToStrF(lNumber, ffGeneral, 20,20, FWorkbook.FormatSettings))
|
||||||
else
|
else
|
||||||
FWorksheet.WriteNumber(cell, lNumber, nf, nfs);
|
FWorksheet.WriteNumber(cell, lNumber, nf, nfs);
|
||||||
ApplyCellFormatting(cell, XF);
|
ApplyCellFormatting(cell, XF);
|
||||||
@ -1843,6 +1845,8 @@ begin
|
|||||||
|
|
||||||
if IsDateTime(value, nf, nfs, dt) then
|
if IsDateTime(value, nf, nfs, dt) then
|
||||||
FWorksheet.WriteDateTime(cell, dt, nf, nfs)
|
FWorksheet.WriteDateTime(cell, dt, nf, nfs)
|
||||||
|
else if nf = nfText then
|
||||||
|
FWorksheet.WriteText(cell, FloatToStrF(value, ffGeneral, 20, 20, FWorkbook.FormatSettings))
|
||||||
else
|
else
|
||||||
FWorksheet.WriteNumber(cell, value, nf, nfs);
|
FWorksheet.WriteNumber(cell, value, nf, nfs);
|
||||||
|
|
||||||
@ -2054,6 +2058,8 @@ begin
|
|||||||
ExtractNumberFormat(XF, nf, nfs);
|
ExtractNumberFormat(XF, nf, nfs);
|
||||||
if IsDateTime(Number, nf, nfs, lDateTime) then
|
if IsDateTime(Number, nf, nfs, lDateTime) then
|
||||||
FWorksheet.WriteDateTime(cell, lDateTime, nf, nfs)
|
FWorksheet.WriteDateTime(cell, lDateTime, nf, nfs)
|
||||||
|
else if nf=nfText then
|
||||||
|
FWorksheet.WriteText(cell, FloatToStrF(Number, ffGeneral, 20,20, FWorkbook.FormatSettings))
|
||||||
else
|
else
|
||||||
FWorksheet.WriteNumber(cell, Number, nf, nfs);
|
FWorksheet.WriteNumber(cell, Number, nf, nfs);
|
||||||
|
|
||||||
|
@ -691,6 +691,8 @@ begin
|
|||||||
number := ConvertExcelDateTimeToDateTime(number, FDateMode);
|
number := ConvertExcelDateTimeToDateTime(number, FDateMode);
|
||||||
AWorksheet.WriteDateTime(cell, number);
|
AWorksheet.WriteDateTime(cell, number);
|
||||||
end
|
end
|
||||||
|
else if IsTextFormat(numFmt) then
|
||||||
|
AWorksheet.WriteText(cell, dataStr)
|
||||||
else
|
else
|
||||||
AWorksheet.WriteNumber(cell, number);
|
AWorksheet.WriteNumber(cell, number);
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user