diff --git a/components/fpspreadsheet/fpsnumformatparser.pas b/components/fpspreadsheet/fpsnumformatparser.pas index b755fb94b..7363ddee4 100644 --- a/components/fpspreadsheet/fpsnumformatparser.pas +++ b/components/fpspreadsheet/fpsnumformatparser.pas @@ -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); ';': diff --git a/components/fpspreadsheet/xlsbiff8.pas b/components/fpspreadsheet/xlsbiff8.pas index 1fc4b4f01..c4e033d7b 100755 --- a/components/fpspreadsheet/xlsbiff8.pas +++ b/components/fpspreadsheet/xlsbiff8.pas @@ -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); diff --git a/components/fpspreadsheet/xlscommon.pas b/components/fpspreadsheet/xlscommon.pas index f77ea1a29..f96a37751 100644 --- a/components/fpspreadsheet/xlscommon.pas +++ b/components/fpspreadsheet/xlscommon.pas @@ -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