You've already forked lazarus-ccr
fpspreadsheet: Initial version of fpspreadsheet controls, a set of visual controls to facilitate creation of a spreadsheet application.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3701 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
BIN
components/fpspreadsheet/examples/fpsctrls/demo_ctrls.ico
Normal file
BIN
components/fpspreadsheet/examples/fpsctrls/demo_ctrls.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 134 KiB |
114
components/fpspreadsheet/examples/fpsctrls/demo_ctrls.lpi
Normal file
114
components/fpspreadsheet/examples/fpsctrls/demo_ctrls.lpi
Normal file
@ -0,0 +1,114 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="demo_ctrls"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="2">
|
||||
<Item1 Name="Debug" Default="True"/>
|
||||
<Item2 Name="Release">
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
</SearchPaths>
|
||||
<CodeGeneration>
|
||||
<SmartLinkUnit Value="True"/>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<StripSymbols Value="True"/>
|
||||
</Debugging>
|
||||
<LinkSmart Value="True"/>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
</Item2>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="laz_fpspreadsheet_visual"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="demo_ctrls.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="main.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="main"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="demo_ctrls"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<CodeGeneration>
|
||||
<SmartLinkUnit Value="True"/>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<DebugInfoType Value="dsDwarf2Set"/>
|
||||
</Debugging>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
21
components/fpspreadsheet/examples/fpsctrls/demo_ctrls.lpr
Normal file
21
components/fpspreadsheet/examples/fpsctrls/demo_ctrls.lpr
Normal file
@ -0,0 +1,21 @@
|
||||
program demo_ctrls;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, main
|
||||
{ you can add units after this };
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
RequireDerivedFormResource := True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
198
components/fpspreadsheet/examples/fpsctrls/main.lfm
Normal file
198
components/fpspreadsheet/examples/fpsctrls/main.lfm
Normal file
@ -0,0 +1,198 @@
|
||||
object Form1: TForm1
|
||||
Left = 349
|
||||
Height = 600
|
||||
Top = 117
|
||||
Width = 925
|
||||
Caption = 'Form1'
|
||||
ClientHeight = 600
|
||||
ClientWidth = 925
|
||||
LCLVersion = '1.3'
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Height = 42
|
||||
Top = 0
|
||||
Width = 925
|
||||
Align = alTop
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 42
|
||||
ClientWidth = 925
|
||||
TabOrder = 0
|
||||
object Button1: TButton
|
||||
Left = 8
|
||||
Height = 25
|
||||
Top = 8
|
||||
Width = 75
|
||||
Caption = 'Open...'
|
||||
OnClick = Button1Click
|
||||
TabOrder = 0
|
||||
end
|
||||
object CellIndicator: TsCellIndicator
|
||||
Left = 95
|
||||
Height = 28
|
||||
Top = 9
|
||||
Width = 80
|
||||
TabOrder = 1
|
||||
Text = 'A1'
|
||||
WorkbookSource = WorkbookSource
|
||||
end
|
||||
object CellEdit: TsCellEdit
|
||||
Left = 184
|
||||
Height = 28
|
||||
Top = 9
|
||||
Width = 731
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
TabOrder = 2
|
||||
WantReturns = False
|
||||
WorkbookSource = WorkbookSource
|
||||
end
|
||||
end
|
||||
object WorkbookTabControl: TsWorkbookTabControl
|
||||
Left = 0
|
||||
Height = 558
|
||||
Top = 42
|
||||
Width = 672
|
||||
TabIndex = 0
|
||||
Tabs.Strings = (
|
||||
'Sheet1'
|
||||
)
|
||||
Align = alClient
|
||||
TabOrder = 1
|
||||
WorkbookSource = WorkbookSource
|
||||
object WorksheetGrid: TsWorksheetGrid
|
||||
Left = 2
|
||||
Height = 528
|
||||
Top = 28
|
||||
Width = 668
|
||||
FrozenCols = 0
|
||||
FrozenRows = 0
|
||||
ReadFormulas = False
|
||||
WorkbookSource = WorkbookSource
|
||||
Align = alClient
|
||||
AutoAdvance = aaDown
|
||||
ColCount = 27
|
||||
Font.Color = clBlack
|
||||
Font.Height = -13
|
||||
Font.Name = 'Arial'
|
||||
ParentFont = False
|
||||
RowCount = 101
|
||||
TabOrder = 1
|
||||
TitleFont.Color = clBlack
|
||||
TitleFont.Height = -13
|
||||
TitleFont.Name = 'Arial'
|
||||
ColWidths = (
|
||||
50
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
64
|
||||
)
|
||||
end
|
||||
end
|
||||
object InspectorTabControl: TTabControl
|
||||
Left = 677
|
||||
Height = 558
|
||||
Top = 42
|
||||
Width = 248
|
||||
OnChange = InspectorTabControlChange
|
||||
TabIndex = 0
|
||||
Tabs.Strings = (
|
||||
'Workbook'
|
||||
'Worksheet'
|
||||
'Cell values'
|
||||
'Cell properties'
|
||||
)
|
||||
Align = alRight
|
||||
TabOrder = 2
|
||||
object Inspector: TsSpreadsheetInspector
|
||||
Left = 2
|
||||
Height = 528
|
||||
Top = 28
|
||||
Width = 244
|
||||
Align = alClient
|
||||
RowCount = 24
|
||||
TabOrder = 1
|
||||
Strings.Strings = (
|
||||
'FileName='
|
||||
'FileFormat=sfExcel8'
|
||||
'Options='
|
||||
'FormatSettings='
|
||||
' ThousandSeparator=.'
|
||||
' DecimalSeparator=,'
|
||||
' ListSeparator=;'
|
||||
' DateSeparator=.'
|
||||
' TimeSeparator=:'
|
||||
' ShortDateFormat=dd.MM.yy'
|
||||
' LongDateFormat=dd.MMM.yyyy'
|
||||
' ShortTimeFormat=hh:nn'
|
||||
' LongTimeFormat=hh:nn:ss'
|
||||
' TimeAMString='
|
||||
' TimePMString='
|
||||
' ShortMonthNames=Jan, Feb, Mrz, Apr, Mai, Jun, Jul, Aug, Sep, Okt, Nov, Dez'
|
||||
' LongMontNames=Januar, Februar, März, April, Mai, Juni, Juli, August, September, Oktober, November, Dezember'
|
||||
' ShortMonthNames=So, Mo, Di, Mi, Do, Fr, Sa'
|
||||
' LongMontNames=Sonntag, Montag, Dienstag, Mittwoch, Donnerstag, Freitag, Samstag'
|
||||
' CurrencyString=€'
|
||||
' PosCurrencyFormat=3'
|
||||
' NegCurrencyFormat=8'
|
||||
' TwoDigitYearCenturyWindow=50'
|
||||
)
|
||||
TitleCaptions.Strings = (
|
||||
'Properties'
|
||||
'Values'
|
||||
)
|
||||
WorkbookSource = WorkbookSource
|
||||
Mode = imWorkbook
|
||||
ColWidths = (
|
||||
109
|
||||
110
|
||||
)
|
||||
end
|
||||
end
|
||||
object Splitter1: TSplitter
|
||||
Left = 672
|
||||
Height = 558
|
||||
Top = 42
|
||||
Width = 5
|
||||
Align = alRight
|
||||
ResizeAnchor = akRight
|
||||
end
|
||||
object WorkbookSource: TsWorkbookSource
|
||||
AutoDetectFormat = False
|
||||
Options = [boAutoCalc, boCalcBeforeSaving, boReadFormulas]
|
||||
left = 150
|
||||
top = 234
|
||||
end
|
||||
object OpenDialog: TOpenDialog
|
||||
DefaultExt = '.xls'
|
||||
Filter = 'All spreadsheet files|*.xls;*.xlsx;*.ods;*.csv|All Excel files (*.xls, *.xlsx)|*.xls;*.xlsx|Excel XML spreadsheet (*.xlsx)|*.xlsx|Excel 97-2003 spreadsheets (*.xls)|*.xls|Excel 5 spreadsheet (*.xls)|*.xls|Excel 2.1 spreadsheets (*.xls)|*.xls|LibreOffice/OpenOffice spreadsheet (*.ods)|*.ods|Comma-delimited files (*.csv)|*.csv'
|
||||
Options = [ofExtensionDifferent, ofEnableSizing, ofViewDetail]
|
||||
left = 312
|
||||
top = 128
|
||||
end
|
||||
object ActionList1: TActionList
|
||||
left = 434
|
||||
top = 180
|
||||
end
|
||||
end
|
71
components/fpspreadsheet/examples/fpsctrls/main.pas
Normal file
71
components/fpspreadsheet/examples/fpsctrls/main.pas
Normal file
@ -0,0 +1,71 @@
|
||||
unit main;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
|
||||
StdCtrls, ComCtrls, ActnList,
|
||||
fpspreadsheet, fpspreadsheetctrls, fpspreadsheetgrid;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
ActionList1: TActionList;
|
||||
Button1: TButton;
|
||||
OpenDialog: TOpenDialog;
|
||||
OpenDialog1: TOpenDialog;
|
||||
Panel1: TPanel;
|
||||
CellEdit: TsCellEdit;
|
||||
CellIndicator: TsCellIndicator;
|
||||
Splitter1: TSplitter;
|
||||
Inspector: TsSpreadsheetInspector;
|
||||
InspectorTabControl: TTabControl;
|
||||
WorkbookSource: TsWorkbookSource;
|
||||
WorkbookTabControl: TsWorkbookTabControl;
|
||||
WorksheetGrid: TsWorksheetGrid;
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure InspectorTabControlChange(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
public
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.Button1Click(Sender: TObject);
|
||||
begin
|
||||
if OpenDialog.Execute then begin
|
||||
WorkbookSource.AutodetectFormat := false;
|
||||
case OpenDialog.FilterIndex of
|
||||
1: WorkbookSource.AutoDetectFormat := true; // All spreadsheet files
|
||||
2: WorkbookSource.AutoDetectFormat := true; // All Excel files
|
||||
3: WorkbookSource.FileFormat := sfOOXML; // Excel 2007+
|
||||
4: WorkbookSource.FileFormat := sfExcel8; // Excel 97-2003
|
||||
5: WorkbookSource.FileFormat := sfExcel5; // Excel 5.0
|
||||
6: WorkbookSource.FileFormat := sfExcel2; // Excel 2.1
|
||||
7: WorkbookSource.FileFormat := sfOpenDocument; // Open/LibreOffice
|
||||
8: WorkbookSource.FileFormat := sfCSV; // Text files
|
||||
end;
|
||||
WorkbookSource.FileName := OpenDialog.FileName; // this loads the file
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.InspectorTabControlChange(Sender: TObject);
|
||||
begin
|
||||
Inspector.Mode := TsInspectorMode(InspectorTabControl.TabIndex);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 134 KiB |
@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="demo_ctrls"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="demo_ctrls.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="main.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="main"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="demo_ctrls"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<OtherUnitFiles Value="..\.."/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerMessages>
|
||||
<IgnoredMessages idx11031="True" idx11030="True"/>
|
||||
</CompilerMessages>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
@ -0,0 +1,20 @@
|
||||
program demo_ctrls;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, main;
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
RequireDerivedFormResource := True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
182
components/fpspreadsheet/examples/fpsctrls_no_install/main.lfm
Normal file
182
components/fpspreadsheet/examples/fpsctrls_no_install/main.lfm
Normal file
@ -0,0 +1,182 @@
|
||||
object Form1: TForm1
|
||||
Left = 361
|
||||
Height = 528
|
||||
Top = 177
|
||||
Width = 874
|
||||
Caption = 'Form1'
|
||||
ClientHeight = 528
|
||||
ClientWidth = 874
|
||||
OnCreate = FormCreate
|
||||
LCLVersion = '1.3'
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Height = 74
|
||||
Top = 0
|
||||
Width = 874
|
||||
Align = alTop
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 74
|
||||
ClientWidth = 874
|
||||
TabOrder = 0
|
||||
object BtnLoad: TButton
|
||||
Left = 280
|
||||
Height = 25
|
||||
Top = 9
|
||||
Width = 75
|
||||
Caption = 'Load...'
|
||||
OnClick = BtnLoadClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object SpeedButton1: TSpeedButton
|
||||
Left = 8
|
||||
Height = 22
|
||||
Hint = 'Add worksheet'
|
||||
Top = 38
|
||||
Width = 23
|
||||
Glyph.Data = {
|
||||
36040000424D3604000000000000360000002800000010000000100000000100
|
||||
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000E8D
|
||||
000003600000036000000360000003600000035F0099025D00CC025D00CC035F
|
||||
0099036000000360000003600000036000000E8D0000FFFFFF00FFFFFF000E8D
|
||||
00000C830000066D0000066D0000066D0000066D00CC22D811FF22D811FF066D
|
||||
00CC066D0000066D0000066D00000C8300000E8D0000FFFFFF00FFFFFF000E8D
|
||||
00000E8C00000D8800000A7D00000A7D00000A7D00CC23CD12FF22CC11FF0A7D
|
||||
00CC0A7D00000A7D00000D8800000E8C00000E8D0000FFFFFF00FFFFFF000E8D
|
||||
00000E8C00000E8C00000E8A00000C8400000C8400CC25C014FF24C013FF0C84
|
||||
00CC0C8400000E8A00000E8C00000E8C00000E8D0000FFFFFF00FFFFFF000E8D
|
||||
00000E8C00000E8C00000E8C00000E8B00000D8900CC29B618FF27B416FF0D89
|
||||
00CC0E8B00000E8C00000E8C00000E8C00000E8D0000FFFFFF00FFFFFF000E8E
|
||||
00990E8D00CC0E8D00CC0E8D00CC0E8D00CC0E8D00CC2DAE1CFF2BAC1AFF0E8D
|
||||
00CC0E8D00CC0E8D00CC0E8D00CC0E8D00CC0E8E0099FFFFFF00FFFFFF000F92
|
||||
00CC59D048FF50C73FFF50C73FFF4FC63EFF4AC139FF3BB32AFF31A920FF31A9
|
||||
20FF2CA51BFF2BA31AFF2DA51CFF33AB22FF0F9200CCFFFFFF00FFFFFF001096
|
||||
00CC5ED54DFF55CC44FF54CB43FF53CA42FF52C941FF4BC23AFF4AC139FF4FC6
|
||||
3EFF4EC53DFF4DC43CFF4CC33BFF4EC53DFF109600CCFFFFFF00FFFFFF00119A
|
||||
0099119A00CC119A00CC119A00CC119A00CC119A00CC54CB43FF52C941FF119A
|
||||
00CC119A00CC119A00CC119A00CC119A00CC119A0099FFFFFF00FFFFFF00119A
|
||||
0000119B0000119B0000119B0000129C0000129E00CC5AD149FF59D048FF129E
|
||||
00CC129C0000119B0000119B0000119B0000119A0000FFFFFF00FFFFFF00119A
|
||||
0000119B0000119B0000129D000013A2000013A200CC62D951FF61D850FF13A2
|
||||
00CC13A20000129D0000119B0000119B0000119A0000FFFFFF00FFFFFF00119A
|
||||
0000119B0000129E000014A5000014A5000014A500CC69E058FF69E058FF14A5
|
||||
00CC14A5000014A50000129E0000119B0000119A0000FFFFFF00FFFFFF00119A
|
||||
0000129F000014A8000014A8000014A8000014A800CC72E961FF71E860FF14A8
|
||||
00CC14A8000014A8000014A80000129F0000119A0000FFFFFF00FFFFFF003B7F
|
||||
320015A9000015A9000015A9000015A9000015AA009915AA00CC15AA00CC15AA
|
||||
009915A9000015A9000015A9000015A90000119A0000FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
|
||||
}
|
||||
OnClick = SpeedButton1Click
|
||||
end
|
||||
object SpeedButton2: TSpeedButton
|
||||
Left = 36
|
||||
Height = 22
|
||||
Hint = 'Delete worksheet'
|
||||
Top = 38
|
||||
Width = 23
|
||||
Glyph.Data = {
|
||||
36040000424D3604000000000000360000002800000010000000100000000100
|
||||
2000000000000004000064000000640000000000000000000000FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000
|
||||
7E99000078CC000078CC000078CC000078CC000078CC000078CC000078CC0000
|
||||
78CC000078CC000078CC000078CC000078CC00007E99FFFFFF00FFFFFF000000
|
||||
8FCC5F5FE7FF5252DAFF4C4CD4FF4646CEFF4141C9FF3E3EC6FF3D3DC5FF3C3C
|
||||
C4FF3B3BC3FF3A3AC2FF3939C1FF3A3AC2FF00008FCCFFFFFF00FFFFFF000000
|
||||
9ECC6666EEFF5B5BE3FF5555DDFF4F4FD7FF4A4AD2FF4545CDFF4343CBFF4141
|
||||
C9FF4040C8FF3F3FC7FF3E3EC6FF4040C8FF00009ECCFFFFFF00FFFFFF000000
|
||||
A7990000A8CC0000A8CC0000A8CC0000A8CC0000A8CC0000A8CC0000A8CC0000
|
||||
A8CC0000A8CC0000A8CC0000A8CC0000A8CC0000A799FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
|
||||
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00
|
||||
}
|
||||
OnClick = SpeedButton2Click
|
||||
end
|
||||
object SpeedButton3: TSpeedButton
|
||||
Left = 64
|
||||
Height = 22
|
||||
Top = 38
|
||||
Width = 96
|
||||
Caption = 'Sheet name'
|
||||
OnClick = SpeedButton3Click
|
||||
end
|
||||
object CbLoader: TComboBox
|
||||
Left = 104
|
||||
Height = 28
|
||||
Top = 8
|
||||
Width = 148
|
||||
ItemHeight = 20
|
||||
ItemIndex = 0
|
||||
Items.Strings = (
|
||||
'Workbook'
|
||||
'WorkbookSource'
|
||||
'WorksheetGrid'
|
||||
)
|
||||
Style = csDropDownList
|
||||
TabOrder = 1
|
||||
Text = 'Workbook'
|
||||
end
|
||||
object Label1: TLabel
|
||||
Left = 13
|
||||
Height = 20
|
||||
Top = 11
|
||||
Width = 73
|
||||
Caption = 'Loaded by:'
|
||||
ParentColor = False
|
||||
end
|
||||
end
|
||||
object InspectorTabControl: TTabControl
|
||||
Left = 577
|
||||
Height = 454
|
||||
Top = 74
|
||||
Width = 297
|
||||
OnChange = InspectorTabControlChange
|
||||
TabIndex = 0
|
||||
Tabs.Strings = (
|
||||
'Workbook'
|
||||
'Worksheet'
|
||||
'Cell values'
|
||||
'Properties'
|
||||
)
|
||||
Align = alRight
|
||||
TabOrder = 1
|
||||
end
|
||||
object Splitter1: TSplitter
|
||||
Left = 572
|
||||
Height = 454
|
||||
Top = 74
|
||||
Width = 5
|
||||
Align = alRight
|
||||
ResizeAnchor = akRight
|
||||
end
|
||||
object OpenDialog: TOpenDialog
|
||||
DefaultExt = '.xls'
|
||||
Filter = 'All spreadsheet files|*.xls;*.xlsx;*.ods;*.csv|All Excel files (*.xls, *.xlsx)|*.xls;*.xlsx|Excel XML spreadsheet (*.xlsx)|*.xlsx|Excel 97-2003 spreadsheets (*.xls)|*.xls|Excel 5 spreadsheet (*.xls)|*.xls|Excel 2.1 spreadsheets (*.xls)|*.xls|LibreOffice/OpenOffice spreadsheet (*.ods)|*.ods|Comma-delimited files (*.csv)|*.csv|Wikitable (pipes) (.wikitable_pipes)|*.wikitable_pipes'
|
||||
Options = [ofExtensionDifferent, ofEnableSizing, ofViewDetail]
|
||||
left = 48
|
||||
top = 80
|
||||
end
|
||||
end
|
178
components/fpspreadsheet/examples/fpsctrls_no_install/main.pas
Normal file
178
components/fpspreadsheet/examples/fpsctrls_no_install/main.pas
Normal file
@ -0,0 +1,178 @@
|
||||
unit main;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, ComCtrls, ExtCtrls, Grids, Buttons,
|
||||
fpspreadsheet, fpspreadsheetctrls, fpSpreadsheetGrid;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
BtnLoad: TButton;
|
||||
CbLoader: TComboBox;
|
||||
Label1: TLabel;
|
||||
OpenDialog: TOpenDialog;
|
||||
Panel1: TPanel;
|
||||
SpeedButton1: TSpeedButton;
|
||||
SpeedButton2: TSpeedButton;
|
||||
SpeedButton3: TSpeedButton;
|
||||
Splitter1: TSplitter;
|
||||
InspectorTabControl: TTabControl;
|
||||
procedure BtnLoadClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure InspectorTabControlChange(Sender: TObject);
|
||||
procedure SpeedButton1Click(Sender: TObject);
|
||||
procedure SpeedButton2Click(Sender: TObject);
|
||||
procedure SpeedButton3Click(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
WorkbookSource: TsWorkbookSource;
|
||||
WorkbookTabControl: TsWorkbookTabControl;
|
||||
WorksheetGrid: TsWorksheetGrid;
|
||||
CellIndicator: TsCellIndicator;
|
||||
CellEdit: TsCellEdit;
|
||||
Inspector: TsSpreadsheetInspector;
|
||||
public
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.BtnLoadClick(Sender: TObject);
|
||||
begin
|
||||
if OpenDialog.Execute then begin
|
||||
WorkbookSource.AutodetectFormat := false;
|
||||
case OpenDialog.FilterIndex of
|
||||
1: WorkbookSource.AutoDetectFormat := true; // All spreadsheet files
|
||||
2: WorkbookSource.AutoDetectFormat := true; // All Excel files
|
||||
3: WorkbookSource.FileFormat := sfOOXML; // Excel 2007+
|
||||
4: WorkbookSource.FileFormat := sfExcel8; // Excel 97-2003
|
||||
5: WorkbookSource.FileFormat := sfExcel5; // Excel 5.0
|
||||
6: WorkbookSource.FileFormat := sfExcel2; // Excel 2.1
|
||||
7: WorkbookSource.FileFormat := sfOpenDocument; // Open/LibreOffice
|
||||
8: WOrkbookSource.FileFormat := sfCSV; // Text files
|
||||
9: WorkbookSource.FileFormat := sfWikiTable_WikiMedia; // wiki tables
|
||||
end;
|
||||
|
||||
// There are 3 possibilities to open a file:
|
||||
case CbLoader.ItemIndex of
|
||||
0: if WorkbookSource.AutodetectFormat then
|
||||
WorkbookSource.Workbook.ReadFromFile(OpenDialog.FileName)
|
||||
else
|
||||
WorkbookSource.Workbook.ReadFromFile(OpenDialog.Filename, WorkbookSource.FileFormat);
|
||||
1: WorkbookSource.FileName := OpenDialog.FileName; // this loads the file
|
||||
2: if WorkbookSource.AutodetectFormat then
|
||||
WorksheetGrid.LoadFromSpreadsheetFile(OpenDialog.FileName)
|
||||
else
|
||||
WorksheetGrid.LoadFromSpreadsheetFile(OpenDialog.FileName, WorkbookSource.FileFormat);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
WorkbookSource := TsWorkbookSource.Create(self);
|
||||
with WorkbookSource do begin
|
||||
Options := [boReadFormulas, boAutoCalc];
|
||||
end;
|
||||
|
||||
WorkbookTabControl := TsWorkbookTabControl.Create(self);
|
||||
with WorkbookTabControl do
|
||||
begin
|
||||
Parent := self;
|
||||
Align := alClient;
|
||||
WorkbookSource := Self.WorkbookSource;
|
||||
end;
|
||||
|
||||
WorksheetGrid := TsWorksheetGrid.Create(self);
|
||||
with WorksheetGrid do
|
||||
begin
|
||||
Parent := WorkbookTabControl;
|
||||
Align := alClient;
|
||||
Options := Options + [goEditing];
|
||||
TextOverflow := true;
|
||||
WorkbookSource := Self.WorkbookSource;
|
||||
end;
|
||||
|
||||
CellIndicator := TsCellIndicator.Create(self);
|
||||
with CellIndicator do begin
|
||||
Parent := Panel1;
|
||||
Left := BtnLoad.Left + BtnLoad.Width + 24;
|
||||
Top := BtnLoad.Top;
|
||||
WorkbookSource := Self.WorkbookSource;
|
||||
end;
|
||||
|
||||
CellEdit := TsCellEdit.Create(self);
|
||||
with CellEdit do begin
|
||||
Parent := Panel1;
|
||||
Left := CellIndicator.Left + CellIndicator.Width + 24;
|
||||
Top := CellIndicator.Top;
|
||||
WorkbookSource := Self.WorkbookSource;
|
||||
end;
|
||||
|
||||
Inspector := TsSpreadsheetInspector.Create(self);
|
||||
with Inspector do begin
|
||||
Parent := InspectorTabControl;
|
||||
Align := alClient;
|
||||
WorkbookSource := Self.WorkbookSource;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.InspectorTabControlChange(Sender: TObject);
|
||||
begin
|
||||
Inspector.Mode := TsInspectorMode(InspectorTabControl.TabIndex);
|
||||
end;
|
||||
|
||||
procedure TForm1.SpeedButton1Click(Sender: TObject);
|
||||
var
|
||||
sheetname: String;
|
||||
i: Integer;
|
||||
begin
|
||||
i := WorkbookSource.Workbook.GetWorksheetCount;
|
||||
repeat
|
||||
inc(i);
|
||||
sheetName := Format('Sheet %d', [i]);
|
||||
until (WorkbookSource.Workbook.GetWorksheetByName(sheetname) = nil);
|
||||
WorkbookSource.Workbook.AddWorksheet(sheetName);
|
||||
end;
|
||||
|
||||
procedure TForm1.SpeedButton2Click(Sender: TObject);
|
||||
begin
|
||||
if WorkbookSource.Workbook.GetWorksheetCount = 1 then
|
||||
MessageDlg('There must be a least 1 worksheet.', mtError, [mbOK], 0)
|
||||
else
|
||||
if MessageDlg('Do you really want to delete this worksheet?', mtConfirmation,
|
||||
[mbYes, mbNo], 0) = mrYes
|
||||
then
|
||||
WorkbookSource.Workbook.RemoveWorksheet(WorkbookSource.SelectedWorksheet);
|
||||
end;
|
||||
|
||||
procedure TForm1.SpeedButton3Click(Sender: TObject);
|
||||
var
|
||||
s: String;
|
||||
begin
|
||||
s := WorkbookSource.SelectedWorksheet.Name;
|
||||
if InputQuery('Edit worksheet name', 'New name', s) then
|
||||
begin
|
||||
if WorkbookSource.Workbook.ValidWorksheetName(s) then
|
||||
WorkbookSource.SelectedWorksheet.Name := s
|
||||
else
|
||||
MessageDlg('Invalid worksheet name.', mtError, [mbOK], 0);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -94,7 +94,8 @@ function LineEndingAsString(ALineEnding: TsCSVLineEnding): String;
|
||||
implementation
|
||||
|
||||
uses
|
||||
StrUtils, DateUtils, LConvEncoding, Math, fpsutils, fpscurrency;
|
||||
//StrUtils,
|
||||
DateUtils, LConvEncoding, Math, fpsutils, fpscurrency;
|
||||
|
||||
{ Initializes the FormatSettings of the CSVParams to default values which
|
||||
can be replaced by the FormatSettings of the workbook's FormatSettings }
|
||||
@ -439,7 +440,6 @@ procedure TsCSVReader.ReadFromStream(AStream: TStream; AData: TsWorkbook);
|
||||
var
|
||||
Parser: TCSVParser;
|
||||
s: String;
|
||||
i: Integer;
|
||||
encoding: String;
|
||||
begin
|
||||
// Try to determine encoding of the input file
|
||||
@ -452,7 +452,7 @@ begin
|
||||
|
||||
// Store workbook for internal use, and create worksheet
|
||||
FWorkbook := AData;
|
||||
FWorksheet := AData.AddWorksheet(FWorksheetName);
|
||||
FWorksheet := AData.AddWorksheet(FWorksheetName, true);
|
||||
|
||||
// Create csv parser, read file and store in worksheet
|
||||
Parser := TCSVParser.Create;
|
||||
|
@ -141,7 +141,7 @@ end;
|
||||
function TryStrToCurrency(AText: String; out ANumber: Double;
|
||||
out ACurrencySymbol:String; const AFormatSettings: TFormatSettings): boolean;
|
||||
var
|
||||
i, p: Integer;
|
||||
i: Integer;
|
||||
s: String;
|
||||
isNeg: Boolean;
|
||||
begin
|
||||
|
@ -1442,7 +1442,7 @@ begin
|
||||
TableNode := TableNode.NextSibling;
|
||||
continue;
|
||||
end;
|
||||
FWorkSheet := aData.AddWorksheet(GetAttrValue(TableNode,'table:name'));
|
||||
FWorkSheet := aData.AddWorksheet(GetAttrValue(TableNode,'table:name'), true);
|
||||
// Collect column styles used
|
||||
ReadColumns(TableNode);
|
||||
// Process each row inside the sheet and process each cell of the row
|
||||
@ -2010,8 +2010,11 @@ begin
|
||||
ReadDateTime(row, col, cellNode)
|
||||
else if (paramValueType = 'boolean') then
|
||||
ReadBoolean(row, col, cellNode)
|
||||
else if (paramValueType = '') and (tableStyleName <> '') then
|
||||
else if (paramValueType = '') then //and (tableStyleName <> '') then
|
||||
ReadBlank(row, col, cellNode);
|
||||
{$Warning TODO: Check if the removal of "tableStyleName" here does not
|
||||
create unnecessary empty cells. The ReadBlank should only be executed
|
||||
if the cell contains formatting! }
|
||||
|
||||
if ParamFormula <> '' then
|
||||
ReadFormula(row, col, cellNode);
|
||||
|
@ -493,7 +493,7 @@ type
|
||||
{ TsWorksheet }
|
||||
|
||||
{@@ This event fires whenever a cell value or cell formatting changes. It is
|
||||
handled by TsWorksheetGrid to update the grid. }
|
||||
handled by TsWorkbookLink to update the listening controls. }
|
||||
TsCellEvent = procedure (Sender: TObject; ARow, ACol: Cardinal) of object;
|
||||
|
||||
{@@ This event can be used to override the built-in comparing function which
|
||||
@ -506,9 +506,12 @@ type
|
||||
TsWorksheet = class
|
||||
private
|
||||
FWorkbook: TsWorkbook;
|
||||
FName: String; // Name of the worksheet (displayed at the tab)
|
||||
FCells: TAvlTree; // Items are TCell
|
||||
FCurrentNode: TAVLTreeNode; // For GetFirstCell and GetNextCell
|
||||
FRows, FCols: TIndexedAVLTree; // This lists contain only rows or cols with styles different from default
|
||||
FSelectedCellRow: Cardinal;
|
||||
FSelectedCellCol: Cardinal;
|
||||
FLeftPaneWidth: Integer;
|
||||
FTopPaneHeight: Integer;
|
||||
FOptions: TsSheetOptions;
|
||||
@ -522,9 +525,11 @@ type
|
||||
FOnChangeCell: TsCellEvent;
|
||||
FOnChangeFont: TsCellEvent;
|
||||
FOnCompareCells: TsCellCompareEvent;
|
||||
FOnSelectCell: TsCellEvent;
|
||||
|
||||
{ Setter/Getter }
|
||||
function GetFormatSettings: TFormatSettings;
|
||||
procedure SetName(const AName: String);
|
||||
|
||||
{ Callback procedures called when iterating through all cells }
|
||||
procedure CalcFormulaCallback(data, arg: Pointer);
|
||||
@ -555,10 +560,6 @@ type
|
||||
AFromIndex, AToIndex: Cardinal);
|
||||
|
||||
public
|
||||
{@@ Name of the sheet. In the popular spreadsheet applications this is
|
||||
displayed at the tab of the sheet. }
|
||||
Name: string;
|
||||
|
||||
{ Base methods }
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
@ -793,6 +794,9 @@ type
|
||||
ARowFrom, AColFrom, ARowTo, AColTo: Cardinal); overload;
|
||||
procedure Sort(ASortParams: TsSortParams; ARange: String); overload;
|
||||
|
||||
// Selected cell
|
||||
procedure SelectCell(ARow, ACol: Cardinal);
|
||||
|
||||
{ Properties }
|
||||
|
||||
{@@ List of cells of the worksheet. Only cells with contents or with formatting
|
||||
@ -802,6 +806,9 @@ type
|
||||
property Cols: TIndexedAVLTree read FCols;
|
||||
{@@ FormatSettings for localization of some formatting strings }
|
||||
property FormatSettings: TFormatSettings read GetFormatSettings;
|
||||
{@@ Name of the sheet. In the popular spreadsheet applications this is
|
||||
displayed at the tab of the sheet. }
|
||||
property Name: string read FName write SetName;
|
||||
{@@ List of all row records of the worksheet having a non-standard row height }
|
||||
property Rows: TIndexedAVLTree read FRows;
|
||||
{@@ Workbook to which the worksheet belongs }
|
||||
@ -817,6 +824,10 @@ type
|
||||
{@@ Parameters controlling visibility of grid lines and row/column headers,
|
||||
usage of frozen panes etc. }
|
||||
property Options: TsSheetOptions read FOptions write FOptions;
|
||||
{@@ Column index of the selected cell of this worksheet }
|
||||
property SelectedCellCol: Cardinal read FSelectedCellCol;
|
||||
{@@ Row index of the selected cell of this worksheet }
|
||||
property SelectedCellRow: Cardinal read FSelectedCellRow;
|
||||
{@@ Number of frozen columns which do not scroll }
|
||||
property LeftPaneWidth: Integer read FLeftPaneWidth write FLeftPaneWidth;
|
||||
{@@ Number of frozen rows which do not scroll }
|
||||
@ -827,6 +838,9 @@ type
|
||||
property OnChangeFont: TsCellEvent read FOnChangeFont write FOnChangeFont;
|
||||
{@@ Event to override cell comparison for sorting }
|
||||
property OnCompareCells: TsCellCompareEvent read FOnCompareCells write FOnCompareCells;
|
||||
{@@ Event fired when a cell is "selected". }
|
||||
property OnSelectCell: TsCellEvent read FOnSelectCell write FOnSelectCell;
|
||||
|
||||
end;
|
||||
|
||||
{@@
|
||||
@ -853,8 +867,7 @@ type
|
||||
TsWorkbookOption = (boVirtualMode, boBufStream, boAutoCalc, boCalcBeforeSaving,
|
||||
boReadFormulas);
|
||||
|
||||
{@@
|
||||
Set of options flags for the workbook }
|
||||
{@@ Set of option flags for the workbook }
|
||||
TsWorkbookOptions = set of TsWorkbookOption;
|
||||
|
||||
{@@
|
||||
@ -870,6 +883,12 @@ type
|
||||
TsWorkbookReadCellDataEvent = procedure(Sender: TObject; ARow, ACol: Cardinal;
|
||||
const ADataCell: PCell) of object;
|
||||
|
||||
{@@ Event procedure containing a specific worksheet }
|
||||
TsWorksheetEvent = procedure (Sender: TObject; ASheet: TsWorksheet) of object;
|
||||
|
||||
{@@ Event procedure called when a worksheet is removed }
|
||||
TsRemoveWorksheetEvent = procedure (Sender: TObject; ASheetIndex: Integer) of object;
|
||||
|
||||
{@@
|
||||
The workbook contains the worksheets and provides methods for reading from
|
||||
and writing to file.
|
||||
@ -890,6 +909,9 @@ type
|
||||
FOptions: TsWorkbookOptions;
|
||||
FOnWriteCellData: TsWorkbookWriteCellDataEvent;
|
||||
FOnReadCellData: TsWorkbookReadCellDataEvent;
|
||||
FOnChangeWorksheet: TsWorksheetEvent;
|
||||
FOnAddWorksheet: TsWorksheetEvent;
|
||||
FOnRemoveWorksheet: TsRemoveWorksheetEvent;
|
||||
FFileName: String;
|
||||
FLog: TStringList;
|
||||
|
||||
@ -898,13 +920,16 @@ type
|
||||
procedure SetVirtualColCount(AValue: Cardinal);
|
||||
procedure SetVirtualRowCount(AValue: Cardinal);
|
||||
|
||||
{ Callback procedures }
|
||||
procedure RemoveWorksheetsCallback(data, arg: pointer);
|
||||
|
||||
protected
|
||||
{ Internal methods }
|
||||
procedure FixSharedFormulas;
|
||||
procedure GetLastRowColIndex(out ALastRow, ALastCol: Cardinal);
|
||||
procedure PrepareBeforeReading;
|
||||
procedure PrepareBeforeSaving;
|
||||
procedure ReCalc;
|
||||
procedure RemoveWorksheetsCallback(data, arg: pointer);
|
||||
procedure UpdateCaches;
|
||||
|
||||
public
|
||||
@ -930,13 +955,17 @@ type
|
||||
procedure WriteToStream(AStream: TStream; AFormat: TsSpreadsheetFormat);
|
||||
|
||||
{ Worksheet list handling methods }
|
||||
function AddWorksheet(AName: string; AcceptEmptyName: boolean = false): TsWorksheet;
|
||||
function AddWorksheet(AName: string;
|
||||
ReplaceDuplicateName: Boolean = false): TsWorksheet;
|
||||
function GetFirstWorksheet: TsWorksheet;
|
||||
function GetWorksheetByIndex(AIndex: Integer): TsWorksheet;
|
||||
function GetWorksheetByName(AName: String): TsWorksheet;
|
||||
function GetWorksheetCount: Integer;
|
||||
function GetWorksheetIndex(AWorksheet: TsWorksheet): Integer;
|
||||
procedure RemoveAllWorksheets;
|
||||
function ValidWorksheetName(AName: String; AcceptEmptyName: Boolean = false): Boolean;
|
||||
procedure RemoveWorksheet(AWorksheet: TsWorksheet);
|
||||
function ValidWorksheetName(var AName: String;
|
||||
ReplaceDuplicateName: Boolean = false): Boolean;
|
||||
|
||||
{ Font handling }
|
||||
function AddFont(const AFontName: String; ASize: Single;
|
||||
@ -988,6 +1017,12 @@ type
|
||||
property VirtualColCount: cardinal read FVirtualColCount write SetVirtualColCount;
|
||||
property VirtualRowCount: cardinal read FVirtualRowCount write SetVirtualRowCount;
|
||||
property Options: TsWorkbookOptions read FOptions write FOptions;
|
||||
{@@ This event fires whenever a new worksheet is added }
|
||||
property OnAddWorksheet: TsWorksheetEvent read FOnAddWorksheet write FOnAddWorksheet;
|
||||
{@@ This event fires whenever a worksheet is changed }
|
||||
property OnChangeWorksheet: TsWorksheetEvent read FOnChangeWorksheet write FOnChangeWorksheet;
|
||||
{@@ This event fires when a worksheet is deleted }
|
||||
property OnRemoveWorksheet: TsRemoveWorksheetEvent read FOnRemoveWorksheet write FOnRemoveWorksheet;
|
||||
{@@ This event allows to provide external cell data for writing to file,
|
||||
standard cells are ignored. Intended for converting large database files
|
||||
to a spreadsheet format. Requires Option boVirtualMode to be set. }
|
||||
@ -1494,12 +1529,12 @@ end;
|
||||
|
||||
function CompareRows(Item1, Item2: Pointer): Integer;
|
||||
begin
|
||||
result := LongInt(PRow(Item1).Row) - PRow(Item2).Row;
|
||||
Result := LongInt(PRow(Item1).Row) - PRow(Item2).Row;
|
||||
end;
|
||||
|
||||
function CompareCols(Item1, Item2: Pointer): Integer;
|
||||
begin
|
||||
result := LongInt(PCol(Item1).Col) - PCol(Item2).Col;
|
||||
Result := LongInt(PCol(Item1).Col) - PCol(Item2).Col;
|
||||
end;
|
||||
|
||||
|
||||
@ -1531,6 +1566,9 @@ end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Destructor of the TsWorksheet class.
|
||||
Releases all memory, but does not delete from the workbook's worksheetList !!!
|
||||
NOTE: Don't call directly. Always use Workbook.RemoveWorksheet to remove a
|
||||
worksheet from a workbook.
|
||||
-------------------------------------------------------------------------------}
|
||||
destructor TsWorksheet.Destroy;
|
||||
begin
|
||||
@ -3207,6 +3245,22 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Setter for the worksheet name property. Checks if the name is valid, and
|
||||
exits without any change if not. Creates an event OnChangeWorksheet.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorksheet.SetName(const AName: String);
|
||||
begin
|
||||
if AName = FName then
|
||||
exit;
|
||||
if (FWorkbook <> nil) then //and FWorkbook.ValidWorksheetName(AName) then
|
||||
begin
|
||||
FName := AName;
|
||||
if Assigned(FWorkbook.FOnChangeWorksheet) then
|
||||
FWorkbook.FOnChangeWorksheet(FWorkbook, self);
|
||||
end;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Compare function for sorting of rows and columns called directly by Sort()
|
||||
The compare algorithm starts with the first key parameters. If cells are
|
||||
@ -3465,6 +3519,19 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Marks a specified cell as "selected". Only needed by the visual controls.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorksheet.SelectCell(ARow, ACol: Cardinal);
|
||||
begin
|
||||
if (ARow <> FSelectedCellRow) or (ACol <> FSelectedCellCol) then
|
||||
begin
|
||||
FSelectedCellRow := ARow;
|
||||
FSelectedCellCol := ACol;
|
||||
if Assigned(FOnSelectCell) then FOnSelectCell(Self, ARow, ACol);
|
||||
end;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Helper method to update internal caching variables
|
||||
-------------------------------------------------------------------------------}
|
||||
@ -6366,27 +6433,29 @@ begin
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Adds a new worksheet to the workbook
|
||||
Adds a new worksheet to the workbook.
|
||||
It is put to the end of the worksheet list.
|
||||
|
||||
It is added to the end of the list of worksheets
|
||||
|
||||
@param AName The name of the new worksheet
|
||||
@param AcceptEmptyName Allow an empty worksheet name (for Excel2)
|
||||
@param AName The name of the new worksheet
|
||||
@param ReplaceDupliateName If true and the sheet name already exists then
|
||||
a number is added to the sheet name to make it
|
||||
unique.
|
||||
@return The instance of the newly created worksheet
|
||||
@see TsWorksheet
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorkbook.AddWorksheet(AName: string;
|
||||
AcceptEmptyName: Boolean = false): TsWorksheet;
|
||||
ReplaceDuplicateName: Boolean = false): TsWorksheet;
|
||||
begin
|
||||
if not ValidWorksheetName(AName, AcceptEmptyName) then
|
||||
if not ValidWorksheetName(AName, ReplaceDuplicateName) then
|
||||
raise Exception.CreateFmt(rsInvalidWorksheetName, [AName]);
|
||||
|
||||
Result := TsWorksheet.Create;
|
||||
|
||||
Result.FWorkbook := Self; // Must be before "SetName" needing the workbook
|
||||
Result.Name := AName;
|
||||
Result.FWorkbook := Self;
|
||||
|
||||
FWorksheets.Add(Pointer(Result));
|
||||
|
||||
if Assigned(FOnAddWorksheet) then FOnAddWorksheet(self, Result);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
@ -6431,7 +6500,6 @@ end;
|
||||
Gets the worksheet with a given worksheet name
|
||||
|
||||
@param AName The name of the worksheet
|
||||
|
||||
@return A TsWorksheet instance if one is found with that name,
|
||||
nil otherwise. Case is ignored.
|
||||
|
||||
@ -6464,35 +6532,74 @@ begin
|
||||
Result := FWorksheets.Count;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Returns the index of a worksheet in the worksheet list
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorkbook.GetWorksheetIndex(AWorksheet: TsWorksheet): Integer;
|
||||
begin
|
||||
Result := FWorksheets.IndexOf(AWorksheet);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Clears the list of Worksheets and releases their memory.
|
||||
|
||||
NOTE: This procedure conflicts with the WorkbookLink mechanism which requires
|
||||
at least 1 worksheet per workbook!
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorkbook.RemoveAllWorksheets;
|
||||
begin
|
||||
FWorksheets.ForEachCall(RemoveWorksheetsCallback, nil);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Removes the specified worksheet: Removes the sheet from the internal sheet
|
||||
list, generates an event OnRemoveWorksheet, and releases all memory.
|
||||
The event handler specifies the index of the deleted worksheet; the worksheet
|
||||
itself does no longer exist.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorkbook.RemoveWorksheet(AWorksheet: TsWorksheet);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
if GetWorksheetCount > 1 then // There must be at least 1 worksheet!
|
||||
begin
|
||||
i := GetWorksheetIndex(AWorksheet);
|
||||
if (i <> -1) and (AWorksheet <> nil) then
|
||||
begin
|
||||
FWorksheets.Delete(i);
|
||||
AWorksheet.Free;
|
||||
if Assigned(FOnRemoveWorksheet) then
|
||||
FOnRemoveWorksheet(self, i);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Checks whether the passed string is a valid worksheet name according to Excel
|
||||
(ODS seems to be a bit less restrictive, but if we follow Excel's convention
|
||||
we always have valid sheet names independent of the format.
|
||||
|
||||
@param AName Name to be checked
|
||||
@param AcceptEmptyName Accepts an empty name (for Excel2)
|
||||
@param AName Name to be checked. If the input name is already
|
||||
used AName will be modified such that the sheet
|
||||
name is unique.
|
||||
@param ReplaceDuplicateName If there exists already a sheet name equal to
|
||||
AName then a number is added to AName such that
|
||||
the name is unique.
|
||||
@return TRUE if it is a valid worksheet name, FALSE otherwise
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorkbook.ValidWorksheetName(AName: String;
|
||||
AcceptEmptyName: Boolean = false): Boolean;
|
||||
function TsWorkbook.ValidWorksheetName(var AName: String;
|
||||
ReplaceDuplicateName: Boolean = false): Boolean;
|
||||
// see: http://stackoverflow.com/questions/451452/valid-characters-for-excel-sheet-names
|
||||
var
|
||||
INVALID_CHARS: array [0..6] of char = ('[', ']', ':', '*', '?', '/', '\');
|
||||
var
|
||||
i: Integer;
|
||||
unique: Boolean;
|
||||
begin
|
||||
Result := false;
|
||||
|
||||
// Name must not be empty
|
||||
if (AName = '') and (not AcceptEmptyName) then
|
||||
if (AName = '') then
|
||||
exit;
|
||||
|
||||
// Length must be less than 31 characters
|
||||
@ -6505,8 +6612,20 @@ begin
|
||||
exit;
|
||||
|
||||
// Name must be unique
|
||||
if GetWorksheetByName(AName) <> nil then
|
||||
exit;
|
||||
unique := (GetWorksheetByName(AName) = nil);
|
||||
if not unique then
|
||||
begin
|
||||
if ReplaceDuplicateName then
|
||||
begin
|
||||
i := 0;
|
||||
repeat
|
||||
inc(i);
|
||||
unique := (GetWorksheetByName(AName + IntToStr(i)) = nil);
|
||||
until unique;
|
||||
AName := AName + IntToStr(i);
|
||||
end else
|
||||
exit;
|
||||
end;
|
||||
|
||||
Result := true;
|
||||
end;
|
||||
|
@ -77,7 +77,7 @@ implementation
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterComponents('Chart',[TsWorksheetChartSource]);
|
||||
RegisterComponents('Chart', [TsWorksheetChartSource]);
|
||||
end;
|
||||
|
||||
{ TsWorksheetChartSource }
|
||||
|
1322
components/fpspreadsheet/fpspreadsheetctrls.pas
Normal file
1322
components/fpspreadsheet/fpspreadsheetctrls.pas
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -2390,7 +2390,7 @@ var
|
||||
i: Integer;
|
||||
begin
|
||||
Result.SortByCols := ASortByCols;
|
||||
Result.Priority := spNumAlpha; // numbers before text, like in Excel
|
||||
Result.Priority := ASortPriority;
|
||||
SetLength(Result.Keys, ANumSortKeys);
|
||||
for i:=0 to High(Result.Keys) do begin
|
||||
Result.Keys[i].ColRowIndex := i;
|
||||
|
@ -8,11 +8,11 @@
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<SearchPaths>
|
||||
<OtherUnitFiles Value="."/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Other>
|
||||
<CustomOptions Value="$(IDEBuildOptions)"/>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Description Value="laz_fpspreadsheet_visual is a visual component that allows you to use the fpspreadsheet package to read/write spreadsheet files in .xls (BIFF/Excel), .ods OpenDocument (LibreOffice/OpenOffice) and .xlsx Open XML (Excel) formats.
|
||||
@ -20,17 +20,22 @@
|
||||
It provides graphical components like a grid and chart."/>
|
||||
<License Value="LGPL with static linking exception. This is the same license as is used in the LCL (Lazarus Component Library)."/>
|
||||
<Version Major="1" Minor="2"/>
|
||||
<Files Count="2">
|
||||
<Files Count="3">
|
||||
<Item1>
|
||||
<Filename Value="fpspreadsheetgrid.pas"/>
|
||||
<Filename Value="fpspreadsheetctrls.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="FPSpreadsheetGrid"/>
|
||||
<UnitName Value="fpspreadsheetctrls"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Filename Value="fpspreadsheetgrid.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="fpspreadsheetgrid"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Filename Value="fpspreadsheetchart.pas"/>
|
||||
<HasRegisterProc Value="True"/>
|
||||
<UnitName Value="fpspreadsheetchart"/>
|
||||
</Item2>
|
||||
</Item3>
|
||||
</Files>
|
||||
<Type Value="RunAndDesignTime"/>
|
||||
<RequiredPkgs Count="4">
|
||||
|
@ -2,21 +2,22 @@
|
||||
This source is only used to compile and install the package.
|
||||
}
|
||||
|
||||
unit laz_fpspreadsheet_visual;
|
||||
unit laz_fpspreadsheet_visual;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
fpspreadsheetgrid, fpspreadsheetchart, LazarusPackageIntf;
|
||||
fpspreadsheetctrls, fpspreadsheetgrid, fpspreadsheetchart, LazarusPackageIntf;
|
||||
|
||||
implementation
|
||||
|
||||
procedure Register;
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterUnit('fpspreadsheetgrid', @fpspreadsheetgrid.Register);
|
||||
RegisterUnit('fpspreadsheetchart', @fpspreadsheetchart.Register);
|
||||
end;
|
||||
RegisterUnit('fpspreadsheetctrls', @fpspreadsheetctrls.Register);
|
||||
RegisterUnit('fpspreadsheetgrid', @fpspreadsheetgrid.Register);
|
||||
RegisterUnit('fpspreadsheetchart', @fpspreadsheetchart.Register);
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterPackage('laz_fpspreadsheet_visual', @Register);
|
||||
RegisterPackage('laz_fpspreadsheet_visual', @Register);
|
||||
end.
|
||||
|
@ -309,7 +309,7 @@ var
|
||||
lLineSplitter: TWikiTableTokenizer;
|
||||
lCurToken: TWikiTableToken;
|
||||
begin
|
||||
FWorksheet := AData.AddWorksheet('Table');
|
||||
FWorksheet := AData.AddWorksheet('Table', true);
|
||||
lLineSplitter := TWikiTableTokenizer.Create(AData);
|
||||
try
|
||||
for i := 0 to AStrings.Count-1 do
|
||||
|
@ -564,7 +564,7 @@ begin
|
||||
BIFF2EOF := False;
|
||||
|
||||
{ In BIFF2 files there is only one worksheet, let's create it }
|
||||
FWorksheet := AData.AddWorksheet('', true); // true --> accept empty sheet name
|
||||
FWorksheet := AData.AddWorksheet('Sheet', true);
|
||||
|
||||
{ Read all records in a loop }
|
||||
while not BIFF2EOF do
|
||||
|
@ -1128,7 +1128,7 @@ var
|
||||
RecordType: Word;
|
||||
CurStreamPos: Int64;
|
||||
begin
|
||||
FWorksheet := AData.AddWorksheet(FWorksheetNames.Strings[FCurrentWorksheet]);
|
||||
FWorksheet := AData.AddWorksheet(FWorksheetNames[FCurrentWorksheet], true);
|
||||
|
||||
while (not SectionEOF) do
|
||||
begin
|
||||
|
@ -1428,7 +1428,7 @@ var
|
||||
RecordType: Word;
|
||||
CurStreamPos: Int64;
|
||||
begin
|
||||
FWorksheet := AData.AddWorksheet(FWorksheetNames.Strings[FCurrentWorksheet]);
|
||||
FWorksheet := AData.AddWorksheet(FWorksheetNames[FCurrentWorksheet], true);
|
||||
|
||||
while (not SectionEOF) do
|
||||
begin
|
||||
|
@ -1489,7 +1489,7 @@ begin
|
||||
ReadXMLFile(Doc, FilePath + fn);
|
||||
DeleteFile(FilePath + fn);
|
||||
|
||||
FWorksheet := AData.AddWorksheet(SheetList[i]);
|
||||
FWorksheet := AData.AddWorksheet(SheetList[i], true);
|
||||
|
||||
ReadSheetViews(Doc.DocumentElement.FindNode('sheetViews'), FWorksheet);
|
||||
ReadSheetFormatPr(Doc.DocumentElement.FindNode('sheetFormatPr'), FWorksheet);
|
||||
|
Reference in New Issue
Block a user