You've already forked lazarus-ccr
fpspreadsheet: Fix BIFF currency bug of previous commit. Fix UTF8 bug when reading currency symbol. No more errors in number test.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3143 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -192,7 +192,7 @@ end;
|
|||||||
procedure TsNumFormatParser.AnalyzeBracket(const AValue: String);
|
procedure TsNumFormatParser.AnalyzeBracket(const AValue: String);
|
||||||
var
|
var
|
||||||
lValue: String;
|
lValue: String;
|
||||||
n: Integer;
|
p, n: Integer;
|
||||||
begin
|
begin
|
||||||
lValue := lowercase(AValue);
|
lValue := lowercase(AValue);
|
||||||
// date/time format for interval
|
// date/time format for interval
|
||||||
@ -262,9 +262,16 @@ begin
|
|||||||
if not TryStrToFloat(trim(lValue), FSections[FCurrSection].CompareValue) then
|
if not TryStrToFloat(trim(lValue), FSections[FCurrSection].CompareValue) then
|
||||||
FStatus := psErrNoValidCompareNumber;
|
FStatus := psErrNoValidCompareNumber;
|
||||||
end else
|
end else
|
||||||
// Locale information
|
// Currency information
|
||||||
if lValue[1] = '$' then begin
|
if lValue[1] = '$' then begin
|
||||||
FSections[FCurrSection].CountryCode := Copy(AValue, 2, Length(AValue));
|
p := pos('-', AValue);
|
||||||
|
with FSections[FCurrSection] do begin
|
||||||
|
if p = 0 then
|
||||||
|
CurrencySymbol := Copy(AValue, 2, Length(AValue))
|
||||||
|
else
|
||||||
|
CurrencySymbol := Copy(AValue, 2, p-2);
|
||||||
|
FormatString := FormatString + CurrencySymbol;
|
||||||
|
end;
|
||||||
end else
|
end else
|
||||||
FStatus := psErrUnknownInfoInBrackets;
|
FStatus := psErrUnknownInfoInBrackets;
|
||||||
end;
|
end;
|
||||||
@ -749,8 +756,22 @@ begin
|
|||||||
end;
|
end;
|
||||||
'0', '#', '.', ',', '-':
|
'0', '#', '.', ',', '-':
|
||||||
ScanNumber;
|
ScanNumber;
|
||||||
'y', 'Y', 'm', 'M', 'd', 'D', 'h', 'N', 'n', 's', '[':
|
'y', 'Y', 'm', 'M', 'd', 'D', 'h', 'N', 'n', 's':
|
||||||
ScanDateTime;
|
ScanDateTime;
|
||||||
|
'[':
|
||||||
|
begin
|
||||||
|
inc(FCurrent);
|
||||||
|
if (FCurrent <= FEnd) then begin
|
||||||
|
token := FCurrent^;
|
||||||
|
if token in ['h', 'H', 'n', 'N', 's', 'S'] then
|
||||||
|
ScanDateTime
|
||||||
|
else
|
||||||
|
if token = '$' then begin
|
||||||
|
dec(FCurrent, 2);
|
||||||
|
done := true;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
' ':
|
' ':
|
||||||
AddChar(token);
|
AddChar(token);
|
||||||
';':
|
';':
|
||||||
|
@ -65,7 +65,6 @@ uses
|
|||||||
type
|
type
|
||||||
|
|
||||||
{ TsSpreadBIFF8Reader }
|
{ TsSpreadBIFF8Reader }
|
||||||
|
|
||||||
TsSpreadBIFF8Reader = class(TsSpreadBIFFReader)
|
TsSpreadBIFF8Reader = class(TsSpreadBIFFReader)
|
||||||
private
|
private
|
||||||
PendingRecordSize: SizeInt;
|
PendingRecordSize: SizeInt;
|
||||||
@ -1995,7 +1994,7 @@ begin
|
|||||||
fmtIndex := WordLEtoN(AStream.ReadWord);
|
fmtIndex := WordLEtoN(AStream.ReadWord);
|
||||||
|
|
||||||
// 2 var. Number format string (Unicode string, 16-bit string length, ➜2.5.3)
|
// 2 var. Number format string (Unicode string, 16-bit string length, ➜2.5.3)
|
||||||
fmtString := ReadWideString(AStream, False);
|
fmtString := UTF8Encode(ReadWideString(AStream, False));
|
||||||
|
|
||||||
// Analyze the format string and add format to the list
|
// Analyze the format string and add format to the list
|
||||||
NumFormatList.AnalyzeAndAdd(fmtIndex, fmtString);
|
NumFormatList.AnalyzeAndAdd(fmtIndex, fmtString);
|
||||||
|
@ -713,7 +713,7 @@ procedure TsBIFFNumFormatList.AddBuiltinFormats;
|
|||||||
var
|
var
|
||||||
cs: String;
|
cs: String;
|
||||||
begin
|
begin
|
||||||
cs := Workbook.FormatSettings.CurrencyString;
|
cs := AnsiToUTF8(Workbook.FormatSettings.CurrencyString);
|
||||||
|
|
||||||
AddFormat( 0, '', nfGeneral);
|
AddFormat( 0, '', nfGeneral);
|
||||||
AddFormat( 1, '0', nfFixed, 0);
|
AddFormat( 1, '0', nfFixed, 0);
|
||||||
@ -1214,7 +1214,7 @@ begin
|
|||||||
if IsDateTime(value, nf, dt) then
|
if IsDateTime(value, nf, dt) then
|
||||||
FWorksheet.WriteDateTime(ARow, ACol, dt) //, nf, nfs)
|
FWorksheet.WriteDateTime(ARow, ACol, dt) //, nf, nfs)
|
||||||
else
|
else
|
||||||
if nf <> nfCustom then
|
//if nf <> nfCustom then // why was this here?
|
||||||
FWorksheet.WriteNumber(ARow, ACol, value, nf, nd, ncs);
|
FWorksheet.WriteNumber(ARow, ACol, value, nf, nd, ncs);
|
||||||
FWorksheet.WriteNumberFormat(ARow, ACol, nf, nfs); // override built-in format string
|
FWorksheet.WriteNumberFormat(ARow, ACol, nf, nfs); // override built-in format string
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user