fpspreadsheet: Add controls to change number format to the fpsgrid demo program. Also, add the "brush" button to copy a format to another cell.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3049 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2014-05-15 22:41:14 +00:00
parent dae7caff9c
commit e21231de03
7 changed files with 1664 additions and 974 deletions

View File

@ -128,29 +128,30 @@
<UnitName Value="mainform"/>
<EditorIndex Value="1"/>
<WindowIndex Value="0"/>
<TopLine Value="309"/>
<CursorPos X="18" Y="327"/>
<TopLine Value="628"/>
<CursorPos X="30" Y="639"/>
<UsageCount Value="200"/>
<Bookmarks Count="1">
<Item0 X="3" Y="361" ID="1"/>
</Bookmarks>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
<Unit2>
<Filename Value="..\..\fpspreadsheet.pas"/>
<UnitName Value="fpspreadsheet"/>
<EditorIndex Value="3"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="4"/>
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="2655"/>
<CursorPos X="3" Y="2680"/>
<UsageCount Value="100"/>
<Bookmarks Count="1">
<Item0 X="13" Y="2613" ID="1"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit2>
<Unit3>
<Filename Value="..\..\fpspreadsheetgrid.pas"/>
<UnitName Value="fpspreadsheetgrid"/>
<EditorIndex Value="2"/>
<EditorIndex Value="3"/>
<WindowIndex Value="0"/>
<TopLine Value="1774"/>
<CursorPos X="26" Y="1785"/>
@ -231,12 +232,11 @@
<Unit13>
<Filename Value="..\..\fpsutils.pas"/>
<UnitName Value="fpsutils"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="9"/>
<WindowIndex Value="0"/>
<TopLine Value="65"/>
<CursorPos X="1" Y="78"/>
<UsageCount Value="51"/>
<TopLine Value="37"/>
<CursorPos X="1" Y="21"/>
<UsageCount Value="53"/>
<Loaded Value="True"/>
</Unit13>
<Unit14>
@ -268,7 +268,7 @@
<WindowIndex Value="0"/>
<TopLine Value="62"/>
<CursorPos X="15" Y="90"/>
<UsageCount Value="82"/>
<UsageCount Value="84"/>
<Loaded Value="True"/>
</Unit17>
<Unit18>
@ -289,11 +289,11 @@
<Unit20>
<Filename Value="..\..\xlscommon.pas"/>
<UnitName Value="xlscommon"/>
<EditorIndex Value="4"/>
<EditorIndex Value="5"/>
<WindowIndex Value="0"/>
<TopLine Value="608"/>
<CursorPos X="31" Y="634"/>
<UsageCount Value="78"/>
<TopLine Value="588"/>
<CursorPos X="61" Y="592"/>
<UsageCount Value="80"/>
<Loaded Value="True"/>
</Unit20>
<Unit21>
@ -303,7 +303,7 @@
<WindowIndex Value="0"/>
<TopLine Value="1363"/>
<CursorPos X="1" Y="1364"/>
<UsageCount Value="65"/>
<UsageCount Value="67"/>
<Loaded Value="True"/>
</Unit21>
<Unit22>
@ -313,7 +313,7 @@
<WindowIndex Value="0"/>
<TopLine Value="664"/>
<CursorPos X="21" Y="677"/>
<UsageCount Value="66"/>
<UsageCount Value="68"/>
<Loaded Value="True"/>
</Unit22>
<Unit23>
@ -372,10 +372,12 @@
</Unit29>
<Unit30>
<Filename Value="d:\lazarus-svn\lcl\include\control.inc"/>
<EditorIndex Value="2"/>
<WindowIndex Value="0"/>
<TopLine Value="4129"/>
<CursorPos X="1" Y="4161"/>
<UsageCount Value="8"/>
<TopLine Value="2696"/>
<CursorPos X="23" Y="2712"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit30>
<Unit31>
<Filename Value="..\..\fpspreadsheetchart.pas"/>
@ -482,12 +484,10 @@
</Unit43>
<Unit44>
<Filename Value="C:\development\fpc\rtl\i386\i386.inc"/>
<EditorIndex Value="5"/>
<WindowIndex Value="0"/>
<TopLine Value="1497"/>
<CursorPos X="1" Y="1515"/>
<UsageCount Value="13"/>
<Loaded Value="True"/>
</Unit44>
<Unit45>
<Filename Value="C:\development\lazarus\lcl\grids.pas"/>
@ -592,124 +592,124 @@
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="783" Column="1" TopLine="768"/>
<Filename Value="mainform.pas"/>
<Caret Line="633" Column="1" TopLine="631"/>
</Position1>
<Position2>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="804" Column="1" TopLine="788"/>
<Filename Value="mainform.pas"/>
<Caret Line="638" Column="43" TopLine="619"/>
</Position2>
<Position3>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="805" Column="1" TopLine="788"/>
<Filename Value="mainform.pas"/>
<Caret Line="633" Column="43" TopLine="619"/>
</Position3>
<Position4>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="817" Column="32" TopLine="788"/>
<Filename Value="mainform.pas"/>
<Caret Line="195" Column="1" TopLine="168"/>
</Position4>
<Position5>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="807" Column="1" TopLine="788"/>
<Filename Value="mainform.pas"/>
<Caret Line="643" Column="25" TopLine="631"/>
</Position5>
<Position6>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="808" Column="1" TopLine="788"/>
<Filename Value="mainform.pas"/>
<Caret Line="640" Column="1" TopLine="631"/>
</Position6>
<Position7>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="784" Column="1" TopLine="769"/>
<Filename Value="mainform.pas"/>
<Caret Line="342" Column="3" TopLine="337"/>
</Position7>
<Position8>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="785" Column="1" TopLine="769"/>
<Filename Value="mainform.pas"/>
<Caret Line="343" Column="1" TopLine="336"/>
</Position8>
<Position9>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="786" Column="1" TopLine="769"/>
<Filename Value="mainform.pas"/>
<Caret Line="346" Column="1" TopLine="336"/>
</Position9>
<Position10>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="787" Column="1" TopLine="769"/>
<Filename Value="mainform.pas"/>
<Caret Line="354" Column="1" TopLine="336"/>
</Position10>
<Position11>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="788" Column="1" TopLine="769"/>
<Filename Value="mainform.pas"/>
<Caret Line="346" Column="8" TopLine="336"/>
</Position11>
<Position12>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="794" Column="1" TopLine="769"/>
<Filename Value="mainform.pas"/>
<Caret Line="343" Column="1" TopLine="336"/>
</Position12>
<Position13>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1108" Column="1" TopLine="1093"/>
<Filename Value="mainform.pas"/>
<Caret Line="346" Column="1" TopLine="336"/>
</Position13>
<Position14>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1109" Column="1" TopLine="1093"/>
<Filename Value="mainform.pas"/>
<Caret Line="347" Column="1" TopLine="336"/>
</Position14>
<Position15>
<Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="1461" Column="1" TopLine="1445"/>
<Filename Value="mainform.pas"/>
<Caret Line="348" Column="1" TopLine="336"/>
</Position15>
<Position16>
<Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="1462" Column="1" TopLine="1445"/>
<Filename Value="mainform.pas"/>
<Caret Line="349" Column="1" TopLine="336"/>
</Position16>
<Position17>
<Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="1464" Column="1" TopLine="1445"/>
<Filename Value="mainform.pas"/>
<Caret Line="350" Column="1" TopLine="336"/>
</Position17>
<Position18>
<Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="1465" Column="1" TopLine="1451"/>
<Filename Value="mainform.pas"/>
<Caret Line="351" Column="1" TopLine="336"/>
</Position18>
<Position19>
<Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="1469" Column="1" TopLine="1451"/>
<Filename Value="mainform.pas"/>
<Caret Line="354" Column="1" TopLine="336"/>
</Position19>
<Position20>
<Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="1470" Column="1" TopLine="1451"/>
<Filename Value="mainform.pas"/>
<Caret Line="640" Column="1" TopLine="621"/>
</Position20>
<Position21>
<Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="1471" Column="1" TopLine="1451"/>
<Filename Value="mainform.pas"/>
<Caret Line="641" Column="1" TopLine="621"/>
</Position21>
<Position22>
<Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="1485" Column="39" TopLine="1468"/>
<Filename Value="mainform.pas"/>
<Caret Line="343" Column="1" TopLine="324"/>
</Position22>
<Position23>
<Filename Value="..\..\fpsutils.pas"/>
<Caret Line="913" Column="46" TopLine="884"/>
<Filename Value="mainform.pas"/>
<Caret Line="632" Column="30" TopLine="621"/>
</Position23>
<Position24>
<Filename Value="..\..\fpsutils.pas"/>
<Caret Line="83" Column="3" TopLine="52"/>
<Filename Value="mainform.pas"/>
<Caret Line="633" Column="30" TopLine="622"/>
</Position24>
<Position25>
<Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="1485" Column="42" TopLine="1459"/>
<Filename Value="mainform.pas"/>
<Caret Line="634" Column="30" TopLine="623"/>
</Position25>
<Position26>
<Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
<Filename Value="mainform.pas"/>
<Caret Line="635" Column="30" TopLine="624"/>
</Position26>
<Position27>
<Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="2612" Column="3" TopLine="2674"/>
<Filename Value="mainform.pas"/>
<Caret Line="636" Column="30" TopLine="625"/>
</Position27>
<Position28>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="581" Column="3" TopLine="573"/>
<Filename Value="mainform.pas"/>
<Caret Line="637" Column="30" TopLine="626"/>
</Position28>
<Position29>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
<Filename Value="mainform.pas"/>
<Caret Line="638" Column="30" TopLine="627"/>
</Position29>
<Position30>
<Filename Value="..\..\fpsutils.pas"/>
<Caret Line="1157" Column="1" TopLine="1131"/>
<Filename Value="..\..\xlscommon.pas"/>
<Caret Line="592" Column="61" TopLine="588"/>
</Position30>
</JumpHistory>
</ProjectOptions>

View File

@ -1,11 +1,11 @@
object Form1: TForm1
Left = 359
Height = 593
Height = 649
Top = 193
Width = 722
Width = 884
Caption = 'fpsGrid'
ClientHeight = 568
ClientWidth = 722
ClientHeight = 629
ClientWidth = 884
Menu = MainMenu1
OnActivate = FormActivate
OnCreate = FormCreate
@ -14,18 +14,18 @@ object Form1: TForm1
object Panel1: TPanel
Left = 0
Height = 76
Top = 492
Width = 722
Top = 553
Width = 884
Align = alBottom
BevelOuter = bvNone
ClientHeight = 76
ClientWidth = 722
ClientWidth = 884
TabOrder = 0
object CbShowHeaders: TCheckBox
Left = 8
Height = 24
Height = 19
Top = 11
Width = 116
Width = 93
Caption = 'Show headers'
Checked = True
OnClick = CbShowHeadersClick
@ -34,9 +34,9 @@ object Form1: TForm1
end
object CbShowGridLines: TCheckBox
Left = 8
Height = 24
Height = 19
Top = 36
Width = 125
Width = 100
Caption = 'Show grid lines'
Checked = True
OnClick = CbShowGridLinesClick
@ -45,7 +45,7 @@ object Form1: TForm1
end
object EdFrozenCols: TSpinEdit
Left = 238
Height = 28
Height = 23
Top = 8
Width = 52
OnChange = EdFrozenColsChange
@ -53,7 +53,7 @@ object Form1: TForm1
end
object EdFrozenRows: TSpinEdit
Left = 238
Height = 28
Height = 23
Top = 39
Width = 52
OnChange = EdFrozenRowsChange
@ -61,18 +61,18 @@ object Form1: TForm1
end
object Label1: TLabel
Left = 152
Height = 20
Height = 15
Top = 13
Width = 77
Width = 62
Caption = 'Frozen cols:'
FocusControl = EdFrozenCols
ParentColor = False
end
object Label2: TLabel
Left = 153
Height = 20
Height = 15
Top = 40
Width = 82
Width = 66
Caption = 'Frozen rows:'
FocusControl = EdFrozenRows
ParentColor = False
@ -80,9 +80,9 @@ object Form1: TForm1
end
object PageControl1: TPageControl
Left = 0
Height = 439
Height = 500
Top = 53
Width = 722
Width = 884
ActivePage = TabSheet1
Align = alClient
TabIndex = 0
@ -90,13 +90,13 @@ object Form1: TForm1
OnChange = PageControl1Change
object TabSheet1: TTabSheet
Caption = 'Sheet1'
ClientHeight = 406
ClientWidth = 714
ClientHeight = 472
ClientWidth = 876
object sWorksheetGrid1: TsWorksheetGrid
Left = 0
Height = 406
Height = 472
Top = 0
Width = 714
Width = 876
FrozenCols = 0
FrozenRows = 0
Align = alClient
@ -108,7 +108,7 @@ object Form1: TForm1
TitleStyle = tsNative
OnSelection = sWorksheetGrid1Selection
ColWidths = (
56
42
64
)
end
@ -118,7 +118,7 @@ object Form1: TForm1
Left = 0
Height = 26
Top = 0
Width = 722
Width = 884
ButtonHeight = 24
Caption = 'ToolBar1'
EdgeBorders = []
@ -163,41 +163,42 @@ object Form1: TForm1
Left = 0
Height = 27
Top = 26
Width = 722
Width = 884
ButtonHeight = 23
Caption = 'FormatToolBar'
Images = ImageList1
TabOrder = 3
object ToolButton10: TToolButton
Left = 296
Left = 324
Top = 2
Action = AcLeftAlign
Wrap = True
end
object ToolButton12: TToolButton
Left = 319
Left = 347
Top = 2
Action = AcHorCenterAlign
end
object ToolButton13: TToolButton
Left = 342
Left = 370
Top = 2
Action = AcRightAlign
end
object FontComboBox: TComboBox
Left = 24
Height = 28
Left = 52
Height = 23
Top = 2
Width = 127
ItemHeight = 20
ItemHeight = 15
OnSelect = FontComboBoxSelect
TabOrder = 0
end
object FontSizeComboBox: TComboBox
Left = 151
Height = 28
Left = 179
Height = 23
Top = 2
Width = 48
ItemHeight = 20
ItemHeight = 15
Items.Strings = (
'8'
'9'
@ -214,70 +215,75 @@ object Form1: TForm1
TabOrder = 1
end
object ToolButton7: TToolButton
Left = 199
Left = 227
Top = 2
Action = AcFontBold
end
object ToolButton8: TToolButton
Left = 222
Left = 250
Top = 2
Action = AcFontItalic
end
object ToolButton9: TToolButton
Left = 245
Left = 273
Top = 2
Action = AcFontUnderline
end
object ToolButton11: TToolButton
Left = 268
Left = 296
Top = 2
Action = AcFontStrikeout
end
object ToolButton14: TToolButton
Left = 291
Left = 319
Top = 2
Width = 5
Caption = 'ToolButton14'
Style = tbsDivider
Wrap = True
end
object ToolButton15: TToolButton
Left = 365
Left = 393
Top = 2
Width = 5
Caption = 'ToolButton15'
Style = tbsDivider
Wrap = True
end
object ToolButton16: TToolButton
Left = 370
Left = 398
Top = 2
Action = AcVAlignTop
Wrap = True
end
object ToolButton17: TToolButton
Left = 393
Left = 421
Top = 2
Action = AcVAlignCenter
end
object ToolButton18: TToolButton
Left = 416
Left = 444
Top = 2
Action = AcVAlignBottom
end
object ToolButton19: TToolButton
Left = 439
Left = 467
Top = 2
Width = 5
Caption = 'ToolButton19'
Style = tbsDivider
Wrap = True
end
object TbBorders: TToolButton
Left = 444
Left = 472
Top = 2
Action = AcBorderNone
DropdownMenu = BordersPopupMenu
Style = tbsDropDown
Wrap = True
end
object CbBackgroundColor: TColorBox
Left = 479
Left = 507
Height = 22
Top = 2
Width = 132
@ -288,10 +294,42 @@ object Form1: TForm1
TabOrder = 2
end
object ToolButton21: TToolButton
Left = 1
Left = 29
Top = 2
Action = AcFont
end
object TbNumFormats: TToolButton
Left = 639
Hint = 'Change number format'
Top = 2
Caption = 'Fixed'
DropdownMenu = NumFormatPopupMenu
ImageIndex = 33
Style = tbsDropDown
end
object ToolButton24: TToolButton
Left = 697
Top = 2
Action = AcDecDecimals
end
object ToolButton25: TToolButton
Left = 674
Top = 2
Action = AcIncDecimals
end
object ToolButton26: TToolButton
Left = 24
Top = 2
Width = 5
Caption = 'ToolButton26'
Style = tbsDivider
Wrap = True
end
object ToolButton20: TToolButton
Left = 1
Top = 2
Action = AcCopyFormat
end
end
object OpenDialog1: TOpenDialog
DefaultExt = '.xls'
@ -804,13 +842,40 @@ object Form1: TForm1
Action = AcWordwrap
AutoCheck = True
end
object MnuNumberFormat: TMenuItem
Caption = 'Number format'
object MenuItem33: TMenuItem
Action = AcNFGeneral
AutoCheck = True
end
object MenuItem34: TMenuItem
Action = AcNFFixed
AutoCheck = True
end
object MenuItem35: TMenuItem
Action = AcNFFixedTh
AutoCheck = True
end
object MenuItem36: TMenuItem
Action = AcNFPercentage
AutoCheck = True
end
object MenuItem37: TMenuItem
Action = AcNFExp
AutoCheck = True
end
object MenuItem38: TMenuItem
Action = AcNFSci
AutoCheck = True
end
end
end
end
object ImageList1: TImageList
left = 176
top = 120
Bitmap = {
4C691E0000001000000010000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
4C69220000001000000010000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00EAC39DFFE6BF96FFE4BB92FFE4BB92FFD1A06CF5D09E6DF6CC96
5FDAC479427EB2673C09FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00E5BE96FFFFFFFEFFFDF3E9FFFDF3EAFFFCF2E8FFFAEFE3FFFAF2
@ -1770,6 +1835,134 @@ object Form1: TForm1
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00016395000163940001629300016192000162
930001629300016394000000000001334C00016597000164960001639400003A
8C00003E9248003C8FCC00378A48016395000163940001629300016192000162
930001629300016394000000000001334C390165969C0164959C0163943E0039
8B48003688CC5285C9FF002E7ECC016395000163940001629300016192000162
93000162930001639400000000240000006788CCDDFF87CBDDFF016091AF0030
80CC3F72B6FF002774CC00247048016395000163940001629300016192000162
9300016293100162936D00000069DDDCDCFF949494FF70B4D6FF80C4DBFF015C
8DB2001A63CC0013584800226E00016395050163941401629328016192410161
9277106C9AAB4B9BBADB79B9D5FC919191FFD9D4D4FF8D8D8DFF68ACCEFF74B8
D4FF015887B4015686400155840001629383126D9BB82078A2C33385ABD058A2
C0E774B9D1FB6EACCCFF669DC8FF83C7DAFF888888FFD3CACAFF838383FF60A4
C6FF63A7C9FF015382A5015281000160913E015E8FB16AAEC9FF66A8C5FF5692
B8FF4B80AFFF5D97BFFF77B9D2FF669DC8FF7BBAD5FF7E7E7EFFCEC0C0FF7979
79FF5588BBFF014F7EA6014E7D00015F9000002B5548002B55CC336898FF508C
B3FF69ABC8FF67A7C6FF4D80B3FF71B1CEFF6EA9CDFF6CA3CEFF6D6D6DFFAA99
99FF010101A5014C7A42014B7A00015F9000002B55000157873F015585B65FA1
C0FF3F79A3FF4278A7FF66A6C5FF619DC2FF5E95C1FF74B4D1FF6598CBFF0101
01AB0101013C014B7900014B7A00015F9000002B550001568600002B5548002B
55CC4F8DB3FF68ACC8FF4880ACFF5087B3FF6AAAC8FF5588BBFF00416EC1003E
6A4401010100014B7900014B7A00015F9000002B550001568600002B5500014D
7C41014B79BB3A719FFF386F9DFF5F9FC0FF4578ABFF003763C600356046003C
680001010100014B7900014B7A00015F9000002B550001568600002B5500014C
7B00002B5548002B55CC5494B7FF34679AFF00305ACA002D584800335E00003C
680001010100014B7900014B7A00015F9000002B550001568600002B5500014C
7B00002B550000315C47002D57CC002C56CC002B5548002C570000335E00003C
680001010100014B7900014B7A00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00E7815F00BE5A3800B34B
2900D4573500DF5D3B00702F1E0001010100010101000101013F010101B40101
01B601010140FFFFFF00FFFFFF00FFFFFF00FFFFFF00E7815F40BE5A38FFB148
2600D4573500DF5D3B00702F1E000101010001010112010101B50101012E0101
0138010101B9FFFFFF00FFFFFF00FFFFFF00FFFFFF00E7815FFFBE5A38E0AF45
23FFD45735FFDF5D3B00391810000101010001010112010101B7010101000101
0113010101BBFFFFFF00FFFFFF00FFFFFF00FFFFFF00E7815F40BE5A38FFB148
2600D457350039181000010101000101010001010113010101B9010101000101
0113010101BEFFFFFF00FFFFFF00FFFFFF00FFFFFF00E7815F00BE5A3800B34B
29009D40270001010100010101B70101015C01010113010101BB0101012F0101
013A010101C0FFFFFF00FFFFFF00FFFFFF00FFFFFF00E7815F00BE5A3800873A
21000101010001010100010101B90101015D0101010001010143010101BF0101
01C101010144FFFFFF00FFFFFF00FFFFFF00FFFFFF00E7815F00BE5A38002E15
0D00010101000101010001010100010101000101010001010100010101000101
010001010100FFFFFF00FFFFFF00FFFFFF00FFFFFF0001010100010101000101
0100010101000101010001010100010101000101010001010100010101000101
010001010100FFFFFF00FFFFFF00FFFFFF00FFFFFF0001010100010101000101
010001010143010101BE010101C0010101440101010001010145010101C60101
01C801010147FFFFFF00FFFFFF00FFFFFF00FFFFFF0001010100010101000101
0113010101BF010101300101013B010101C401010114010101C7010101320101
013D010101CDFFFFFF00FFFFFF00FFFFFF00FFFFFF0001010100010101000101
0113010101C10101010001010114010101C601010114010101CA010101000000
0015000000D5FFFFFF00FFFFFF00FFFFFF00FFFFFF0001010100010101000101
0114010101C40101010001010114010101C901010115010101CC010101000000
0016000000DEFFFFFF00FFFFFF00FFFFFF00FFFFFF00010101C1010101610101
0114010101C6010101320101013D010101CB00000015000000D5000000370000
0045000000E6FFFFFF00FFFFFF00FFFFFF00FFFFFF00010101C4010101630101
010001010146010101CB010101CC00000048000000000000004E000000E40000
00E900000053FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF0001010100010101000101
01000101013E010101AF010101B00101013E010101000101013F010101B40101
01B601010140FFFFFF00FFFFFF00FFFFFF00FFFFFF0001010100010101000101
0112010101AF0101012C01010135010101B301010112010101B50101012E0101
0138010101B9FFFFFF00FFFFFF00FFFFFF00FFFFFF0001010100010101000101
0112010101B10101010001010112010101B401010112010101B7010101000101
0113010101BBFFFFFF00FFFFFF00FFFFFF00FFFFFF0001010100010101000101
0112010101B20101010001010112010101B601010113010101B9010101000101
0113010101BEFFFFFF00FFFFFF00FFFFFF00FFFFFF00010101B1010101590101
0112010101B40101012E01010137010101B801010113010101BB0101012F0101
013A010101C0FFFFFF00FFFFFF00FFFFFF00FFFFFF00010101B20101015A0101
010001010140010101B8010101B9010101410101010001010143010101BF0101
01C101010144FFFFFF00FFFFFF00FFFFFF00FFFFFF0001010100010101000101
0100010101000101010001010100010101000101010001010100010101000101
010001010100FFFFFF00FFFFFF00FFFFFF00FFFFFF00010101002C120A00AF45
230033150D000101010001010100010101000101010001010100010101000101
010001010100FFFFFF00FFFFFF00FFFFFF00FFFFFF00E7815F00B9543200AF45
2300D4573500A8462D0039181000010101000101010001010145010101C60101
01C801010147FFFFFF00FFFFFF00FFFFFF00FFFFFF00E7815F00BC573500AF45
23FFD4573540DF5D3B00702F1E000101010001010114010101C7010101320101
013D010101CDFFFFFF00FFFFFF00FFFFFF00FFFFFF00E7815FFFBE5A38FFAF45
23E0D45735FFDF5D3B00391810000101010001010114010101CA010101000000
0015000000D5FFFFFF00FFFFFF00FFFFFF00FFFFFF00E7815F00BC573500AF45
23FFD457354039181000010101000101010001010115010101CC010101000000
0016000000DEFFFFFF00FFFFFF00FFFFFF00FFFFFF00E7815F00B9543200AF45
23009D40270001010100010101CA0101016600000015000000D5000000370000
0045000000E6FFFFFF00FFFFFF00FFFFFF00FFFFFF00E7815F00B9543200AF45
230033150D0001010100010101CC00000068000000000000004E000000E40000
00E900000053FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00010101000101
0100010101000101012B010101AC0101012B010101000101012B010101AC0101
012BFFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00010101000101
01000101010001010160010101A6010101000101010001010160010101A60101
0100FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00010101000101
010001010100010101A9010101620101010001010100010101A9010101620101
0100FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000101012E0101
01B5010101B5010101B5010101B5010101B5010101B5010101B5010101B50101
01B5FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00010101000101
010001010166010101B1010101000101010001010166010101B1010101000101
0100FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00010101000101
0100010101B5010101690101010001010100010101B501010169010101000101
0100FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00010101C30101
01C3010101C3010101C3010101C3010101C3010101C3010101C3010101C30101
0131FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00010101000101
016F010101BE01010100010101000101016F010101BE01010100010101000101
0100FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00010101000101
01C7010101730101010001010100010101C70101017301010100010101000101
0100FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000003A0000
00E400000039000000000000003A000000E40000003900000000010101000101
0100FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00
}
end
@ -2035,6 +2228,72 @@ object Form1: TForm1
Hint = 'Text characters stacked'
OnExecute = AcTextRotationExecute
end
object AcNFGeneral: TAction
Tag = 150
Category = 'Format'
AutoCheck = True
Caption = 'General'
Checked = True
OnExecute = AcNumFormatExecute
end
object AcNFFixed: TAction
Tag = 151
Category = 'Format'
AutoCheck = True
Caption = 'Fixed'
Hint = 'Fixed format'
OnExecute = AcNumFormatExecute
end
object AcNFFixedTh: TAction
Tag = 152
Category = 'Format'
AutoCheck = True
Caption = 'Fixed w/thousand separator'
Hint = 'Fixed format with thousand separator'
OnExecute = AcNumFormatExecute
end
object AcNFExp: TAction
Tag = 153
Category = 'Format'
AutoCheck = True
Caption = 'Exponential'
OnExecute = AcNumFormatExecute
end
object AcNFSci: TAction
Tag = 154
Category = 'Format'
AutoCheck = True
Caption = 'Scientific'
OnExecute = AcNumFormatExecute
end
object AcNFPercentage: TAction
Tag = 155
Category = 'Format'
AutoCheck = True
Caption = 'Percentage'
OnExecute = AcNumFormatExecute
end
object AcIncDecimals: TAction
Category = 'Format'
Caption = 'AcIncDecimals'
Hint = 'More decimals'
ImageIndex = 31
OnExecute = AcIncDecDecimalsExecute
end
object AcDecDecimals: TAction
Category = 'Format'
Caption = 'AcDecDecimals'
Hint = 'Less decimals'
ImageIndex = 32
OnExecute = AcIncDecDecimalsExecute
end
object AcCopyFormat: TAction
Category = 'Format'
AutoCheck = True
Caption = 'AcCopyFormat'
ImageIndex = 30
OnExecute = AcCopyFormatExecute
end
end
object FontDialog1: TFontDialog
MinFontSize = 0
@ -2650,4 +2909,32 @@ object Form1: TForm1
}
end
end
object NumFormatPopupMenu: TPopupMenu
left = 290
top = 179
object MnuNFGeneral: TMenuItem
Action = AcNFGeneral
AutoCheck = True
end
object MnuNFFixed: TMenuItem
Action = AcNFFixed
AutoCheck = True
end
object MnuNFFixedTh: TMenuItem
Action = AcNFFixedTh
AutoCheck = True
end
object MnuNFPercentage: TMenuItem
Action = AcNFPercentage
AutoCheck = True
end
object MnuNFExp: TMenuItem
Action = AcNFExp
AutoCheck = True
end
object MnuNFSci: TMenuItem
Action = AcNFSci
AutoCheck = True
end
end
end

File diff suppressed because it is too large Load Diff

View File

@ -46,6 +46,15 @@ type
AcTextVertCW: TAction;
AcTextVertCCW: TAction;
AcTextStacked: TAction;
AcNFFixed: TAction;
AcNFFixedTh: TAction;
AcNFPercentage: TAction;
AcIncDecimals: TAction;
AcDecDecimals: TAction;
AcNFGeneral: TAction;
AcNFExp: TAction;
AcNFSci: TAction;
AcCopyFormat: TAction;
AcWordwrap: TAction;
AcVAlignDefault: TAction;
AcVAlignTop: TAction;
@ -88,6 +97,19 @@ type
MenuItem30: TMenuItem;
MenuItem31: TMenuItem;
MenuItem32: TMenuItem;
MenuItem33: TMenuItem;
MenuItem34: TMenuItem;
MenuItem35: TMenuItem;
MenuItem36: TMenuItem;
MenuItem37: TMenuItem;
MenuItem38: TMenuItem;
MnuNumberFormat: TMenuItem;
MnuNFFixed: TMenuItem;
MnuNFFixedTh: TMenuItem;
MnuNFPercentage: TMenuItem;
MnuNFExp: TMenuItem;
MnuNFSci: TMenuItem;
MnuNFGeneral: TMenuItem;
MnuTextRotation: TMenuItem;
MenuItem3: TMenuItem;
MenuItem4: TMenuItem;
@ -115,6 +137,7 @@ type
PageControl1: TPageControl;
Panel1: TPanel;
BordersPopupMenu: TPopupMenu;
NumFormatPopupMenu: TPopupMenu;
SaveDialog1: TSaveDialog;
EdFrozenCols: TSpinEdit;
sWorksheetGrid1: TsWorksheetGrid;
@ -134,7 +157,12 @@ type
ToolButton19: TToolButton;
ToolButton2: TToolButton;
TbBorders: TToolButton;
TbNumFormats: TToolButton;
ToolButton20: TToolButton;
ToolButton21: TToolButton;
ToolButton24: TToolButton;
ToolButton25: TToolButton;
ToolButton26: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
@ -143,10 +171,13 @@ type
ToolButton8: TToolButton;
ToolButton9: TToolButton;
procedure AcBorderExecute(Sender: TObject);
procedure AcCopyFormatExecute(Sender: TObject);
procedure AcEditExecute(Sender: TObject);
procedure AcFontExecute(Sender: TObject);
procedure AcFontStyleExecute(Sender: TObject);
procedure AcHorAlignmentExecute(Sender: TObject);
procedure AcIncDecDecimalsExecute(Sender: TObject);
procedure AcNumFormatExecute(Sender: TObject);
procedure AcOpenExecute(Sender: TObject);
procedure AcQuitExecute(Sender: TObject);
procedure AcSaveAsExecute(Sender: TObject);
@ -167,6 +198,7 @@ type
procedure sWorksheetGrid1Selection(Sender: TObject; aCol, aRow: Integer);
private
{ private declarations }
FCopiedFormat: TCell;
procedure LoadFile(const AFileName: String);
procedure SetupBackgroundColorBox;
procedure UpdateBackgroundColorIndex;
@ -174,6 +206,7 @@ type
procedure UpdateFontSizeIndex;
procedure UpdateFontStyleActions;
procedure UpdateHorAlignmentActions;
procedure UpdateNumFormatActions;
procedure UpdateTextRotationActions;
procedure UpdateVertAlignmentActions;
procedure UpdateWordwraps;
@ -193,6 +226,7 @@ const
HORALIGN_TAG = 100;
VERTALIGN_TAG = 110;
TEXTROT_TAG = 130;
NUMFMT_TAG = 150; // needs 20
LEFT_BORDER_THIN = $0001;
LEFT_BORDER_THICK = $0002;
@ -307,6 +341,25 @@ begin
end;
end;
procedure TForm1.AcCopyFormatExecute(Sender: TObject);
var
cell: PCell;
r, c: Cardinal;
begin
with sWorksheetGrid1 do begin
if Workbook = nil then
exit;
if AcCopyFormat.Checked then begin
r := GetWorksheetRow(Row);
c := GetWorksheetCol(Col);
cell := Worksheet.FindCell(r, c);
if cell <> nil then
FCopiedFormat := cell^;
end;
end;
end;
{ Changes the font of the selected cell by calling a standard font dialog. }
procedure TForm1.AcFontExecute(Sender: TObject);
begin
@ -347,6 +400,47 @@ begin
UpdateHorAlignmentActions;
end;
procedure TForm1.AcIncDecDecimalsExecute(Sender: TObject);
var
cell: PCell;
decs: Byte;
begin
with sWorksheetGrid1 do begin
if Workbook = nil then
exit;
cell := Worksheet.FindCell(GetWorksheetRow(Row), GetWorksheetCol(Col));
if (cell <> nil) then begin
decs := cell^.NumberDecimals;
if (Sender = AcIncDecimals) then
Worksheet.WriteDecimals(cell, decs+1);
if (Sender = AcDecDecimals) and (decs > 0) then
Worksheet.WriteDecimals(cell, decs-1);
end;
end;
end;
procedure TForm1.AcNumFormatExecute(Sender: TObject);
var
nf: TsNumberFormat;
c, r: Cardinal;
begin
if sWorksheetGrid1.Worksheet = nil then
exit;
if TAction(Sender).Checked then
nf := TsNumberFormat(TAction(Sender).Tag - NUMFMT_TAG)
else
nf := nfGeneral;
with sWorksheetGrid1 do begin
c := GetWorksheetCol(Col);
r := GetWorksheetRow(Row);
Worksheet.WriteNumberFormat(r, c, nf);
end;
UpdateNumFormatActions;
end;
procedure TForm1.AcTextRotationExecute(Sender: TObject);
var
text_rot: TsTextRotation;
@ -543,10 +637,19 @@ begin
end;
procedure TForm1.sWorksheetGrid1Selection(Sender: TObject; aCol, aRow: Integer);
var
r, c: Cardinal;
begin
if sWorksheetGrid1.Workbook = nil then
exit;
if AcCopyFormat.Checked then begin
r := sWorksheetGrid1.GetWorksheetRow(ARow);
c := sWorksheetGrid1.GetWorksheetCol(ACol);
sWorksheetGrid1.Worksheet.CopyFormat(@FCopiedFormat, r, c);
AcCopyFormat.Checked := false;
end;
UpdateHorAlignmentActions;
UpdateVertAlignmentActions;
UpdateWordwraps;
@ -555,6 +658,7 @@ begin
UpdateFontNameIndex;
UpdateFontSizeIndex;
UpdateFontStyleActions;
UpdateNumFormatActions;
end;
procedure TForm1.UpdateBackgroundColorIndex;
@ -615,6 +719,30 @@ begin
AcFontStrikeout.Checked := fssStrikeOut in style;
end;
procedure TForm1.UpdateNumFormatActions;
var
i: Integer;
ac: TAction;
nf: TsNumberFormat;
cell: PCell;
r,c: Cardinal;
begin
with sWorksheetGrid1 do begin
r := GetWorksheetRow(Row);
c := GetWorksheetCol(Col);
cell := Worksheet.FindCell(r, c);
if (cell = nil) or (cell^.ContentType <> cctNumber) then
nf := nfGeneral
else
nf := cell^.NumberFormat;
for i:=0 to ActionList1.ActionCount-1 do begin
ac := TAction(ActionList1.Actions[i]);
if (ac.Tag >= NUMFMT_TAG) and (ac.Tag < NUMFMT_TAG + 20) then
ac.Checked := ((ac.Tag - NUMFMT_TAG) = ord(nf));
end;
end;
end;
procedure TForm1.UpdateTextRotationActions;
var
i: Integer;

View File

@ -14,7 +14,7 @@ unit fpspreadsheet;
interface
uses
Classes, SysUtils, fpimage, AVL_Tree, avglvltree, lconvencoding, fpsutils;
Classes, SysUtils, fpimage, AVL_Tree, avglvltree, lconvencoding;
type
TsSpreadsheetFormat = (sfExcel2, sfExcel3, sfExcel4, sfExcel5, sfExcel8,
@ -105,6 +105,9 @@ type
fekOpSUM {Unary sum operation. Note: CANNOT be used for summing sell contents; use fekSUM}
);
TsRelFlag = (rfRelRow, rfRelCol, rfRelRow2, rfRelCol2);
TsRelFlags = set of TsRelFlag;
TsFormulaElement = record
ElementKind: TFEKind;
Row, Row2: Word; // zero-based
@ -292,6 +295,7 @@ type
BoolValue: Boolean;
StatusValue: Byte;
{ Formatting fields }
{ When adding/deleting formatting fields don't forget to update CopyFormat! }
UsedFormattingFields: TsUsedFormattingFields;
FontIndex: Integer;
TextRotation: TsTextRotation;
@ -360,6 +364,7 @@ type
class function CellPosToText(ARow, ACol: Cardinal): string;
{ Data manipulation methods - For Cells }
procedure CopyCell(AFromRow, AFromCol, AToRow, AToCol: Cardinal; AFromWorksheet: TsWorksheet);
procedure CopyFormat(AFormat: PCell; AToRow, AToCol: Cardinal);
function FindCell(ARow, ACol: Cardinal): PCell;
function GetCell(ARow, ACol: Cardinal): PCell;
function GetCellCount: Cardinal;
@ -385,12 +390,14 @@ type
procedure WriteBoolValue(ARow, ACol: Cardinal; AValue: Boolean);
procedure WriteDateTime(ARow, ACol: Cardinal; AValue: TDateTime;
AFormat: TsNumberFormat = nfShortDateTime; AFormatStr: String = '');
procedure WriteDecimals(ARow, ACol: Cardinal; ADecimals: byte); overload;
procedure WriteDecimals(ACell: PCell; ADecimals: Byte); overload;
procedure WriteErrorValue(ARow, ACol: Cardinal; AValue: TErrorValue);
procedure WriteFormula(ARow, ACol: Cardinal; AFormula: TsFormula);
procedure WriteRPNFormula(ARow, ACol: Cardinal; AFormula: TsRPNFormula);
{ Writing of cell attributes }
procedure WriteNumberFormat(ARow, ACol: Cardinal; ANumberFormat: TsNumberFormat;
const AFormatString: String);
const AFormatString: String = '');
function WriteFont(ARow, ACol: Cardinal; const AFontName: String;
AFontSize: Single; AFontStyle: TsFontStyles; AFontColor: TsColor): Integer; overload;
procedure WriteFont(ARow, ACol: Cardinal; AFontIndex: Integer); overload;
@ -694,7 +701,7 @@ procedure MakeLEPalette(APalette: PsPalette; APaletteSize: Integer);
implementation
uses
Math, StrUtils;
Math, StrUtils, fpsutils;
{ Translatable strings }
resourcestring
@ -921,10 +928,21 @@ end;
procedure TsWorksheet.CopyCell(AFromRow, AFromCol, AToRow, AToCol: Cardinal;
AFromWorksheet: TsWorksheet);
var
lSrcCell, lDestCell: PCell;
{
lCurStr: String;
lCurUsedFormatting: TsUsedFormattingFields;
lCurColor: TsColor;
}
begin
lSrcCell := AFromWorksheet.FindCell(AFromRow, AFromCol);
lDestCell := GetCell(AToRow, AToCol);
lDestCell^ := lSrcCell^;
lDestCell^.Row := AToRow;
lDestCell^.Col := AToCol;
ChangedCell(AToRow, AToCol);
ChangedFont(AToRow, AToCol);
{
lCurStr := AFromWorksheet.ReadAsUTF8Text(AFromRow, AFromCol);
lCurUsedFormatting := AFromWorksheet.ReadUsedFormatting(AFromRow, AFromCol);
lCurColor := AFromWorksheet.ReadBackgroundColor(AFromRow, AFromCol);
@ -934,6 +952,34 @@ begin
begin
WriteBackgroundColor(AToRow, AToCol, lCurColor);
end;
}
end;
{@@
Copies all format parameters from the format cell to another cell.
}
procedure TsWorksheet.CopyFormat(AFormat: PCell; AToRow, AToCol: Cardinal);
var
cell: PCell;
begin
if AFormat = nil then
exit;
cell := GetCell(AToRow, AToCol);
cell^.UsedFormattingFields := AFormat^.UsedFormattingFields;
cell^.BackgroundColor := AFormat^.BackgroundColor;
cell^.Border := AFormat^.Border;
cell^.BorderStyles := AFormat^.BorderStyles;
cell^.FontIndex := AFormat^.FontIndex;
cell^.HorAlignment := AFormat^.HorAlignment;
cell^.VertAlignment := AFormat^.VertAlignment;
cell^.TextRotation := AFormat^.TextRotation;
cell^.NumberFormat := AFormat^.NumberFormat;
cell^.NumberFormatStr := AFormat^.NumberFormatStr;
cell^.NumberDecimals := AFormat^.NumberDecimals;
ChangedCell(AToRow, AToCol);
ChangedFont(AToRow, AToCol);
end;
{@@
@ -1354,7 +1400,6 @@ procedure TsWorksheet.WriteNumber(ARow, ACol: Cardinal; ANumber: double;
AFormat: TsNumberFormat = nfGeneral; ADecimals: Word = 2);
var
ACell: PCell;
decs: String;
begin
ACell := GetCell(ARow, ACol);
@ -1364,20 +1409,7 @@ begin
if AFormat <> nfGeneral then begin
Include(ACell^.UsedFormattingFields, uffNumberFormat);
ACell^.NumberFormat := AFormat;
decs := DupeString('0', ADecimals);
if ADecimals > 0 then decs := '.' + decs;
case AFormat of
nfFixed:
ACell^.NumberFormatStr := '0' + decs;
nfFixedTh:
ACell^.NumberFormatStr := '#,##0' + decs;
nfExp:
ACell^.NumberFormatStr := '0' + decs + 'E+00';
nfSci:
ACell^.NumberFormatStr := '##0' + decs + 'E+0';
nfPercentage:
ACell^.NumberFormatStr := '0' + decs + '%';
end;
WriteDecimals(ACell, ADecimals);
end;
ChangedCell(ARow, ACol);
end;
@ -1499,6 +1531,20 @@ begin
ChangedCell(ARow, ACol);
end;
procedure TsWorksheet.WriteDecimals(ARow, ACol: Cardinal; ADecimals: Byte);
begin
WriteDecimals(FindCell(ARow, ACol), ADecimals);
end;
procedure TsWorksheet.WriteDecimals(ACell: PCell; ADecimals: Byte);
begin
if (ACell <> nil) and (ACell^.ContentType = cctNumber) then begin
ACell^.NumberDecimals := ADecimals;
ACell^.NumberFormatStr := BuildNumFormatString(ACell^.NumberFormat, ADecimals);
ChangedCell(ACell^.Row, ACell^.Col);
end;
end;
{@@
Writes a cell with an error.
@ -1544,14 +1590,17 @@ end;
@see TsNumberFormat
}
procedure TsWorksheet.WriteNumberFormat(ARow, ACol: Cardinal;
ANumberFormat: TsNumberFormat; const AFormatString: String);
ANumberFormat: TsNumberFormat; const AFormatString: String = '');
var
ACell: PCell;
begin
ACell := GetCell(ARow, ACol);
Include(ACell^.UsedFormattingFields, uffNumberFormat);
ACell^.NumberFormat := ANumberFormat;
ACell^.NumberFormatStr := AFormatString;
if (AFormatString = '') then
ACell^.NumberFormatStr := BuildNumFormatString(ANumberFormat, ACell^.NumberDecimals)
else
ACell^.NumberFormatStr := AFormatString;
ChangedCell(ARow, ACol);
end;

View File

@ -12,15 +12,12 @@ unit fpsutils;
interface
uses
Classes, SysUtils, StrUtils;
Classes, SysUtils, StrUtils, fpspreadsheet;
// Exported types
type
TsSelectionDirection = (fpsVerticalSelection, fpsHorizontalSelection);
TsRelFlag = (rfRelRow, rfRelCol, rfRelRow2, rfRelCol2);
TsRelFlags = set of TsRelFlag;
const
// Date formatting string for unambiguous date/time display as strings
// Can be used for text output when date/time cell support is not available
@ -71,6 +68,8 @@ function IsDateFormat(s: String; out IsLong: Boolean): Boolean;
function IsTimeFormat(s: String; out isLong, isAMPM, isInterval: Boolean;
out SecDecimals: Word): Boolean;
function BuildNumFormatString(ANumberFormat: TsNumberFormat; ADecimals: Byte): String;
function SciFloat(AValue: Double; ADecimals: Word): String;
//function TimeIntervalToString(AValue: TDateTime; AFormatStr: String): String;
procedure MakeTimeIntervalMask(Src: String; var Dest: String);
@ -732,6 +731,31 @@ begin
end;
end;
{ Builds a number format string from the numberformat code and the count of
decimals. }
function BuildNumFormatString(ANumberFormat: TsNumberFormat;
ADecimals: Byte): String;
var
decs: String;
begin
decs := DupeString('0', ADecimals);
if ADecimals > 0 then decs := '.' + decs;
case ANumberFormat of
nfFixed:
Result := '0' + decs;
nfFixedTh:
Result := '#,##0' + decs;
nfExp:
Result := '0' + decs + 'E+00';
nfSci:
Result := '##0' + decs + 'E+0';
nfPercentage:
Result := '0' + decs + '%';
else
Result := '';
end;
end;
{ Formats the number AValue in "scientific" format with the given number of
decimals. "Scientific" is the same as "exponential", but with exponents rounded
to multiples of 3 (like for "kilo" - "Mega" - "Giga" etc.). }

View File

@ -561,7 +561,7 @@ begin
AddFormat(45, nfFmtDateTime, 'nn:ss');
AddFormat(46, nfTimeInterval, '[h]:nn:ss');
AddFormat(47, nfFmtDateTime, 'nn:ss.z'); // z will be replace by 0 later
AddFormat(48, nfSci, '##0.0E+0', 1);
AddFormat(48, nfSci, '##0.0E+00', 1);
// 49 ("Text") not supported
// All indexes from 0 to 163 are reserved for built-in formats.
@ -579,13 +579,17 @@ var
fmt: String;
begin
fmt := Lowercase(AFormatString);
{ Check the built-in formats first }
{ Check the built-in formats first:
The prefix "[$-F400]" before the formatting string means that the system's
long Time format string is used. }
if (pos('[$-F400]', AFormatString) = 1) then begin
ANumFormat := nfLongTime;
AFormatString := ''; // will be replaced by system's format setting
ADecimals := 0;
exit;
end;
{ Excel often has the locale ID [$-409] (for Germany) in front of the format
string. We currently ignore this because it confuses fpc. }
if (pos('[$', fmt) = 1) then begin
if (pos('h:mm:ss\', fmt) > 0) then begin
// long time format