You've already forked lazarus-ccr
lazspreadsheet: Adds a new example which can show an entire spreadsheet file
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2603 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
8
applications/lazspreadsheet/about.lfm
Normal file
8
applications/lazspreadsheet/about.lfm
Normal file
@ -0,0 +1,8 @@
|
||||
object Form1: TForm1
|
||||
Left = 232
|
||||
Height = 240
|
||||
Top = 158
|
||||
Width = 320
|
||||
Caption = 'Form1'
|
||||
LCLVersion = '1.1'
|
||||
end
|
26
applications/lazspreadsheet/about.pas
Normal file
26
applications/lazspreadsheet/about.pas
Normal file
@ -0,0 +1,26 @@
|
||||
unit about;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs;
|
||||
|
||||
type
|
||||
TForm1 = class(TForm)
|
||||
private
|
||||
{ private declarations }
|
||||
public
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
end.
|
||||
|
101
applications/lazspreadsheet/lazspreadsheet.lpi
Normal file
101
applications/lazspreadsheet/lazspreadsheet.lpi
Normal file
@ -0,0 +1,101 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<General>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="lazspreadsheet"/>
|
||||
<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"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
<LaunchingApplication PathPlusParams="/usr/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="2">
|
||||
<Item1>
|
||||
<PackageName Value="laz_fpspreadsheet_visual"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="3">
|
||||
<Unit0>
|
||||
<Filename Value="lazspreadsheet.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="lazspreadsheet"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="../../components/fpspreadsheet/examples/lazspreadsheet/about.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="about"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="../../components/fpspreadsheet/examples/lazspreadsheet/mainform.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="lazfpsmainform"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="mainform"/>
|
||||
</Unit2>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<Target>
|
||||
<Filename Value="lazspreadsheet"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerMessages>
|
||||
<MsgFileName Value=""/>
|
||||
</CompilerMessages>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
22
applications/lazspreadsheet/lazspreadsheet.lpr
Normal file
22
applications/lazspreadsheet/lazspreadsheet.lpr
Normal file
@ -0,0 +1,22 @@
|
||||
program lazspreadsheet;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, about, mainform, laz_fpspreadsheet_visual
|
||||
{ you can add units after this };
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
RequireDerivedFormResource := True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(Tlazfpsmainform, lazfpsmainform);
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
BIN
applications/lazspreadsheet/lazspreadsheet.res
Normal file
BIN
applications/lazspreadsheet/lazspreadsheet.res
Normal file
Binary file not shown.
59
applications/lazspreadsheet/mainform.lfm
Normal file
59
applications/lazspreadsheet/mainform.lfm
Normal file
@ -0,0 +1,59 @@
|
||||
object lazfpsmainform: Tlazfpsmainform
|
||||
Left = 234
|
||||
Height = 401
|
||||
Top = 170
|
||||
Width = 700
|
||||
Caption = 'FPSpreadsheet Chart Example'
|
||||
ClientHeight = 401
|
||||
ClientWidth = 700
|
||||
OnCreate = FormCreate
|
||||
LCLVersion = '1.1'
|
||||
object pagesSheets: TPageControl
|
||||
Left = 0
|
||||
Height = 343
|
||||
Top = 58
|
||||
Width = 700
|
||||
Align = alClient
|
||||
TabOrder = 0
|
||||
end
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Height = 58
|
||||
Top = 0
|
||||
Width = 700
|
||||
Align = alTop
|
||||
ClientHeight = 58
|
||||
ClientWidth = 700
|
||||
TabOrder = 1
|
||||
object btnLoadSpreadsheet: TButton
|
||||
Left = 312
|
||||
Height = 25
|
||||
Top = 24
|
||||
Width = 75
|
||||
Caption = 'Load'
|
||||
OnClick = btnLoadSpreadsheetClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object editSourceFile: TFileNameEdit
|
||||
Left = 146
|
||||
Height = 21
|
||||
Top = 24
|
||||
Width = 136
|
||||
DialogOptions = []
|
||||
FilterIndex = 0
|
||||
HideDirectories = False
|
||||
ButtonWidth = 23
|
||||
NumGlyphs = 1
|
||||
MaxLength = 0
|
||||
TabOrder = 1
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 8
|
||||
Height = 15
|
||||
Top = 30
|
||||
Width = 116
|
||||
Caption = 'Source Spreadsheet:'
|
||||
ParentColor = False
|
||||
end
|
||||
end
|
||||
end
|
99
applications/lazspreadsheet/mainform.pas
Normal file
99
applications/lazspreadsheet/mainform.pas
Normal file
@ -0,0 +1,99 @@
|
||||
unit mainform;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, Grids, EditBtn, ExtCtrls, ComCtrls, fpspreadsheetchart,
|
||||
fpspreadsheetgrid, TAGraph, TASeries;
|
||||
|
||||
type
|
||||
|
||||
{ Tlazfpsmainform }
|
||||
|
||||
Tlazfpsmainform = class(TForm)
|
||||
btnLoadSpreadsheet: TButton;
|
||||
editSourceFile: TFileNameEdit;
|
||||
Label2: TLabel;
|
||||
pagesSheets: TPageControl;
|
||||
Panel1: TPanel;
|
||||
procedure btnLoadSpreadsheetClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
public
|
||||
{ public declarations }
|
||||
Worksheets: array of TsWorksheetGrid;
|
||||
procedure DeleteAllSheets();
|
||||
end;
|
||||
|
||||
var
|
||||
lazfpsmainform: Tlazfpsmainform;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
// FPSpreadsheet and supported formats
|
||||
fpspreadsheet, xlsbiff8, xlsbiff5, xlsbiff2, xlsxooxml, fpsopendocument;
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ Tlazfpsmainform }
|
||||
|
||||
procedure Tlazfpsmainform.btnLoadSpreadsheetClick(Sender: TObject);
|
||||
var
|
||||
lWorkbook: TsWorkbook;
|
||||
lWorksheetCount: Cardinal;
|
||||
lCurPage: TTabSheet;
|
||||
lCurWorksheet: TsWorksheet;
|
||||
i: Integer;
|
||||
begin
|
||||
if editSourceFile.Text = '' then Exit;
|
||||
|
||||
lWorkbook := TsWorkbook.Create;
|
||||
try
|
||||
lWorkbook.ReadFromFile(editSourceFile.Text);
|
||||
|
||||
DeleteAllSheets();
|
||||
|
||||
lWorksheetCount := lWorkbook.GetWorksheetCount();
|
||||
SetLength(Worksheets, lWorksheetCount);
|
||||
for i := 0 to lWorksheetCount-1 do
|
||||
begin
|
||||
pagesSheets.AddTabSheet();
|
||||
lCurPage := pagesSheets.Pages[i];
|
||||
lCurWorksheet := lWorkbook.GetWorksheetByIndex(i);
|
||||
|
||||
Worksheets[i] := TsWorksheetGrid.Create(nil);
|
||||
Worksheets[i].Parent := lCurPage;
|
||||
Worksheets[i].Align := alClient;
|
||||
//Worksheets[i].Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll]
|
||||
Worksheets[i].LoadFromWorksheet(lCurWorksheet);
|
||||
lCurPage.Caption := lCurWorksheet.Name;
|
||||
end;
|
||||
finally
|
||||
lWorkbook.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Tlazfpsmainform.DeleteAllSheets;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i := 0 to Length(Worksheets)-1 do
|
||||
begin
|
||||
Worksheets[i].Free;
|
||||
pagesSheets.Pages[i].Free;
|
||||
end;
|
||||
SetLength(Worksheets, 0);
|
||||
end;
|
||||
|
||||
procedure Tlazfpsmainform.FormCreate(Sender: TObject);
|
||||
begin
|
||||
editSourceFile.InitialDir := ExtractFilePath(ParamStr(0));
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Reference in New Issue
Block a user