Forum > FPSpreadsheet

How to set a number format for WriteNumber(...) and WriteFormula(...)?

(1/1)

Jvan:
Please, how to do it?

I'm using formulas to sum these numbers too.


Thanks.

wp:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program Project1; uses  fpspreadsheet, fpstypes, fpsutils, fpsopendocument;var  wb: TsWorkbook;  sh: TsWorksheet;begin  wb := TsWorkbook.Create;  try    wb.Options := [boAutoCalc];    sh := wb.AddWorksheet('Test');    sh.WriteNumber(0, 0, 2.345678, nfFixed, 3);      // cell A1: 3 decimals    sh.WriteNumber(1, 0, 5349.342863, nfFixedTh, 3); // cell A2: 3 decimals with thousand separator    sh.WriteNumber(2, 0, -2.345678, nfCustom, '0.000;(0.000)');  // cell A3: negative value in parenthesis    sh.Writeformula(3, 0, 'sum(A1:A3)');    sh.WriteNumberFormat(3, 0, nfFixedTh, 3);        // Format for formula cell: 3 decimals with th.sep.    wb.WriteToFile('test.ods', true);  finally    wb.Free;  end;end.

Jvan:
Thanks.

Navigation

[0] Message Index

Go to full version