Forum > FPSpreadsheet

numeric format number in cell

(1/3) > >>

pomalo:
hello

In my application,  data are extracted from a mysql database and write it to an ods worsheet
some cell contain currency number and are read from database with

--- Code: ---MyWorksheet.WriteNumber( row,2, FieldByName('price').AsCurrency);

--- End code ---

When reading the spreadsheet with Openoffice the price become for exemple '2' in place of '2.00' or "2.5" in place of '2.50'.

Is there a way to format the numeric cell containt


thank for your help
Claude

exdatis:
Fields->Properties(Object inspector)->DisplayFormat

exdatis:
Example
Format : #0.00 -> 123=> 123.00,  12.1 => 12.10 etc.

exdatis:
http://lazarus-ccr.sourceforge.net/docs/rtl/sysutils/format.html
http://www.freepascal.org/docs-html/rtl/sysutils/formatfloat.html
http://lazarus-ccr.sourceforge.net/docs/rtl/sysutils/formatdatetime.html

exdatis:
-----------http://wiki.freepascal.org/FPSpreadsheet#Using_formatting_options-------
 Using formatting options

The formatting is set independently from the text, as in the example below:

  // Write a bold text
  MyWorksheet.WriteUTF8Text(0, 0, 'First');
  MyWorksheet.WriteUsedFormatting(0, 0, [uffBold]);
----------http://wiki.freepascal.org/FPSpreadsheet#Using_formatting_options-------
so, you can use : MyWorksheet.WriteUTF8Text(0, 0, Format('2.f', [your_numeric]))
http://wiki.freepascal.org/FPSpreadsheet#Using_formatting_options

Navigation

[0] Message Index

[#] Next page

Go to full version