You've already forked lazarus-ccr
fpspreadsheet: Add demo "workbookchartsource" to "fpschart" folder. Move previous content of fpschart to subfolder "worksheetchartsource". Fix old fpschart demo to show a reasonable chart.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3877 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1,2 +0,0 @@
|
||||
This demo demonstrates the use of the visual charting component included with
|
||||
fpspreadsheet.
|
Before Width: | Height: | Size: 134 KiB After Width: | Height: | Size: 134 KiB |
@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<Title Value="fpschartsource"/>
|
||||
<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="3">
|
||||
<Item1>
|
||||
<PackageName Value="TAChartLazarusPkg"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="laz_fpspreadsheet_visual"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item3>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="fpschartsource.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="mainform"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="fpschartsource"/>
|
||||
</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>
|
@ -0,0 +1,21 @@
|
||||
program fpschartsource;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, mainform, tachartlazaruspkg
|
||||
{ you can add units after this };
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
RequireDerivedFormResource := True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
@ -0,0 +1,263 @@
|
||||
object Form1: TForm1
|
||||
Left = 354
|
||||
Height = 634
|
||||
Top = 132
|
||||
Width = 875
|
||||
Caption = 'Form1'
|
||||
ClientHeight = 634
|
||||
ClientWidth = 875
|
||||
OnCreate = FormCreate
|
||||
LCLVersion = '1.3'
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Height = 40
|
||||
Top = 0
|
||||
Width = 875
|
||||
Align = alTop
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 40
|
||||
ClientWidth = 875
|
||||
TabOrder = 0
|
||||
object Button1: TButton
|
||||
Left = 8
|
||||
Height = 25
|
||||
Top = 7
|
||||
Width = 91
|
||||
Caption = 'Delete sheet'
|
||||
OnClick = Button1Click
|
||||
TabOrder = 0
|
||||
end
|
||||
object Button2: TButton
|
||||
Left = 107
|
||||
Height = 25
|
||||
Top = 7
|
||||
Width = 93
|
||||
Caption = 'Rename sheet'
|
||||
OnClick = Button2Click
|
||||
TabOrder = 1
|
||||
end
|
||||
object Bevel1: TBevel
|
||||
Left = 0
|
||||
Height = 3
|
||||
Top = 37
|
||||
Width = 875
|
||||
Align = alBottom
|
||||
Shape = bsBottomLine
|
||||
end
|
||||
end
|
||||
object Splitter1: TSplitter
|
||||
Left = 870
|
||||
Height = 594
|
||||
Top = 40
|
||||
Width = 5
|
||||
Align = alRight
|
||||
ResizeAnchor = akRight
|
||||
end
|
||||
object sWorkbookTabControl1: TsWorkbookTabControl
|
||||
Left = 6
|
||||
Height = 582
|
||||
Top = 46
|
||||
Width = 380
|
||||
TabIndex = 0
|
||||
Tabs.Strings = (
|
||||
'Sheet1'
|
||||
)
|
||||
Align = alClient
|
||||
BorderSpacing.Around = 6
|
||||
TabOrder = 2
|
||||
WorkbookSource = sWorkbookSource1
|
||||
object sWorksheetGrid1: TsWorksheetGrid
|
||||
Left = 2
|
||||
Height = 557
|
||||
Top = 23
|
||||
Width = 376
|
||||
FrozenCols = 0
|
||||
FrozenRows = 0
|
||||
ReadFormulas = False
|
||||
WorkbookSource = sWorkbookSource1
|
||||
Align = alClient
|
||||
AutoAdvance = aaDown
|
||||
ColCount = 27
|
||||
Font.Color = clBlack
|
||||
Font.Height = -15
|
||||
Font.Name = 'Calibri'
|
||||
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll]
|
||||
ParentFont = False
|
||||
RowCount = 101
|
||||
TabOrder = 1
|
||||
TitleFont.Color = clBlack
|
||||
TitleFont.Height = -15
|
||||
TitleFont.Name = 'Calibri'
|
||||
ColWidths = (
|
||||
48
|
||||
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 Panel2: TPanel
|
||||
Left = 392
|
||||
Height = 594
|
||||
Top = 40
|
||||
Width = 478
|
||||
Align = alRight
|
||||
BevelOuter = bvNone
|
||||
Caption = 'Panel2'
|
||||
ClientHeight = 594
|
||||
ClientWidth = 478
|
||||
TabOrder = 3
|
||||
object Chart1: TChart
|
||||
Left = 0
|
||||
Height = 183
|
||||
Top = 0
|
||||
Width = 478
|
||||
AxisList = <
|
||||
item
|
||||
Minors = <>
|
||||
Title.LabelFont.Orientation = 900
|
||||
end
|
||||
item
|
||||
Alignment = calBottom
|
||||
Minors = <>
|
||||
end>
|
||||
BackColor = clWhite
|
||||
Foot.Brush.Color = clBtnFace
|
||||
Foot.Font.Color = clBlue
|
||||
Title.Brush.Color = clBtnFace
|
||||
Title.Font.Color = clBlue
|
||||
Title.Text.Strings = (
|
||||
'Chart from 1st sheet'
|
||||
)
|
||||
Title.Visible = True
|
||||
Align = alTop
|
||||
ParentColor = False
|
||||
object Chart1AreaSeries1: TAreaSeries
|
||||
AreaBrush.Color = clSkyBlue
|
||||
AreaLinesPen.Style = psClear
|
||||
Source = sWorkbookChartSource1
|
||||
UseZeroLevel = True
|
||||
end
|
||||
end
|
||||
object Chart2: TChart
|
||||
Left = 0
|
||||
Height = 218
|
||||
Top = 183
|
||||
Width = 478
|
||||
AxisList = <
|
||||
item
|
||||
Minors = <>
|
||||
Title.LabelFont.Orientation = 900
|
||||
end
|
||||
item
|
||||
Alignment = calBottom
|
||||
Minors = <>
|
||||
end>
|
||||
BackColor = clWhite
|
||||
Depth = 10
|
||||
Foot.Brush.Color = clBtnFace
|
||||
Foot.Font.Color = clBlue
|
||||
Title.Brush.Color = clBtnFace
|
||||
Title.Font.Color = clBlue
|
||||
Title.Text.Strings = (
|
||||
'Chart from 2nd sheet'
|
||||
)
|
||||
Title.Visible = True
|
||||
Align = alClient
|
||||
ParentColor = False
|
||||
object Chart2BarSeries1: TBarSeries
|
||||
Marks.Distance = 15
|
||||
Marks.Format = '%0:.2f'
|
||||
Marks.Frame.Color = clOlive
|
||||
Marks.LabelBrush.Color = clCream
|
||||
Marks.LinkPen.Visible = False
|
||||
Marks.Style = smsCustom
|
||||
BarBrush.Color = 9934847
|
||||
Depth = 10
|
||||
Source = sWorkbookChartSource2
|
||||
end
|
||||
end
|
||||
object Chart3: TChart
|
||||
Left = 0
|
||||
Height = 193
|
||||
Top = 401
|
||||
Width = 478
|
||||
AxisList = <
|
||||
item
|
||||
Visible = False
|
||||
Minors = <>
|
||||
Title.LabelFont.Orientation = 900
|
||||
end
|
||||
item
|
||||
Visible = False
|
||||
Alignment = calBottom
|
||||
Minors = <>
|
||||
end>
|
||||
Foot.Brush.Color = clBtnFace
|
||||
Foot.Font.Color = clBlue
|
||||
Frame.Visible = False
|
||||
Legend.Alignment = laCenterRight
|
||||
Legend.Visible = True
|
||||
Title.Brush.Color = clBtnFace
|
||||
Title.Font.Color = clBlue
|
||||
Title.Text.Strings = (
|
||||
'Chart from 3rd sheet'
|
||||
)
|
||||
Title.Visible = True
|
||||
Align = alBottom
|
||||
ParentColor = False
|
||||
object Chart3PieSeries1: TPieSeries
|
||||
Legend.Multiplicity = lmPoint
|
||||
Marks.Distance = 8
|
||||
Marks.Format = '%2:s'
|
||||
Marks.Style = smsLabel
|
||||
Source = sWorkbookChartSource3
|
||||
end
|
||||
end
|
||||
end
|
||||
object sWorkbookSource1: TsWorkbookSource
|
||||
AutoDetectFormat = False
|
||||
FileFormat = sfOOXML
|
||||
Options = []
|
||||
left = 184
|
||||
top = 320
|
||||
end
|
||||
object sWorkbookChartSource1: TsWorkbookChartSource
|
||||
WorkbookSource = sWorkbookSource1
|
||||
left = 640
|
||||
top = 112
|
||||
end
|
||||
object sWorkbookChartSource2: TsWorkbookChartSource
|
||||
WorkbookSource = sWorkbookSource1
|
||||
left = 640
|
||||
top = 320
|
||||
end
|
||||
object sWorkbookChartSource3: TsWorkbookChartSource
|
||||
WorkbookSource = sWorkbookSource1
|
||||
left = 640
|
||||
top = 512
|
||||
end
|
||||
end
|
@ -0,0 +1,91 @@
|
||||
unit mainform;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, TAGraph, TASeries, TASources, Forms, Controls,
|
||||
Graphics, Dialogs, ExtCtrls, EditBtn, StdCtrls,
|
||||
fpspreadsheetctrls, fpspreadsheetgrid, fpspreadsheetchart;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
Bevel1: TBevel;
|
||||
Button1: TButton;
|
||||
Button2: TButton;
|
||||
Chart1: TChart;
|
||||
Chart1AreaSeries1: TAreaSeries;
|
||||
Chart2: TChart;
|
||||
Chart2BarSeries1: TBarSeries;
|
||||
Chart3: TChart;
|
||||
Chart3PieSeries1: TPieSeries;
|
||||
Panel1: TPanel;
|
||||
Panel2: TPanel;
|
||||
Splitter1: TSplitter;
|
||||
sWorkbookChartSource1: TsWorkbookChartSource;
|
||||
sWorkbookChartSource2: TsWorkbookChartSource;
|
||||
sWorkbookChartSource3: TsWorkbookChartSource;
|
||||
sWorkbookSource1: TsWorkbookSource;
|
||||
sWorkbookTabControl1: TsWorkbookTabControl;
|
||||
sWorksheetGrid1: TsWorksheetGrid;
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure Button2Click(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
public
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.Button1Click(Sender: TObject);
|
||||
// The same effect is obtained by using the built-in TsWorksheetDeleteAction.
|
||||
begin
|
||||
if sWorkbookSource1.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
|
||||
sWorkbookSource1.Workbook.RemoveWorksheet(sWorkbookSource1.Worksheet);
|
||||
end;
|
||||
|
||||
procedure TForm1.Button2Click(Sender: TObject);
|
||||
var
|
||||
s: String;
|
||||
begin
|
||||
s := sWorkbookSource1.Worksheet.Name;
|
||||
if InputQuery('Edit worksheet name', 'New name', s) then
|
||||
begin
|
||||
if sWorkbookSource1.Workbook.ValidWorksheetName(s) then
|
||||
sWorkbookSource1.Worksheet.Name := s
|
||||
else
|
||||
MessageDlg('Invalid worksheet name.', mtError, [mbOK], 0);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
sWorkbookSource1.Filename := 'test-data.xlsx';
|
||||
sWorkbookChartSource1.XRange := 'Sheet1!A2:A21';
|
||||
sWorkbookChartSource1.YRange := 'Sheet1!B2:B21';
|
||||
sWorkbookChartSource2.XRange := 'Sheet2!A2:A16';
|
||||
sWorkbookChartSource2.YRange := 'Sheet2!B2:B16';
|
||||
sWorkbookChartSource3.XRange := 'Sheet3!A2:A5';
|
||||
sWorkbookChartSource3.YRange := 'Sheet3!B2:B5';
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -0,0 +1,2 @@
|
||||
This demo shows usage of the TsWorkbookChartSource component for
|
||||
creating charts from spreadsheet data.
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 134 KiB |
@ -66,7 +66,7 @@
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||
<UnitOutputDirectory Value="../../lib/$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Options>
|
@ -10,8 +10,8 @@ object FPSChartForm: TFPSChartForm
|
||||
LCLVersion = '1.3'
|
||||
object MyChart: TChart
|
||||
Left = 352
|
||||
Height = 240
|
||||
Top = 136
|
||||
Height = 264
|
||||
Top = 112
|
||||
Width = 336
|
||||
AxisList = <
|
||||
item
|
||||
@ -20,6 +20,10 @@ object FPSChartForm: TFPSChartForm
|
||||
end
|
||||
item
|
||||
Alignment = calBottom
|
||||
Marks.LabelFont.Orientation = 900
|
||||
Marks.Format = '%2:s'
|
||||
Marks.Source = FPSChartSource
|
||||
Marks.Style = smsLabel
|
||||
Minors = <>
|
||||
end>
|
||||
Foot.Brush.Color = clBtnFace
|
||||
@ -30,27 +34,28 @@ object FPSChartForm: TFPSChartForm
|
||||
'TAChart'
|
||||
)
|
||||
ParentColor = False
|
||||
object MyChartLineSeries: TLineSeries
|
||||
LinePen.Color = clRed
|
||||
object MyChartBarSeries1: TBarSeries
|
||||
BarBrush.Color = clRed
|
||||
Source = FPSChartSource
|
||||
end
|
||||
end
|
||||
object WorksheetGrid: TsWorksheetGrid
|
||||
Left = 16
|
||||
Height = 240
|
||||
Top = 136
|
||||
Height = 264
|
||||
Top = 112
|
||||
Width = 328
|
||||
FrozenCols = 0
|
||||
FrozenRows = 0
|
||||
ReadFormulas = False
|
||||
TextOverflow = True
|
||||
AutoAdvance = aaDown
|
||||
ColCount = 27
|
||||
ExtendedSelect = False
|
||||
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll]
|
||||
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goColSizing, goEditing, goThumbTracking]
|
||||
RowCount = 101
|
||||
TabOrder = 1
|
||||
ColWidths = (
|
||||
56
|
||||
42
|
||||
64
|
||||
64
|
||||
64
|
||||
@ -82,7 +87,7 @@ object FPSChartForm: TFPSChartForm
|
||||
object btnCreateGraphic: TButton
|
||||
Left = 464
|
||||
Height = 25
|
||||
Top = 56
|
||||
Top = 48
|
||||
Width = 128
|
||||
Caption = 'Create Graphic'
|
||||
OnClick = btnCreateGraphicClick
|
||||
@ -100,9 +105,10 @@ object FPSChartForm: TFPSChartForm
|
||||
end
|
||||
object editSourceFile: TFileNameEdit
|
||||
Left = 152
|
||||
Height = 28
|
||||
Height = 23
|
||||
Top = 48
|
||||
Width = 136
|
||||
FileName = 't1.xls'
|
||||
DialogOptions = []
|
||||
FilterIndex = 0
|
||||
HideDirectories = False
|
||||
@ -110,12 +116,13 @@ object FPSChartForm: TFPSChartForm
|
||||
NumGlyphs = 1
|
||||
MaxLength = 0
|
||||
TabOrder = 3
|
||||
Text = 't1.xls'
|
||||
end
|
||||
object Label2: TLabel
|
||||
Left = 14
|
||||
Height = 20
|
||||
Height = 15
|
||||
Top = 51
|
||||
Width = 134
|
||||
Width = 106
|
||||
Caption = 'Source Spreadsheet:'
|
||||
ParentColor = False
|
||||
end
|
||||
@ -130,7 +137,7 @@ object FPSChartForm: TFPSChartForm
|
||||
end
|
||||
object editXAxis: TLabeledEdit
|
||||
Left = 64
|
||||
Height = 28
|
||||
Height = 23
|
||||
Top = 80
|
||||
Width = 80
|
||||
EditLabel.AnchorSideTop.Control = editXAxis
|
||||
@ -138,19 +145,19 @@ object FPSChartForm: TFPSChartForm
|
||||
EditLabel.AnchorSideRight.Control = editXAxis
|
||||
EditLabel.AnchorSideBottom.Control = editXAxis
|
||||
EditLabel.AnchorSideBottom.Side = asrBottom
|
||||
EditLabel.Left = 16
|
||||
EditLabel.Height = 20
|
||||
EditLabel.Left = 25
|
||||
EditLabel.Height = 15
|
||||
EditLabel.Top = 84
|
||||
EditLabel.Width = 45
|
||||
EditLabel.Width = 36
|
||||
EditLabel.Caption = 'X-Axis:'
|
||||
EditLabel.ParentColor = False
|
||||
LabelPosition = lpLeft
|
||||
TabOrder = 5
|
||||
Text = 'A1:A5'
|
||||
Text = 'A3:A14'
|
||||
end
|
||||
object EditYAxis: TLabeledEdit
|
||||
Left = 208
|
||||
Height = 28
|
||||
Height = 23
|
||||
Top = 80
|
||||
Width = 80
|
||||
EditLabel.AnchorSideTop.Control = EditYAxis
|
||||
@ -158,22 +165,22 @@ object FPSChartForm: TFPSChartForm
|
||||
EditLabel.AnchorSideRight.Control = EditYAxis
|
||||
EditLabel.AnchorSideBottom.Control = EditYAxis
|
||||
EditLabel.AnchorSideBottom.Side = asrBottom
|
||||
EditLabel.Left = 161
|
||||
EditLabel.Height = 20
|
||||
EditLabel.Left = 169
|
||||
EditLabel.Height = 15
|
||||
EditLabel.Top = 84
|
||||
EditLabel.Width = 44
|
||||
EditLabel.Width = 36
|
||||
EditLabel.Caption = 'Y-Axis:'
|
||||
EditLabel.ParentColor = False
|
||||
LabelPosition = lpLeft
|
||||
TabOrder = 6
|
||||
Text = 'B1:B5'
|
||||
Text = 'B3:B14'
|
||||
end
|
||||
object FPSChartSource: TsWorksheetChartSource
|
||||
PointsNumber = 5
|
||||
YFirstCellCol = 1
|
||||
XSelectionDirection = fpsVerticalSelection
|
||||
YSelectionDirection = fpsVerticalSelection
|
||||
left = 632
|
||||
top = 56
|
||||
left = 512
|
||||
top = 200
|
||||
end
|
||||
end
|
@ -6,7 +6,8 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, EditBtn, ExtCtrls, fpspreadsheetchart, fpspreadsheetgrid,
|
||||
StdCtrls, EditBtn, ExtCtrls,
|
||||
fpspreadsheetchart, fpspreadsheetgrid,
|
||||
TAGraph, TASeries;
|
||||
|
||||
type
|
||||
@ -23,7 +24,7 @@ type
|
||||
EditYAxis: TLabeledEdit;
|
||||
MyChart: TChart;
|
||||
FPSChartSource: TsWorksheetChartSource;
|
||||
MyChartLineSeries: TLineSeries;
|
||||
MyChartBarSeries1: TBarSeries;
|
||||
WorksheetGrid: TsWorksheetGrid;
|
||||
procedure btnCreateGraphicClick(Sender: TObject);
|
||||
procedure btnLoadSpreadsheetClick(Sender: TObject);
|
@ -0,0 +1,2 @@
|
||||
This demo shows usage of the TsWorksheetChartSource component for
|
||||
creating charts from spreadsheet data.
|
Binary file not shown.
@ -6601,10 +6601,9 @@ begin
|
||||
Exit(True);
|
||||
end;
|
||||
// Check for Excel8
|
||||
ok := true;
|
||||
for i:=0 to 7 do
|
||||
if WideChar(buf[i*2]) <> BIFF8_MARKER[i] then
|
||||
exit;
|
||||
exit(false);
|
||||
SheetType := sfExcel8;
|
||||
Exit(True);
|
||||
finally
|
||||
@ -6784,8 +6783,12 @@ begin
|
||||
raise Exception.CreateFmt(rsFileNotFound, [AFileName]);
|
||||
|
||||
if Lowercase(ExtractFileExt(AFileName))=STR_EXCEL_EXTENSION then
|
||||
valid := GetFormatFromFileHeader(AFileName, SheetType)
|
||||
else
|
||||
begin
|
||||
valid := GetFormatFromFileHeader(AFileName, SheetType);
|
||||
if not valid then
|
||||
SheetType := sfExcel8;
|
||||
valid := true;
|
||||
end else
|
||||
valid := GetFormatFromFileName(AFileName, SheetType);
|
||||
|
||||
if valid then
|
||||
|
@ -205,6 +205,7 @@ end;
|
||||
function TsWorksheetChartSource.GetItem(AIndex: Integer): PChartDataItem;
|
||||
var
|
||||
XRow, XCol, YRow, YCol: Integer;
|
||||
cell: PCell;
|
||||
begin
|
||||
// First calculate the cell position
|
||||
if XSelectionDirection = fpsVerticalSelection then
|
||||
@ -229,11 +230,28 @@ begin
|
||||
YCol := Integer(FYFirstCellCol) + AIndex;
|
||||
end;
|
||||
|
||||
// Check the corresponding cell, if it is empty, use zero
|
||||
// If not, then get a number value
|
||||
cell := FDataWorksheet.FindCell(XRow, XCol);
|
||||
if cell = nil then
|
||||
begin
|
||||
FCurItem.X := NaN;
|
||||
FCurITem.Text := '';
|
||||
end else
|
||||
if cell^.ContentType = cctUTF8String then begin
|
||||
FCurItem.X := AIndex;
|
||||
FCurItem.Text := FDataWorksheet.ReadAsUTF8Text(cell);
|
||||
end else
|
||||
begin
|
||||
FCurItem.X := FDataWorksheet.ReadAsNumber(cell);
|
||||
FCurItem.Text := '';
|
||||
end;
|
||||
|
||||
FCurItem.X := FDataWorksheet.ReadAsNumber(XRow, XCol);
|
||||
FCurItem.Y := FDataWorksheet.ReadAsNumber(YRow, YCol);
|
||||
cell := FDataWorksheet.FindCell(YRow, YCol);
|
||||
if cell = nil then
|
||||
FCurItem.Y := NaN
|
||||
else
|
||||
FCurItem.Y := FDataWorksheet.ReadAsNumber(cell);
|
||||
|
||||
FCurItem.Color := clDefault;
|
||||
|
||||
Result := @FCurItem;
|
||||
end;
|
||||
@ -561,7 +579,8 @@ const
|
||||
var
|
||||
range: TsCellRange;
|
||||
begin
|
||||
if (FWorkbook = nil) or (FRangeStr[AIndex] = '') then begin
|
||||
if (FWorkbook = nil) or (FRangeStr[AIndex] = '') //or (FWorksheets[AIndex] = nil)
|
||||
then begin
|
||||
FWorksheets[AIndex] := nil;
|
||||
SetLength(FRanges[AIndex], 0);
|
||||
FPointsNumber := 0;
|
||||
|
@ -1027,22 +1027,22 @@ end;
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorkbookSource.SetFileName(const AFileName: TFileName);
|
||||
begin
|
||||
FFileName := AFileName;
|
||||
|
||||
if AFileName = '' then
|
||||
begin
|
||||
CreateNewWorkbook;
|
||||
FFileName := '';
|
||||
exit;
|
||||
end;
|
||||
|
||||
if FileExists(AFileName) then
|
||||
if FileExists(FFileName) then
|
||||
begin
|
||||
if FAutoDetectFormat then
|
||||
LoadFromSpreadsheetFile(AFileName)
|
||||
LoadFromSpreadsheetFile(FFileName)
|
||||
else
|
||||
LoadFromSpreadsheetFile(AFileName, FFileFormat);
|
||||
FFileName := AFileName;
|
||||
LoadFromSpreadsheetFile(FFileName, FFileFormat);
|
||||
end else
|
||||
raise Exception.CreateFmt(rsFileNotFound, [AFileName]);
|
||||
raise Exception.CreateFmt(rsFileNotFound, [ExpandFileName(AFileName)]);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user