You've already forked lazarus-ccr
fpspreadsheet: Simplify csv reader interpreting text (calls worksheet's WriteCellValueAsString now).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5728 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -141,14 +141,8 @@ end;
|
|||||||
the corresponding data to the worksheet. }
|
the corresponding data to the worksheet. }
|
||||||
procedure TsCSVReader.ReadCellValue(ARow, ACol: Cardinal; AText: String);
|
procedure TsCSVReader.ReadCellValue(ARow, ACol: Cardinal; AText: String);
|
||||||
var
|
var
|
||||||
dblValue: Double;
|
|
||||||
dtValue: TDateTime;
|
|
||||||
boolValue: Boolean;
|
|
||||||
currSym: string;
|
|
||||||
warning: String;
|
|
||||||
nf: TsNumberFormat;
|
|
||||||
decs: Integer;
|
|
||||||
cell: PCell;
|
cell: PCell;
|
||||||
|
boolValue: Boolean;
|
||||||
begin
|
begin
|
||||||
// Empty strings are blank cells -- nothing to do
|
// Empty strings are blank cells -- nothing to do
|
||||||
if AText = '' then
|
if AText = '' then
|
||||||
@ -163,27 +157,6 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Check for a NUMBER or CURRENCY cell
|
|
||||||
if IsNumberValue(AText, CSVParams.AutoDetectNumberFormat, FFormatSettings,
|
|
||||||
dblValue, nf, decs, currSym, warning) then
|
|
||||||
begin
|
|
||||||
if currSym <> '' then
|
|
||||||
FWorksheet.WriteCurrency(cell, dblValue, nfCurrency, decs, currSym)
|
|
||||||
else
|
|
||||||
FWorksheet.WriteNumber(cell, dblValue, nf, decs);
|
|
||||||
if warning <> '' then
|
|
||||||
FWorkbook.AddErrorMsg('Cell %s: %s', [GetCellString(ARow, ACol), warning]);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Check for a DATE/TIME cell
|
|
||||||
// No idea how to apply the date/time formatsettings here...
|
|
||||||
if IsDateTimeValue(AText, FFormatSettings, dtValue, nf) then
|
|
||||||
begin
|
|
||||||
FWorksheet.WriteDateTime(cell, dtValue, nf);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Check for a BOOLEAN cell
|
// Check for a BOOLEAN cell
|
||||||
if IsBoolValue(AText, CSVParams.TrueText, CSVParams.FalseText, boolValue) then
|
if IsBoolValue(AText, CSVParams.TrueText, CSVParams.FalseText, boolValue) then
|
||||||
begin
|
begin
|
||||||
@ -191,8 +164,8 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// What is left is handled as a TEXT cell
|
// All other cases are handled by WriteCellValusAsString
|
||||||
FWorksheet.WriteText(cell, AText);
|
FWorksheet.WriteCellValueAsString(cell, AText, FFormatSettings);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TsCSVReader.ReadFormula(AStream: TStream);
|
procedure TsCSVReader.ReadFormula(AStream: TStream);
|
||||||
|
Reference in New Issue
Block a user