× Components and Libraries for Documents Development, discussions, problems and suggestions

Question Correction unit fpsexport

  • Randall G. Garcia C
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
4 years 4 months ago #9240 by Randall G. Garcia C
Correction unit fpsexport was created by Randall G. Garcia C
Hi there
Here I attached a procedure that must be corrected in the fpsexport unit because the currency float and puts a symbol fields below
procedure TCustomFPSExport.ExportField(EF: TExportFieldItem);
var
  F : TFPSExportFieldItem;
  dt: TDateTime;
begin
  F := EF as TFPSExportFieldItem;
  with F do
  begin
    // Export depending on field datatype;
    // Fall back to string if unknown datatype
    If Field.IsNull then
      FSheet.WriteBlank(FRow, EF.Index)
    else if Field.Datatype in (IntFieldTypes+[ftAutoInc,ftLargeInt]) then
      FSheet.WriteNumber(FRow, EF.Index,Field.AsInteger)
    else if Field.Datatype=ftCurrency then
      FSheet.WriteCurrency(FRow, EF.Index, Field.AsFloat)
    else if Field.Datatype in [ftBCD,ftFloat,ftFMTBcd] then
      FSheet.WriteNumber(FRow, EF.Index, Field.AsFloat)
    else if Field.DataType in [ftString,ftFixedChar] then
      FSheet.WriteText(FRow, EF.Index, Field.AsString)
    else if (Field.DataType in ([ftWideMemo,ftWideString,ftFixedWideChar]+BlobFieldTypes)) then
      FSheet.WriteText(FRow, EF.Index, UTF8Encode(Field.AsWideString))
      { Note: we test for the wide text fields before the MemoFieldTypes, in order to
      let ftWideMemo end up at the right place }
    else if Field.DataType in MemoFieldTypes then
      FSheet.WriteText(FRow, EF.Index, Field.AsString)
    else if Field.DataType=ftBoolean then
      FSheet.WriteBoolValue(FRow, EF.Index, Field.AsBoolean)
    else if Field.DataType in DateFieldTypes then
      case Field.DataType of
        ftDate: FSheet.WriteDateTime(FRow, EF.Index, Field.AsDateTime, nfShortDate);
        ftTime: FSheet.WriteDateTime(FRow, EF.Index, Field.AsDatetime, nfLongTime);
        else    // try to guess best format if Field.DataType is ftDateTime
                dt := Field.AsDateTime;
                if dt < 1.0 then
                  FSheet.WriteDateTime(FRow, EF.Index, Field.AsDateTime, nfLongTime)
                else if frac(dt) = 0 then
                  FSheet.WriteDateTime(FRow, EF.Index, Field.AsDateTime, nfShortDate)
                else
                  FSheet.WriteDateTime(FRow, EF.Index, Field.AsDateTime, nfShortDateTime);
      end
    else //fallback to string
      FSheet.WriteText(FRow, EF.Index, Field.AsString);
  end;
end;

these are the lines corrected
    else if Field.Datatype=ftCurrency then
      FSheet.WriteCurrency(FRow, EF.Index, Field.AsFloat)
    else if Field.Datatype in [ftBCD,ftFloat,ftFMTBcd] then
      FSheet.WriteNumber(FRow, EF.Index, Field.AsFloat)

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Away
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
4 years 4 months ago #9241 by Sternas Stefanos
Replied by Sternas Stefanos on topic Correction unit fpsexport
Thanks Sir
we will update and test

PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.