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);
|
||||
var
|
||||
lValue: String;
|
||||
n: Integer;
|
||||
p, n: Integer;
|
||||
begin
|
||||
lValue := lowercase(AValue);
|
||||
// date/time format for interval
|
||||
@ -262,9 +262,16 @@ begin
|
||||
if not TryStrToFloat(trim(lValue), FSections[FCurrSection].CompareValue) then
|
||||
FStatus := psErrNoValidCompareNumber;
|
||||
end else
|
||||
// Locale information
|
||||
// Currency information
|
||||
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
|
||||
FStatus := psErrUnknownInfoInBrackets;
|
||||
end;
|
||||
@ -749,8 +756,22 @@ begin
|
||||
end;
|
||||
'0', '#', '.', ',', '-':
|
||||
ScanNumber;
|
||||
'y', 'Y', 'm', 'M', 'd', 'D', 'h', 'N', 'n', 's', '[':
|
||||
'y', 'Y', 'm', 'M', 'd', 'D', 'h', 'N', 'n', 's':
|
||||
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);
|
||||
';':
|
||||
|
@ -65,7 +65,6 @@ uses
|
||||
type
|
||||
|
||||
{ TsSpreadBIFF8Reader }
|
||||
|
||||
TsSpreadBIFF8Reader = class(TsSpreadBIFFReader)
|
||||
private
|
||||
PendingRecordSize: SizeInt;
|
||||
@ -1995,7 +1994,7 @@ begin
|
||||
fmtIndex := WordLEtoN(AStream.ReadWord);
|
||||
|
||||
// 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
|
||||
NumFormatList.AnalyzeAndAdd(fmtIndex, fmtString);
|
||||
|
@ -713,7 +713,7 @@ procedure TsBIFFNumFormatList.AddBuiltinFormats;
|
||||
var
|
||||
cs: String;
|
||||
begin
|
||||
cs := Workbook.FormatSettings.CurrencyString;
|
||||
cs := AnsiToUTF8(Workbook.FormatSettings.CurrencyString);
|
||||
|
||||
AddFormat( 0, '', nfGeneral);
|
||||
AddFormat( 1, '0', nfFixed, 0);
|
||||
@ -1214,7 +1214,7 @@ begin
|
||||
if IsDateTime(value, nf, dt) then
|
||||
FWorksheet.WriteDateTime(ARow, ACol, dt) //, nf, nfs)
|
||||
else
|
||||
if nf <> nfCustom then
|
||||
//if nf <> nfCustom then // why was this here?
|
||||
FWorksheet.WriteNumber(ARow, ACol, value, nf, nd, ncs);
|
||||
FWorksheet.WriteNumberFormat(ARow, ACol, nf, nfs); // override built-in format string
|
||||
|
||||
|
Reference in New Issue
Block a user