diff --git a/applications/lazspreadsheet/about.lfm b/applications/lazspreadsheet/about.lfm new file mode 100644 index 000000000..011398330 --- /dev/null +++ b/applications/lazspreadsheet/about.lfm @@ -0,0 +1,8 @@ +object Form1: TForm1 + Left = 232 + Height = 240 + Top = 158 + Width = 320 + Caption = 'Form1' + LCLVersion = '1.1' +end diff --git a/applications/lazspreadsheet/about.pas b/applications/lazspreadsheet/about.pas new file mode 100644 index 000000000..0cffc7c95 --- /dev/null +++ b/applications/lazspreadsheet/about.pas @@ -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. + diff --git a/applications/lazspreadsheet/lazspreadsheet.lpi b/applications/lazspreadsheet/lazspreadsheet.lpi new file mode 100644 index 000000000..77a313a4d --- /dev/null +++ b/applications/lazspreadsheet/lazspreadsheet.lpi @@ -0,0 +1,101 @@ + + + + + + + + + <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> diff --git a/applications/lazspreadsheet/lazspreadsheet.lpr b/applications/lazspreadsheet/lazspreadsheet.lpr new file mode 100644 index 000000000..f9d731cfe --- /dev/null +++ b/applications/lazspreadsheet/lazspreadsheet.lpr @@ -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. + diff --git a/applications/lazspreadsheet/lazspreadsheet.res b/applications/lazspreadsheet/lazspreadsheet.res new file mode 100644 index 000000000..7c6cf3e4b Binary files /dev/null and b/applications/lazspreadsheet/lazspreadsheet.res differ diff --git a/applications/lazspreadsheet/mainform.lfm b/applications/lazspreadsheet/mainform.lfm new file mode 100644 index 000000000..5e2c2ae39 --- /dev/null +++ b/applications/lazspreadsheet/mainform.lfm @@ -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 diff --git a/applications/lazspreadsheet/mainform.pas b/applications/lazspreadsheet/mainform.pas new file mode 100644 index 000000000..88470ba96 --- /dev/null +++ b/applications/lazspreadsheet/mainform.pas @@ -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. +