Improves FPSpreadsheet examples and improves the Grid component

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1229 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
sekelsenmat
2010-05-25 09:11:02 +00:00
parent 3ac6af427e
commit 06ae369ff5
13 changed files with 352 additions and 34 deletions

View File

@@ -4,6 +4,7 @@
<Version Value="7"/>
<General>
<Flags>
<AlwaysBuild Value="False"/>
<UseDefaultCompilerOptions Value="True"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
@@ -72,6 +73,9 @@
</SyntaxOptions>
</Parsing>
<Linking>
<Debugging>
<GenerateDebugInfo Value="True"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
@@ -79,6 +83,9 @@
</Options>
</Linking>
<Other>
<CompilerMessages>
<UseMsgFile Value="True"/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>

View File

@@ -13,7 +13,6 @@ uses
{$R *.res}
begin
Application.Title:='project1';
Application.Initialize;
Application.CreateForm(TFPSChartForm, FPSChartForm);
Application.Run;

View File

@@ -1,16 +1,17 @@
object FPSChartForm: TFPSChartForm
Left = 179
Height = 331
Top = 157
Width = 742
Left = 239
Height = 382
Top = 154
Width = 700
Caption = 'FPSpreadsheet Chart Example'
ClientHeight = 331
ClientWidth = 742
ClientHeight = 382
ClientWidth = 700
OnCreate = FormCreate
LCLVersion = '0.9.29'
object MyChart: TChart
Left = 400
Left = 352
Height = 240
Top = 24
Top = 136
Width = 336
AxisList = <
item
@@ -37,26 +38,106 @@ object FPSChartForm: TFPSChartForm
object WorksheetGrid: TsWorksheetGrid
Left = 16
Height = 240
Top = 24
Width = 360
Top = 136
Width = 328
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll]
TabOrder = 1
end
object btnCreateGraphic: TButton
Left = 104
Left = 464
Height = 25
Top = 280
Top = 56
Width = 128
Caption = 'Create Graphic'
OnClick = btnCreateGraphicClick
TabOrder = 2
end
object Label1: TLabel
Left = 16
Height = 34
Top = 8
Width = 676
AutoSize = False
Caption = 'Please add data to the grid or load it from a file, then choose the location of the data for the X and Y axises and click on the button "Create Graphic" to generate a chart.'
ParentColor = False
WordWrap = True
end
object editSourceFile: TFileNameEdit
Left = 152
Height = 22
Top = 48
Width = 136
DialogOptions = []
FilterIndex = 0
HideDirectories = False
ButtonWidth = 23
NumGlyphs = 0
MaxLength = 0
TabOrder = 3
end
object Label2: TLabel
Left = 14
Height = 18
Top = 51
Width = 130
Caption = 'Source Spreadsheet:'
ParentColor = False
end
object btnLoadSpreadsheet: TButton
Left = 320
Height = 25
Top = 48
Width = 75
Caption = 'Load'
OnClick = btnLoadSpreadsheetClick
TabOrder = 4
end
object editXAxis: TLabeledEdit
Left = 64
Height = 22
Top = 80
Width = 80
EditLabel.AnchorSideLeft.Control = editXAxis
EditLabel.AnchorSideTop.Control = editXAxis
EditLabel.AnchorSideTop.Side = asrCenter
EditLabel.AnchorSideRight.Control = editXAxis
EditLabel.AnchorSideBottom.Control = editXAxis
EditLabel.Left = 17
EditLabel.Height = 18
EditLabel.Top = 82
EditLabel.Width = 44
EditLabel.Caption = 'X-Axis:'
EditLabel.ParentColor = False
LabelPosition = lpLeft
TabOrder = 5
Text = 'A1:A5'
end
object EditYAxis: TLabeledEdit
Left = 208
Height = 22
Top = 80
Width = 80
EditLabel.AnchorSideLeft.Control = EditYAxis
EditLabel.AnchorSideTop.Control = EditYAxis
EditLabel.AnchorSideTop.Side = asrCenter
EditLabel.AnchorSideRight.Control = EditYAxis
EditLabel.AnchorSideBottom.Control = EditYAxis
EditLabel.Left = 161
EditLabel.Height = 18
EditLabel.Top = 82
EditLabel.Width = 44
EditLabel.Caption = 'Y-Axis:'
EditLabel.ParentColor = False
LabelPosition = lpLeft
TabOrder = 6
Text = 'B1:B5'
end
object FPSChartSource: TsWorksheetChartSource
PointsNumber = 5
YFirstCellCol = 1
XSelectionDirection = fpsVerticalSelection
YSelectionDirection = fpsVerticalSelection
left = 376
top = 264
left = 632
top = 56
end
end

View File

@@ -6,7 +6,8 @@ interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Grids, fpspreadsheetchart, fpspreadsheetgrid, TAGraph, TASeries;
StdCtrls, Grids, EditBtn, ExtCtrls, fpspreadsheetchart, fpspreadsheetgrid,
TAGraph, TASeries;
type
@@ -14,11 +15,19 @@ type
TFPSChartForm = class(TForm)
btnCreateGraphic: TButton;
btnLoadSpreadsheet: TButton;
editSourceFile: TFileNameEdit;
Label1: TLabel;
Label2: TLabel;
editXAxis: TLabeledEdit;
EditYAxis: TLabeledEdit;
MyChart: TChart;
FPSChartSource: TsWorksheetChartSource;
MyChartLineSeries: TLineSeries;
WorksheetGrid: TsWorksheetGrid;
procedure btnCreateGraphicClick(Sender: TObject);
procedure btnLoadSpreadsheetClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
@@ -30,14 +39,40 @@ var
implementation
uses
// FPSpreadsheet and supported formats
fpspreadsheet, xlsbiff8, xlsbiff5, xlsbiff2, xlsxooxml, fpsopendocument;
{$R *.lfm}
{ TFPSChartForm }
procedure TFPSChartForm.btnCreateGraphicClick(Sender: TObject);
begin
FPSChartSource.LoadPropertiesFromStrings(editXAxis.Text, editYAxis.Text, '', '', '');
FPSChartSource.LoadFromWorksheetGrid(WorksheetGrid);
end;
procedure TFPSChartForm.btnLoadSpreadsheetClick(Sender: TObject);
var
Format: TsSpreadsheetFormat;
lExt: string;
begin
// First some logic to detect the format from the extension
lExt := ExtractFileExt(editSourceFile.Text);
if lExt = STR_EXCEL_EXTENSION then Format := sfExcel2
else if lExt = STR_OOXML_EXCEL_EXTENSION then Format := sfOOXML
else if lExt = STR_OPENDOCUMENT_CALC_EXTENSION then Format := sfOpenDocument
else raise Exception.Create('Invalid File Extension');
// Now the actual loading
WorksheetGrid.LoadFromSpreadsheetFile(editSourceFile.Text, Format);
end;
procedure TFPSChartForm.FormCreate(Sender: TObject);
begin
editSourceFile.InitialDir := ExtractFilePath(ParamStr(0));
end;
end.

Binary file not shown.

Binary file not shown.