TRxDBGridExportSpreadSheet - footer colors and lockup fields

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3437 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2014-08-06 10:19:42 +00:00
parent 2ff6da7c68
commit f36775184f
4 changed files with 55 additions and 19 deletions

View File

@ -73,9 +73,8 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="RxDBGridMainUnit"/>
<IsVisibleTab Value="True"/>
<TopLine Value="66"/>
<CursorPos X="15" Y="79"/>
<TopLine Value="78"/>
<CursorPos Y="80"/>
<UsageCount Value="99"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
@ -101,6 +100,7 @@
<Unit5>
<Filename Value="../../rxdbgrid.pas"/>
<UnitName Value="rxdbgrid"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="3742"/>
<CursorPos Y="3763"/>
@ -709,7 +709,7 @@
<UsageCount Value="10"/>
</Unit102>
</Units>
<JumpHistory Count="14" HistoryIndex="13">
<JumpHistory Count="16" HistoryIndex="15">
<Position1>
<Filename Value="../../rxdbgrid.pas"/>
<Caret Line="867" Column="35" TopLine="845"/>
@ -766,6 +766,14 @@
<Filename Value="rxdbgridmainunit.pas"/>
<Caret Line="78" Column="15" TopLine="65"/>
</Position14>
<Position15>
<Filename Value="rxdbgridmainunit.pas"/>
<Caret Line="79" Column="15" TopLine="66"/>
</Position15>
<Position16>
<Filename Value="rxdbgridmainunit.pas"/>
<Caret Line="161" Column="62" TopLine="158"/>
</Position16>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>

View File

@ -9,6 +9,7 @@ object RxDBGridMainForm: TRxDBGridMainForm
ClientWidth = 1187
Menu = MainMenu1
OnCreate = FormCreate
SessionProperties = 'RxDBGridExportSpreadSheet1.FileName;RxDBGridExportSpreadSheet1.OpenAfterExport;RxDBGridExportSpreadSheet1.Options;RxDBGridExportSpreadSheet1.PageName;RxDBGridPrint1.Options;RxDBGridPrint1.Orientation;RxDBGridPrint1.PageMargin;RxDBGridPrint1.ReportTitle;RxDBGridPrint1.ShowColumnHeaderOnAllPage'
ShowHint = True
LCLVersion = '1.3'
object RxDBGrid1: TRxDBGrid
@ -18,6 +19,7 @@ object RxDBGridMainForm: TRxDBGridMainForm
Width = 1187
TitleButtons = True
AutoSort = True
OnGetCellProps = RxDBGrid1GetCellProps
Columns = <
item
Title.Alignment = taCenter
@ -43,6 +45,7 @@ object RxDBGridMainForm: TRxDBGridMainForm
)
end
item
Color = clSkyBlue
Title.Alignment = taCenter
Title.Caption = 'Code - ID'
Title.Orientation = toVertical90
@ -1343,6 +1346,7 @@ object RxDBGridMainForm: TRxDBGridMainForm
RxDBGrid = RxDBGrid1
Caption = 'Export data'
ShowSetupForm = True
FileName = 'RxDBGridDemo.ods'
PageName = 'RxDBGrid demo'
Options = [ressExportTitle, ressExportColors, ressExportFooter, ressOverwriteExisting]
left = 504

View File

@ -78,6 +78,8 @@ type
procedure FormCreate(Sender: TObject);
procedure hlpAboutExecute(Sender: TObject);
procedure RxDBGrid1Filtred(Sender: TObject);
procedure RxDBGrid1GetCellProps(Sender: TObject; Field: TField;
AFont: TFont; var Background: TColor);
procedure showColumnsDialogExecute(Sender: TObject);
procedure showFindDialogExecute(Sender: TObject);
procedure sysExitExecute(Sender: TObject);
@ -138,9 +140,6 @@ begin
RxMemoryData1.AppendRecord([16, 'Гарант', 480, 'Гарант', EncodeDate(2007, 2, 1), 3]);
RxMemoryData1.First;
// RxDBGrid1.CalcStatTotals; //fix error in GotoBookmark
end;
procedure TRxDBGridMainForm.hlpAboutExecute(Sender: TObject);
@ -153,6 +152,13 @@ begin
RxMemoryData1.First;
end;
procedure TRxDBGridMainForm.RxDBGrid1GetCellProps(Sender: TObject;
Field: TField; AFont: TFont; var Background: TColor);
begin
if (Field = RxMemoryData1PRICE1) and (RxMemoryData1PRICE1.AsFloat>99) then
Background:=clRed;
end;
procedure TRxDBGridMainForm.showColumnsDialogExecute(Sender: TObject);
begin

View File

@ -186,7 +186,11 @@ var
CT : TRxColumnTitle;
CC : TColor;
scColor : TsColor;
F:TFont;
S: String;
J: Integer;
begin
F:=TFont.Create;
FDataSet.First;
while not FDataSet.EOF do
begin
@ -197,13 +201,26 @@ begin
CT:=C.Title as TRxColumnTitle;
if C.Visible then
begin
FWorksheet.WriteUTF8Text(FCurRow, FCurCol, C.Field.DisplayText);
CC:=C.Color;
if (CC and SYS_COLOR_BASE) = 0 then
S:=C.Field.DisplayText;
if (C.KeyList.Count > 0) and (C.PickList.Count > 0) then
begin
// CC:=clWhite;
scColor:=FWorkbook.AddColorToPalette(CC);
FWorksheet.WriteBackgroundColor(FCurRow,FCurCol, scColor);
J := C.KeyList.IndexOf(S);
if (J >= 0) and (J < C.PickList.Count) then
S := C.PickList[j];
end;
FWorksheet.WriteUTF8Text(FCurRow, FCurCol, S);
if ressExportColors in FOptions then
begin
CC:=C.Color;
if Assigned(RxDBGrid.OnGetCellProps) then
RxDBGrid.OnGetCellProps(RxDBGrid, C.Field, F, CC);
if (CC and SYS_COLOR_BASE) = 0 then
begin
scColor:=FWorkbook.AddColorToPalette(CC);
FWorksheet.WriteBackgroundColor(FCurRow,FCurCol, scColor);
end;
end;
FWorksheet.WriteBorders(FCurRow,FCurCol, [cbNorth, cbWest, cbEast, cbSouth]);
@ -219,6 +236,7 @@ begin
inc(FCurRow);
FDataSet.Next;
end;
F.Free
end;
procedure TRxDBGridExportSpreadSheet.DoExportFooter;
@ -237,15 +255,15 @@ begin
CT:=C.Title as TRxColumnTitle;
if C.Visible then
begin
if (CC and SYS_COLOR_BASE) = 0 then
begin
scColor:=FWorkbook.AddColorToPalette(CC);
FWorksheet.WriteBackgroundColor(FCurRow,FCurCol, scColor);
end;
if (C.Footer.ValueType <> fvtNon) then
begin
FWorksheet.WriteUTF8Text(FCurRow, FCurCol, C.Footer.DisplayText);
if (CC and SYS_COLOR_BASE) = 0 then
begin
// CC:=clWhite;
scColor:=FWorkbook.AddColorToPalette(CC);
FWorksheet.WriteBackgroundColor(FCurRow,FCurCol, scColor);
end;
FWorksheet.WriteBorders(FCurRow,FCurCol, [cbNorth, cbWest, cbEast, cbSouth]);
FWorksheet.WriteBorderColor(FCurRow,FCurCol, cbNorth, scColorBlack);