TRxDBGridExportSpreadSheet - start code for export merged title cells

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3545 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2014-09-11 09:31:28 +00:00
parent e0241fd6d1
commit bd601224e5
5 changed files with 95 additions and 47 deletions

View File

@ -59,7 +59,7 @@
<MinVersion Major="1" Release="18" Build="56" Valid="True"/>
</Item6>
</RequiredPackages>
<Units Count="103">
<Units Count="104">
<Unit0>
<Filename Value="RxDBGridDemo.lpr"/>
<IsPartOfProject Value="True"/>
@ -73,8 +73,7 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="RxDBGridMainUnit"/>
<TopLine Value="78"/>
<CursorPos Y="80"/>
<CursorPos X="3" Y="10"/>
<UsageCount Value="99"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
@ -100,14 +99,13 @@
<Unit5>
<Filename Value="../../rxdbgrid.pas"/>
<UnitName Value="rxdbgrid"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="3742"/>
<CursorPos Y="3763"/>
<EditorIndex Value="2"/>
<TopLine Value="66"/>
<CursorPos Y="90"/>
<UsageCount Value="17"/>
<Bookmarks Count="2">
<Item0 Y="2564" ID="2"/>
<Item1 Y="3763" ID="1"/>
<Item0 Y="2562" ID="2"/>
<Item1 Y="3761" ID="1"/>
</Bookmarks>
<Loaded Value="True"/>
</Unit5>
@ -708,8 +706,18 @@
<CursorPos X="2" Y="44"/>
<UsageCount Value="10"/>
</Unit102>
<Unit103>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<UnitName Value="RxDBGridExportSpreadSheet"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="185"/>
<CursorPos X="2" Y="208"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit103>
</Units>
<JumpHistory Count="16" HistoryIndex="15">
<JumpHistory Count="19" HistoryIndex="18">
<Position1>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="867" Column="35" TopLine="845"/>
@ -774,6 +782,18 @@
<Filename Value="rxdbgridmainunit.pas"/>
<Caret Line="161" Column="62" TopLine="158"/>
</Position16>
<Position17>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="3753" Column="6" TopLine="3743"/>
</Position17>
<Position18>
<Filename Value="rxdbgridmainunit.pas"/>
<Caret Line="80" TopLine="78"/>
</Position18>
<Position19>
<Filename Value="rxdbgridmainunit.pas"/>
<Caret Line="100" Column="50" TopLine="84"/>
</Position19>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>

View File

@ -1,12 +1,12 @@
object RxDBGridMainForm: TRxDBGridMainForm
Left = 363
Left = 287
Height = 721
Top = 238
Width = 1187
Top = 148
Width = 1151
ActiveControl = Panel1
Caption = 'RxDBGrid Demo'
ClientHeight = 694
ClientWidth = 1187
ClientHeight = 696
ClientWidth = 1151
Menu = MainMenu1
OnCreate = FormCreate
SessionProperties = 'RxDBGridExportSpreadSheet1.FileName;RxDBGridExportSpreadSheet1.OpenAfterExport;RxDBGridExportSpreadSheet1.Options;RxDBGridExportSpreadSheet1.PageName;RxDBGridPrint1.Options;RxDBGridPrint1.Orientation;RxDBGridPrint1.PageMargin;RxDBGridPrint1.ReportTitle;RxDBGridPrint1.ShowColumnHeaderOnAllPage'
@ -14,9 +14,9 @@ object RxDBGridMainForm: TRxDBGridMainForm
LCLVersion = '1.3'
object RxDBGrid1: TRxDBGrid
Left = 0
Height = 624
Top = 70
Width = 1187
Height = 630
Top = 66
Width = 1151
TitleButtons = True
AutoSort = True
OnGetCellProps = RxDBGrid1GetCellProps
@ -297,22 +297,22 @@ object RxDBGridMainForm: TRxDBGridMainForm
end
object Panel1: TPanel
Left = 0
Height = 70
Height = 66
Top = 0
Width = 1187
Width = 1151
Align = alTop
AutoSize = True
ClientHeight = 70
ClientWidth = 1187
ClientHeight = 66
ClientWidth = 1151
TabOrder = 1
object Label1: TLabel
AnchorSideLeft.Control = Button2
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel1
Left = 270
Height = 21
Left = 262
Height = 19
Top = 7
Width = 36
Width = 34
BorderSpacing.Around = 6
Caption = 'Mode'
ParentColor = False
@ -321,9 +321,9 @@ object RxDBGridMainForm: TRxDBGridMainForm
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
Left = 7
Height = 33
Height = 31
Top = 7
Width = 87
Width = 85
Action = actCalcTotal
AutoSize = True
BorderSpacing.Around = 6
@ -333,10 +333,10 @@ object RxDBGridMainForm: TRxDBGridMainForm
AnchorSideLeft.Control = Button1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel1
Left = 100
Height = 33
Left = 98
Height = 31
Top = 7
Width = 164
Width = 158
Action = actOptimizeColumnsWidthAll
AutoSize = True
BorderSpacing.Around = 6
@ -347,11 +347,11 @@ object RxDBGridMainForm: TRxDBGridMainForm
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CheckBox2
AnchorSideTop.Side = asrBottom
Left = 499
Left = 491
Height = 23
Hint = 'Use filter line'
Top = 36
Width = 82
Width = 80
BorderSpacing.Left = 6
Caption = 'Use filter'
OnChange = CheckBox1Change
@ -361,9 +361,9 @@ object RxDBGridMainForm: TRxDBGridMainForm
AnchorSideLeft.Control = Label1
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
Left = 276
Height = 29
Top = 34
Left = 268
Height = 27
Top = 32
Width = 217
BorderSpacing.Around = 6
ItemHeight = 0
@ -381,11 +381,11 @@ object RxDBGridMainForm: TRxDBGridMainForm
AnchorSideLeft.Control = ComboBox1
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel1
Left = 499
Left = 491
Height = 23
Hint = 'Auto fill column width'
Top = 7
Width = 131
Width = 125
BorderSpacing.Around = 6
Caption = 'Auto fill columns'
OnChange = CheckBox2Change
@ -395,10 +395,10 @@ object RxDBGridMainForm: TRxDBGridMainForm
AnchorSideLeft.Control = CheckBox2
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel1
Left = 636
Left = 622
Height = 23
Top = 7
Width = 119
Width = 116
BorderSpacing.Around = 6
Caption = 'Show indicator'
Checked = True
@ -411,10 +411,10 @@ object RxDBGridMainForm: TRxDBGridMainForm
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CheckBox3
AnchorSideTop.Side = asrBottom
Left = 636
Left = 622
Height = 23
Top = 36
Width = 115
Width = 112
BorderSpacing.Around = 6
Caption = 'Show headers'
Checked = True
@ -426,10 +426,10 @@ object RxDBGridMainForm: TRxDBGridMainForm
AnchorSideLeft.Control = CheckBox3
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Panel1
Left = 761
Left = 744
Height = 23
Top = 7
Width = 94
Width = 95
BorderSpacing.Around = 6
Caption = 'Word wrap'
OnChange = CheckBox5Change

View File

@ -97,7 +97,7 @@ var
procedure LocalizeApp;
implementation
uses rxsortmemds, FileUtil, gettext, translations, LCLVersion, rxFileUtils;
uses rxsortmemds, FileUtil, gettext, translations, rxFileUtils;
procedure LocalizeApp;
var

View File

@ -36,12 +36,10 @@ unit rxdbgrid;
interface
uses
Classes, SysUtils, LResources, LCLVersion, LCLType, LCLIntf, Forms, Controls, Buttons,
Classes, SysUtils, LResources, LCLType, LCLIntf, Forms, Controls, Buttons,
Graphics, Dialogs, Grids, dbutils, DBGrids, DB, PropertyStorage, vclutils,
LMessages, types, StdCtrls, Menus, rxspin;
{//$if ((lcl_major = 1) and (lcl_minor = 1))}
const
CBadQuickSearchSymbols = [VK_UNKNOWN..VK_HELP] + [VK_LWIN..VK_SLEEP] +
[VK_NUMLOCK..VK_SCROLL] + [VK_LSHIFT..VK_OEM_102] + [VK_PROCESSKEY] +

View File

@ -107,6 +107,7 @@ var
scColor : TsColor;
CB:TsCellBorders;
FMaxTitleHeight : integer;
P: TMLCaptionItem;
begin
FCurCol:=0;
FMaxTitleHeight:=1;
@ -142,6 +143,7 @@ begin
else
CB:=CB - [cbEast];
FWorksheet.WriteBorderColor(FCurRow + k ,FCurCol, cbSouth, scColorBlack);
FWorksheet.WriteBorders(FCurRow + k, FCurCol, CB);
@ -149,6 +151,20 @@ begin
FWorksheet.WriteHorAlignment(FCurRow + k, FCurCol, ssAligns[C.Title.Alignment]);
FWorksheet.WriteUTF8Text(FCurRow + k, FCurCol, CT.CaptionLine(k).Caption);
if Assigned(CT.CaptionLine(k).Next) and not Assigned(CT.CaptionLine(k).Prior) then
begin
//Merge title cell
P:=CT.CaptionLine(k);
CC:=FCurCol;
while Assigned(P.Next) do
begin
Inc(CC);
P:=P.Next;
end;
if CC<>FCurCol then
FWorksheet.MergeCells(FCurRow, FCurCol, FCurRow, CC);
end;
end;
end
else
@ -176,6 +192,20 @@ begin
end;
end;
{
if FMaxTitleHeight > 1 then
begin
for i:=0 to FRxDBGrid.Columns.Count-1 do
begin
C:=FRxDBGrid.Columns[i] as TRxColumn;
CT:=C.Title as TRxColumnTitle;
if CT.CaptionLinesCount < FMaxTitleHeight then
begin
FWorksheet.MergeCells( FCurRow + CT.CaptionLinesCount, I, FCurRow + FMaxTitleHeight - 1, I);
end;
end;
end;
}
inc(FCurRow, FMaxTitleHeight);
end;