You've already forked lazarus-ccr
fpspreadsheet: Add option to define series labels in TsWorkbookChartSource.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6564 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="11"/>
|
||||
<Version Value="10"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
@ -11,43 +11,19 @@
|
||||
<UseXPManifest Value="True"/>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<i18n>
|
||||
<EnableI18N LFM="False"/>
|
||||
</i18n>
|
||||
<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>
|
||||
<VersionInfo>
|
||||
<StringTable ProductVersion=""/>
|
||||
</VersionInfo>
|
||||
<BuildModes Count="1">
|
||||
<Item1 Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
<Modes Count="1">
|
||||
<Mode0 Name="default"/>
|
||||
</Modes>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="3">
|
||||
<Item1>
|
||||
@ -69,7 +45,6 @@
|
||||
<Filename Value="mainform.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
@ -84,14 +59,7 @@
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<CodeGeneration>
|
||||
<SmartLinkUnit Value="True"/>
|
||||
</CodeGeneration>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<DebugInfoType Value="dsDwarf2Set"/>
|
||||
<UseExternalDbgSyms Value="True"/>
|
||||
</Debugging>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
|
@ -7,12 +7,13 @@ uses
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, mainform;
|
||||
Forms, tachartlazaruspkg, mainform
|
||||
{ you can add units after this };
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
RequireDerivedFormResource := True;
|
||||
RequireDerivedFormResource:=True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
|
@ -1,119 +1,119 @@
|
||||
object Form1: TForm1
|
||||
Left = 354
|
||||
Height = 634
|
||||
Top = 132
|
||||
Width = 877
|
||||
Left = 256
|
||||
Height = 618
|
||||
Top = 127
|
||||
Width = 828
|
||||
Caption = 'Form1'
|
||||
ClientHeight = 634
|
||||
ClientWidth = 877
|
||||
ClientHeight = 618
|
||||
ClientWidth = 828
|
||||
OnCreate = FormCreate
|
||||
LCLVersion = '1.9.0.0'
|
||||
LCLVersion = '1.8.4.0'
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Height = 40
|
||||
Height = 33
|
||||
Top = 0
|
||||
Width = 877
|
||||
Width = 828
|
||||
Align = alTop
|
||||
AutoSize = True
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 40
|
||||
ClientWidth = 877
|
||||
ClientHeight = 33
|
||||
ClientWidth = 828
|
||||
TabOrder = 0
|
||||
object Button1: TButton
|
||||
Left = 8
|
||||
object BtnDeleteSheet: TButton
|
||||
AnchorSideLeft.Control = Panel1
|
||||
AnchorSideTop.Control = Panel1
|
||||
Left = 4
|
||||
Height = 25
|
||||
Top = 7
|
||||
Width = 91
|
||||
Top = 4
|
||||
Width = 90
|
||||
AutoSize = True
|
||||
BorderSpacing.Left = 4
|
||||
BorderSpacing.Top = 4
|
||||
BorderSpacing.Right = 4
|
||||
BorderSpacing.Bottom = 4
|
||||
Caption = 'Delete sheet'
|
||||
OnClick = Button1Click
|
||||
OnClick = BtnDeleteSheetClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object Button2: TButton
|
||||
Left = 107
|
||||
object BtnRenameSheet: TButton
|
||||
AnchorSideLeft.Control = BtnDeleteSheet
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = BtnDeleteSheet
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 98
|
||||
Height = 25
|
||||
Top = 7
|
||||
Width = 93
|
||||
Top = 4
|
||||
Width = 100
|
||||
AutoSize = True
|
||||
BorderSpacing.Right = 4
|
||||
BorderSpacing.Bottom = 4
|
||||
Caption = 'Rename sheet'
|
||||
OnClick = Button2Click
|
||||
OnClick = BtnRenameSheetClick
|
||||
TabOrder = 1
|
||||
end
|
||||
object Bevel1: TBevel
|
||||
Left = 0
|
||||
Height = 3
|
||||
Top = 37
|
||||
Width = 877
|
||||
Align = alBottom
|
||||
Shape = bsBottomLine
|
||||
end
|
||||
end
|
||||
object Splitter1: TSplitter
|
||||
Left = 872
|
||||
Height = 594
|
||||
Top = 40
|
||||
Width = 5
|
||||
Align = alRight
|
||||
ResizeAnchor = akRight
|
||||
end
|
||||
object sWorkbookTabControl1: TsWorkbookTabControl
|
||||
Left = 6
|
||||
Height = 582
|
||||
Top = 46
|
||||
Width = 390
|
||||
Left = 5
|
||||
Height = 581
|
||||
Top = 37
|
||||
Width = 280
|
||||
TabIndex = 0
|
||||
Tabs.Strings = (
|
||||
'Sheet1'
|
||||
)
|
||||
Align = alClient
|
||||
BorderSpacing.Around = 6
|
||||
TabOrder = 2
|
||||
Align = alLeft
|
||||
TabOrder = 1
|
||||
WorkbookSource = sWorkbookSource1
|
||||
object sWorksheetGrid1: TsWorksheetGrid
|
||||
Left = 2
|
||||
Height = 557
|
||||
Height = 556
|
||||
Top = 23
|
||||
Width = 386
|
||||
Width = 276
|
||||
AutoCalc = True
|
||||
FrozenCols = 0
|
||||
FrozenRows = 0
|
||||
ReadFormulas = False
|
||||
ReadFormulas = True
|
||||
WorkbookSource = sWorkbookSource1
|
||||
Align = alClient
|
||||
AutoAdvance = aaDown
|
||||
DefaultColWidth = 64
|
||||
DefaultRowHeight = 22
|
||||
Font.Color = clBlack
|
||||
Font.Height = -15
|
||||
Font.Name = 'Calibri'
|
||||
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goThumbTracking]
|
||||
ParentFont = False
|
||||
MouseWheelOption = mwGrid
|
||||
Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goColSizing, goEditing, goThumbTracking, goSmoothScroll]
|
||||
TabOrder = 1
|
||||
TitleFont.Color = clBlack
|
||||
TitleFont.Height = -15
|
||||
TitleFont.Name = 'Calibri'
|
||||
end
|
||||
end
|
||||
object Panel2: TPanel
|
||||
Left = 402
|
||||
Height = 594
|
||||
Top = 40
|
||||
Width = 470
|
||||
Align = alRight
|
||||
Left = 285
|
||||
Height = 581
|
||||
Top = 37
|
||||
Width = 543
|
||||
Align = alClient
|
||||
BevelOuter = bvNone
|
||||
Caption = 'Panel2'
|
||||
ClientHeight = 594
|
||||
ClientWidth = 470
|
||||
TabOrder = 3
|
||||
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
|
||||
ChildSizing.EnlargeVertical = crsHomogenousChildResize
|
||||
ChildSizing.ShrinkHorizontal = crsHomogenousChildResize
|
||||
ChildSizing.ShrinkVertical = crsHomogenousChildResize
|
||||
ChildSizing.Layout = cclLeftToRightThenTopToBottom
|
||||
ChildSizing.ControlsPerLine = 1
|
||||
ClientHeight = 581
|
||||
ClientWidth = 543
|
||||
TabOrder = 2
|
||||
object Chart1: TChart
|
||||
Left = 0
|
||||
Height = 183
|
||||
Height = 194
|
||||
Top = 0
|
||||
Width = 470
|
||||
Width = 543
|
||||
AxisList = <
|
||||
item
|
||||
Grid.Color = clSilver
|
||||
Marks.LabelBrush.Style = bsClear
|
||||
Minors = <>
|
||||
Title.LabelFont.Orientation = 900
|
||||
Title.LabelBrush.Style = bsClear
|
||||
end
|
||||
item
|
||||
Grid.Color = clSilver
|
||||
Alignment = calBottom
|
||||
Marks.LabelBrush.Style = bsClear
|
||||
Minors = <>
|
||||
@ -128,34 +128,33 @@ object Form1: TForm1
|
||||
'Chart from 1st sheet'
|
||||
)
|
||||
Title.Visible = True
|
||||
Align = alTop
|
||||
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 = 470
|
||||
Height = 194
|
||||
Top = 194
|
||||
Width = 543
|
||||
AxisList = <
|
||||
item
|
||||
Grid.Color = clSilver
|
||||
Marks.LabelBrush.Style = bsClear
|
||||
Minors = <>
|
||||
Title.LabelFont.Orientation = 900
|
||||
Title.LabelBrush.Style = bsClear
|
||||
end
|
||||
item
|
||||
Grid.Color = clSilver
|
||||
Alignment = calBottom
|
||||
Marks.LabelBrush.Style = bsClear
|
||||
Minors = <>
|
||||
Title.LabelBrush.Style = bsClear
|
||||
end>
|
||||
BackColor = clWhite
|
||||
Depth = 10
|
||||
Foot.Brush.Color = clBtnFace
|
||||
Foot.Font.Color = clBlue
|
||||
Title.Brush.Color = clBtnFace
|
||||
@ -164,24 +163,24 @@ object Form1: TForm1
|
||||
'Chart from 2nd sheet'
|
||||
)
|
||||
Title.Visible = True
|
||||
Align = alClient
|
||||
object Chart2BarSeries1: TBarSeries
|
||||
Marks.Distance = 15
|
||||
Marks.Format = '%0:.2f'
|
||||
Marks.Frame.Color = clOlive
|
||||
Marks.LabelBrush.Color = clCream
|
||||
Marks.LinkPen.Visible = False
|
||||
Marks.Distance = 5
|
||||
Marks.Format = '%.2f'
|
||||
Marks.Frame.Visible = False
|
||||
Marks.LabelBrush.Color = 13553407
|
||||
Marks.LinkPen.Color = clGray
|
||||
Marks.OverlapPolicy = opHideNeighbour
|
||||
Marks.Style = smsCustom
|
||||
BarBrush.Color = 9934847
|
||||
Depth = 10
|
||||
Depth = 6
|
||||
Source = sWorkbookChartSource2
|
||||
end
|
||||
end
|
||||
object Chart3: TChart
|
||||
Left = 0
|
||||
Height = 193
|
||||
Top = 401
|
||||
Width = 470
|
||||
Top = 388
|
||||
Width = 543
|
||||
AxisList = <
|
||||
item
|
||||
Visible = False
|
||||
@ -200,7 +199,6 @@ object Form1: TForm1
|
||||
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
|
||||
@ -208,36 +206,49 @@ object Form1: TForm1
|
||||
'Chart from 3rd sheet'
|
||||
)
|
||||
Title.Visible = True
|
||||
Align = alBottom
|
||||
object Chart3PieSeries1: TPieSeries
|
||||
Legend.Multiplicity = lmPoint
|
||||
Marks.Distance = 8
|
||||
Marks.Distance = 10
|
||||
Marks.Format = '%2:s'
|
||||
Marks.Style = smsLabel
|
||||
MarkPositions = pmpInside
|
||||
Source = sWorkbookChartSource3
|
||||
end
|
||||
end
|
||||
end
|
||||
object Bevel1: TBevel
|
||||
Left = 0
|
||||
Height = 4
|
||||
Top = 33
|
||||
Width = 828
|
||||
Align = alTop
|
||||
Shape = bsTopLine
|
||||
end
|
||||
object Splitter1: TSplitter
|
||||
Left = 0
|
||||
Height = 581
|
||||
Top = 37
|
||||
Width = 5
|
||||
end
|
||||
object sWorkbookSource1: TsWorkbookSource
|
||||
AutoDetectFormat = False
|
||||
FileFormat = sfUser
|
||||
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
|
||||
Options = [boAutoCalc, boReadFormulas]
|
||||
left = 152
|
||||
top = 184
|
||||
end
|
||||
object sWorkbookChartSource3: TsWorkbookChartSource
|
||||
WorkbookSource = sWorkbookSource1
|
||||
left = 640
|
||||
top = 512
|
||||
left = 544
|
||||
top = 503
|
||||
end
|
||||
object sWorkbookChartSource2: TsWorkbookChartSource
|
||||
WorkbookSource = sWorkbookSource1
|
||||
left = 544
|
||||
top = 316
|
||||
end
|
||||
object sWorkbookChartSource1: TsWorkbookChartSource
|
||||
WorkbookSource = sWorkbookSource1
|
||||
left = 544
|
||||
top = 120
|
||||
end
|
||||
end
|
||||
|
@ -5,9 +5,9 @@ unit mainform;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, TAGraph, TASeries, Forms, Controls,
|
||||
Graphics, Dialogs, ExtCtrls, StdCtrls,
|
||||
fpstypes, fpspreadsheetctrls, fpspreadsheetgrid, fpspreadsheetchart, fpsallformats;
|
||||
Classes, SysUtils, FileUtil, TAGraph, TASources, TASeries, Forms, Controls,
|
||||
Graphics, Dialogs, ExtCtrls, StdCtrls, fpspreadsheetctrls, fpspreadsheetgrid,
|
||||
fpspreadsheetchart, fpsallformats;
|
||||
|
||||
type
|
||||
|
||||
@ -15,7 +15,7 @@ type
|
||||
|
||||
TForm1 = class(TForm)
|
||||
Bevel1: TBevel;
|
||||
Button1: TButton;
|
||||
BtnDeleteSheet: TButton;
|
||||
Button2: TButton;
|
||||
Chart1: TChart;
|
||||
Chart1AreaSeries1: TAreaSeries;
|
||||
@ -32,13 +32,13 @@ type
|
||||
sWorkbookSource1: TsWorkbookSource;
|
||||
sWorkbookTabControl1: TsWorkbookTabControl;
|
||||
sWorksheetGrid1: TsWorksheetGrid;
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure Button2Click(Sender: TObject);
|
||||
procedure BtnDeleteSheetClick(Sender: TObject);
|
||||
procedure BtnRenameSheetClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
|
||||
public
|
||||
{ public declarations }
|
||||
|
||||
end;
|
||||
|
||||
var
|
||||
@ -50,8 +50,19 @@ implementation
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.Button1Click(Sender: TObject);
|
||||
// The same effect is obtained by using the built-in TsWorksheetDeleteAction.
|
||||
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';
|
||||
sWorkbookChartSource3.LabelRange := 'Sheet3!A2:A5';
|
||||
end;
|
||||
|
||||
procedure TForm1.BtnDeleteSheetClick(Sender: TObject);
|
||||
begin
|
||||
if sWorkbookSource1.Workbook.GetWorksheetCount = 1 then
|
||||
MessageDlg('There must be a least 1 worksheet.', mtError, [mbOK], 0)
|
||||
@ -62,7 +73,7 @@ begin
|
||||
sWorkbookSource1.Workbook.RemoveWorksheet(sWorkbookSource1.Worksheet);
|
||||
end;
|
||||
|
||||
procedure TForm1.Button2Click(Sender: TObject);
|
||||
procedure TForm1.BtnRenameSheetClick(Sender: TObject);
|
||||
var
|
||||
s: String;
|
||||
begin
|
||||
@ -76,16 +87,6 @@ begin
|
||||
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.
|
||||
|
||||
|
Binary file not shown.
@ -79,31 +79,31 @@ type
|
||||
|
||||
{ TsWorkbookChartSource }
|
||||
|
||||
TsXYRange = (rngX, rngY);
|
||||
TsXYLRange = (rngX, rngY, rngLabel);
|
||||
|
||||
TsWorkbookChartSource = class(TCustomChartSource, IsSpreadsheetControl)
|
||||
private
|
||||
FWorkbookSource: TsWorkbookSource;
|
||||
// FWorkbook: TsWorkbook;
|
||||
FWorksheets: array[TsXYRange] of TsWorksheet;
|
||||
FRangeStr: array[TsXYRange] of String;
|
||||
FRanges: array[TsXYRange] of TsCellRangeArray;
|
||||
FWorksheets: array[TsXYLRange] of TsWorksheet;
|
||||
FRangeStr: array[TsXYLRange] of String;
|
||||
FRanges: array[TsXYLRange] of TsCellRangeArray;
|
||||
FPointsNumber: Cardinal;
|
||||
function GetRange(AIndex: TsXYRange): String;
|
||||
function GetRange(AIndex: TsXYLRange): String;
|
||||
function GetWorkbook: TsWorkbook;
|
||||
procedure GetXYItem(XOrY:TsXYRange; APointIndex: Integer;
|
||||
procedure GetXYItem(ARangeIndex:TsXYLRange; APointIndex: Integer;
|
||||
out ANumber: Double; out AText: String);
|
||||
procedure SetRange(AIndex: TsXYRange; const AValue: String);
|
||||
procedure SetRange(AIndex: TsXYLRange; const AValue: String);
|
||||
procedure SetWorkbookSource(AValue: TsWorkbookSource);
|
||||
protected
|
||||
FCurItem: TChartDataItem;
|
||||
function BuildRangeStr(AIndex: TsXYRange; AListSeparator: char = #0): String;
|
||||
function CountValues(AIndex: TsXYRange): Integer;
|
||||
function BuildRangeStr(AIndex: TsXYLRange; AListSeparator: char = #0): String;
|
||||
function CountValues(AIndex: TsXYLRange): Integer;
|
||||
function GetCount: Integer; override;
|
||||
function GetItem(AIndex: Integer): PChartDataItem; override;
|
||||
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
||||
procedure Prepare; overload;
|
||||
procedure Prepare(AIndex: TsXYRange); overload;
|
||||
procedure Prepare(AIndex: TsXYLRange); overload;
|
||||
procedure SetYCount(AValue: Cardinal); override;
|
||||
public
|
||||
destructor Destroy; override;
|
||||
@ -116,6 +116,7 @@ type
|
||||
procedure RemoveWorkbookSource;
|
||||
published
|
||||
property WorkbookSource: TsWorkbookSource read FWorkbookSource write SetWorkbookSource;
|
||||
property LabelRange: String index rngLabel read GetRange write SetRange;
|
||||
property XRange: String index rngX read GetRange write SetRange;
|
||||
property YRange: String index rngY read GetRange write SetRange;
|
||||
end;
|
||||
@ -317,7 +318,7 @@ end;
|
||||
to have the worksheet name in the range string in order to make the range
|
||||
string unique.
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorkbookChartSource.BuildRangeStr(AIndex: TsXYRange;
|
||||
function TsWorkbookChartSource.BuildRangeStr(AIndex: TsXYLRange;
|
||||
AListSeparator: Char = #0): String;
|
||||
var
|
||||
L: TStrings;
|
||||
@ -346,7 +347,7 @@ end;
|
||||
|
||||
@param AIndex Identifies whether values in the x or y ranges are counted.
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorkbookChartSource.CountValues(AIndex: TsXYRange): Integer;
|
||||
function TsWorkbookChartSource.CountValues(AIndex: TsXYLRange): Integer;
|
||||
var
|
||||
range: TsCellRange;
|
||||
begin
|
||||
@ -382,23 +383,28 @@ end;
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorkbookChartSource.GetItem(AIndex: Integer): PChartDataItem;
|
||||
var
|
||||
dummy: String;
|
||||
dummyNumber: Double;
|
||||
dummyString: String;
|
||||
tmpLabel: String;
|
||||
begin
|
||||
GetXYItem(rngX, AIndex, FCurItem.X, FCurItem.Text);
|
||||
GetXYItem(rngY, AIndex, FCurItem.Y, dummy);
|
||||
GetXYItem(rngX, AIndex, FCurItem.X, tmpLabel);
|
||||
GetXYItem(rngY, AIndex, FCurItem.Y, dummyString);
|
||||
GetXYItem(rngLabel, AIndex, dummyNumber, FCurItem.Text);
|
||||
if FCurItem.Text = '' then FCurItem.Text := tmpLabel;
|
||||
FCurItem.Color := clDefault;
|
||||
Result := @FCurItem;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Getter method for the cell range used for x or y coordinates (or x labels)
|
||||
Getter method for the cell range used for x or y coordinates or x labels
|
||||
|
||||
@param AIndex Determines whether the methods deals with x or y values
|
||||
@param AIndex Determines whether the methods deals with x, y values or
|
||||
vakze labels.
|
||||
@return An Excel string containing workbookname and cell block(s) in A1
|
||||
notation. Multiple blocks are separated by the ListSeparator defined
|
||||
by the workbook's FormatSettings.
|
||||
-------------------------------------------------------------------------------}
|
||||
function TsWorkbookChartsource.GetRange(AIndex: TsXYRange): String;
|
||||
function TsWorkbookChartsource.GetRange(AIndex: TsXYLRange): String;
|
||||
begin
|
||||
Result := FRangeStr[AIndex];
|
||||
end;
|
||||
@ -418,14 +424,14 @@ end;
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Helper method the prepare the information required for the series data point.
|
||||
|
||||
@param XOrY Identifies whether the method retrieves the x or y
|
||||
coordinate.
|
||||
@param ARangeIndex Identifies whether the method retrieves the x or y
|
||||
coordinate, or the label text
|
||||
@param APointIndex Index of the data point for which the data are required
|
||||
@param ANumber (output) x or y coordinate of the data point
|
||||
@param AText Data point marks label text
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorkbookChartSource.GetXYItem(XOrY:TsXYRange; APointIndex: Integer;
|
||||
out ANumber: Double; out AText: String);
|
||||
procedure TsWorkbookChartSource.GetXYItem(ARangeIndex:TsXYLRange;
|
||||
APointIndex: Integer; out ANumber: Double; out AText: String);
|
||||
var
|
||||
range: TsCellRange;
|
||||
idx: Integer;
|
||||
@ -433,12 +439,17 @@ var
|
||||
row, col: Cardinal;
|
||||
cell: PCell;
|
||||
begin
|
||||
cell := nil;
|
||||
idx := 0;
|
||||
if FRanges[XOrY] = nil then
|
||||
ANumber := NaN;
|
||||
AText := '';
|
||||
if FRanges[ARangeIndex] = nil then
|
||||
exit;
|
||||
if FWorksheets[ARangeIndex] = nil then
|
||||
exit;
|
||||
|
||||
for range in FRanges[XOrY] do
|
||||
cell := nil;
|
||||
idx := 0;
|
||||
|
||||
for range in FRanges[ARangeIndex] do
|
||||
begin
|
||||
if (range.Col1 = range.Col2) then // vertical range
|
||||
begin
|
||||
@ -461,24 +472,22 @@ begin
|
||||
break;
|
||||
end;
|
||||
end else
|
||||
raise Exception.Create('x/y ranges can only be 1 column wide or 1 row high');
|
||||
raise Exception.Create('Ranges can only be 1 column wide or 1 row high');
|
||||
end;
|
||||
|
||||
cell := FWorksheets[XOrY].FindCell(row, col);
|
||||
cell := FWorksheets[ARangeIndex].FindCell(row, col);
|
||||
|
||||
if cell = nil then
|
||||
begin
|
||||
ANumber := NaN;
|
||||
AText := '';
|
||||
end else
|
||||
if cell^.ContentType = cctUTF8String then begin
|
||||
ANumber := APointIndex;
|
||||
AText := FWorksheets[rngX].ReadAsText(cell);
|
||||
end else
|
||||
begin
|
||||
ANumber := FWorksheets[rngX].ReadAsNumber(cell);
|
||||
AText := '';
|
||||
end;
|
||||
if cell <> nil then
|
||||
case cell^.ContentType of
|
||||
cctUTF8String:
|
||||
begin
|
||||
ANumber := APointIndex;
|
||||
AText := FWorksheets[ARangeIndex].ReadAsText(cell);
|
||||
end;
|
||||
else
|
||||
ANumber := FWorksheets[ARangeIndex].ReadAsNumber(cell);
|
||||
AText := '';
|
||||
end;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
@ -500,7 +509,7 @@ var
|
||||
ir: Integer;
|
||||
cell: PCell;
|
||||
ResetDone: Boolean;
|
||||
xy: TsXYRange;
|
||||
rng: TsXYLRange;
|
||||
begin
|
||||
Unused(AData);
|
||||
|
||||
@ -510,19 +519,19 @@ begin
|
||||
|
||||
// Used worksheet has been renamed?
|
||||
if (lniWorksheetRename in AChangedItems) then
|
||||
for xy in TsXYRange do
|
||||
if TsWorksheet(AData) = FWorksheets[xy] then begin
|
||||
FRangeStr[xy] := BuildRangeStr(xy);
|
||||
Prepare(xy);
|
||||
for rng in TsXYLRange do
|
||||
if TsWorksheet(AData) = FWorksheets[rng] then begin
|
||||
FRangeStr[rng] := BuildRangeStr(rng);
|
||||
Prepare(rng);
|
||||
end;
|
||||
|
||||
// Used worksheet will be deleted?
|
||||
if (lniWorksheetRemoving in AChangedItems) then
|
||||
for xy in TsXYRange do
|
||||
if TsWorksheet(AData) = FWorksheets[xy] then begin
|
||||
FWorksheets[xy] := nil;
|
||||
FRangeStr[xy] := BuildRangeStr(xy);
|
||||
Prepare(xy);
|
||||
for rng in TsXYLRange do
|
||||
if TsWorksheet(AData) = FWorksheets[rng] then begin
|
||||
FWorksheets[rng] := nil;
|
||||
FRangeStr[rng] := BuildRangeStr(rng);
|
||||
Prepare(rng);
|
||||
end;
|
||||
|
||||
// Cell changes: Enforce recalculation of axes if modified cell is within the
|
||||
@ -532,10 +541,10 @@ begin
|
||||
cell := PCell(AData);
|
||||
if (cell <> nil) then begin
|
||||
ResetDone := false;
|
||||
for xy in TsXYrange do
|
||||
for ir:=0 to High(FRanges[xy]) do
|
||||
for rng in TsXYLRange do
|
||||
for ir:=0 to High(FRanges[rng]) do
|
||||
begin
|
||||
if FWorksheets[xy].CellInRange(cell^.Row, cell^.Col, FRanges[xy, ir]) then
|
||||
if FWorksheets[rng].CellInRange(cell^.Row, cell^.Col, FRanges[rng, ir]) then
|
||||
begin
|
||||
Reset;
|
||||
ResetDone := true;
|
||||
@ -565,6 +574,7 @@ end;
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorkbookChartSource.Prepare;
|
||||
begin
|
||||
Prepare(rngLabel);
|
||||
Prepare(rngX);
|
||||
Prepare(rngY);
|
||||
end;
|
||||
@ -573,11 +583,13 @@ end;
|
||||
Parses the range string of the data specified by AIndex and extracts internal
|
||||
information (worksheet used, cell range coordinates)
|
||||
|
||||
@param AIndex Identifies whether x or y cell ranges are analyzed
|
||||
@param AIndex Identifies whether x or y or label cell ranges are analyzed
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorkbookChartSource.Prepare(AIndex: TsXYRange);
|
||||
procedure TsWorkbookChartSource.Prepare(AIndex: TsXYLRange);
|
||||
{
|
||||
const
|
||||
XY: array[TsXYRange] of string = ('x', 'y');
|
||||
XY: array[TsXYRange] of string = ('x', 'y', '');
|
||||
}
|
||||
var
|
||||
range: TsCellRange;
|
||||
begin
|
||||
@ -603,11 +615,14 @@ begin
|
||||
end else
|
||||
if (Workbook.GetWorksheetCount > 0) then begin
|
||||
if FWorksheets[AIndex] = nil then
|
||||
exit;
|
||||
{
|
||||
raise Exception.CreateFmt('Worksheet of %s cell range "%s" does not exist.',
|
||||
[XY[AIndex], FRangeStr[AIndex]])
|
||||
else
|
||||
raise Exception.CreateFmt('No valid %s cell range in "%s".',
|
||||
[XY[AIndex], FRangeStr[AIndex]]);
|
||||
}
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -635,13 +650,15 @@ end;
|
||||
If it does not contain the worksheet name the currently active worksheet of
|
||||
the WorkbookSource is assumed.
|
||||
|
||||
@param AIndex Distinguishes whether the method deals with x or y ranges
|
||||
@param AIndex Distinguishes whether the method deals with x, y or
|
||||
label ranges.
|
||||
@param AValue String in Excel syntax containing the cell range to be
|
||||
used for x or y (depending on AIndex). Can contain multiple
|
||||
cell blocks which must be separator by the ListSeparator
|
||||
character defined in the Workbook's FormatSettings.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsWorkbookChartSource.SetRange(AIndex: TsXYRange; const AValue: String);
|
||||
procedure TsWorkbookChartSource.SetRange(AIndex: TsXYLRange;
|
||||
const AValue: String);
|
||||
begin
|
||||
FRangeStr[AIndex] := AValue;
|
||||
Prepare;
|
||||
|
Reference in New Issue
Block a user