Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Packages and Libraries
»
FPSpreadsheet
»
How to set a number format for WriteNumber(...) and WriteFormula(...)?
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
IRC channel
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Compiler demotes register...
by
Thaddy
[
Today
at 02:51:51 pm]
Building Lazarus
by
EventHorizon
[
Today
at 02:47:16 pm]
Initiaiizing records by c...
by
Thaddy
[
Today
at 02:46:32 pm]
TBRGAAnimatedGif irregula...
by
BobT
[
Today
at 02:41:32 pm]
Bad ICONINFO struct in Jw...
by
Thaddy
[
Today
at 02:38:25 pm]
Fairtris 2: The Ultimate ...
by
furious programming
[
Today
at 02:21:42 pm]
IsManagedType problem, do...
by
ASerge
[
Today
at 02:02:23 pm]
Tpagecontrol descendant
by
dseligo
[
Today
at 01:37:28 pm]
[SOLVED] Combined pointer...
by
CM630
[
Today
at 01:08:17 pm]
F8 step-over sometimes go...
by
Martin_fr
[
Today
at 12:44:27 pm]
Cross compilation error, ...
by
jollytall
[
Today
at 12:41:00 pm]
Lazarus character map
by
dseligo
[
Today
at 12:22:41 pm]
Using WebAssemblies
by
Laprado
[
Today
at 12:11:11 pm]
[Solved] Help with sql
by
magleft
[
Today
at 12:08:27 pm]
android
by
BlueIcaro
[
Today
at 11:41:53 am]
Square Fractal: A bit dif...
by
Boleeman
[
Today
at 10:47:20 am]
Here's some Pong game. Su...
by
Seenkao
[
Today
at 10:16:13 am]
lamw
by
dseligo
[
Today
at 09:35:00 am]
"fpc.cfg is missing" (not...
by
Thaddy
[
Today
at 08:55:31 am]
A question on Modula2 vs ...
by
MarkMLl
[
Today
at 08:39:26 am]
Offical launch of the 1 B...
by
Thaddy
[
Today
at 08:37:40 am]
Indeed TCustomApplication...
by
Gustavo 'Gus' Carreno
[
Today
at 08:22:53 am]
Hypocycloid Program (incl...
by
speter
[
Today
at 05:33:19 am]
Designer
by
SandyG
[
Today
at 03:20:24 am]
Best way to exchange data...
by
cdbc
[
Today
at 03:00:24 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: How to set a number format for WriteNumber(...) and WriteFormula(...)? (Read 2447 times)
Jvan
Full Member
Posts: 181
How to set a number format for WriteNumber(...) and WriteFormula(...)?
«
on:
May 07, 2021, 12:56:52 am »
Please, how to do it?
I'm using formulas to sum these numbers too.
Thanks.
«
Last Edit: May 07, 2021, 12:59:59 am by Jvan
»
Logged
wp
Hero Member
Posts: 11833
Re: How to set a number format for WriteNumber(...) and WriteFormula(...)?
«
Reply #1 on:
May 07, 2021, 10:40:25 am »
Code: Pascal
[Select]
[+]
[-]
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
.
Logged
Jvan
Full Member
Posts: 181
Re: How to set a number format for WriteNumber(...) and WriteFormula(...)?
«
Reply #2 on:
May 07, 2021, 09:51:08 pm »
Thanks.
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Packages and Libraries
»
FPSpreadsheet
»
How to set a number format for WriteNumber(...) and WriteFormula(...)?
TinyPortal
© 2005-2018