numeric format number in cell lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- pomalo · 2013-08-20 07:58 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: [Select]MyWorksheet.WriteNumber( row,2, FieldByName('price').AsCurrency); 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 · 2013-08-20 08:01 Fields->Properties(Object inspector)->DisplayFormat ---------------------------------------------------------------------- exdatis · 2013-08-20 08:03 Example Format : #0.00 -> 123=> 123.00,  12.1 => 12.10 etc. ---------------------------------------------------------------------- exdatis · 2013-08-20 08:13 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 · 2013-08-20 08:24 -----------http://wiki.freepascal.org/FPSpreadsheet#Using_formatting_o ptions-------  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_op tions------- so, you can use : MyWorksheet.WriteUTF8Text(0, 0, Format('2.f', [your_numeric])) http://wiki.freepascal.org/FPSpreadsheet#Using_formatting_options ---------------------------------------------------------------------- pomalo · 2013-08-20 10:59 Quote from: exdatis on August 20, 2013, 10:24:07 amso, you can use : MyWorksheet.WriteUTF8Text(0, 0, Format('2.f', [your_numeric])) http://wiki.freepascal.org/FPSpreadsheet#Using_formatting_options thank this can work but content is left justified (because is text) and i have note see formating setting to right justify in fpspreadsheet.pas  try to set  cell to "cctNumber" content type  after value attribution with Code: [Select]myCell :=  MyWorksheet.GetCell(row,2); myCell^.ContentType := cctNumber; but cell content became "0" ---------------------------------------------------------------------- exdatis · 2013-08-20 12:18 I have no experience, perhaps someone else can help. Regards ---------------------------------------------------------------------- felipemdc · 2013-08-21 04:27 Which format are you writing to? ---------------------------------------------------------------------- pomalo · 2013-08-21 07:26 i have try with value = 10.50 Code: [Select]format('%10.2f')result is 10.50 but left align Code: [Select]format('%10.2m')result is 10.50 € but left align Code: [Select]formatCurr('#######0.00')result is 10.50 but left align Code: [Select]formatCurr('0000000.00') result is 0000010.50 and right align. i'm think that fpspreadsheet trim the result before wiriting it to cell (bug?) ---------------------------------------------------------------------- felipemdc · 2013-08-21 12:23 Not this format ... I meant the file format: if you are writing a Excel2, Excel5, Excel8, or OpenDocument or OOXML document ... ---------------------------------------------------------------------- pomalo · 2013-08-21 16:10 i have the same result with sfOpenDocument and sfExcel5 thank claude