RxFPC:TRxDBGridExportSpreadSheet - export footer SUM,MIN and MAX values as formula

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4589 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2016-03-24 13:13:58 +00:00
parent 5d05fb1959
commit 8ac210069d
11 changed files with 309 additions and 161 deletions

View File

@ -3,13 +3,13 @@
<ProjectSession> <ProjectSession>
<Version Value="9"/> <Version Value="9"/>
<BuildModes Active="Default"/> <BuildModes Active="Default"/>
<Units Count="6"> <Units Count="9">
<Unit0> <Unit0>
<Filename Value="project1.lpr"/> <Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="1"/> <EditorIndex Value="1"/>
<CursorPos Y="20"/> <CursorPos Y="20"/>
<UsageCount Value="21"/> <UsageCount Value="32"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
@ -20,24 +20,24 @@
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/> <UnitName Value="Unit1"/>
<TopLine Value="3"/> <TopLine Value="3"/>
<CursorPos X="5" Y="22"/> <CursorPos X="16" Y="18"/>
<UsageCount Value="21"/> <UsageCount Value="32"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
</Unit1> </Unit1>
<Unit2> <Unit2>
<Filename Value="../../../fpspreadsheet/fpspreadsheet.pas"/> <Filename Value="../../../fpspreadsheet/fpspreadsheet.pas"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="4364"/> <TopLine Value="874"/>
<CursorPos Y="4385"/> <CursorPos X="78" Y="863"/>
<UsageCount Value="10"/> <UsageCount Value="15"/>
</Unit2> </Unit2>
<Unit3> <Unit3>
<Filename Value="unit1.lfm"/> <Filename Value="unit1.lfm"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="223"/> <TopLine Value="223"/>
<CursorPos X="56" Y="250"/> <CursorPos X="56" Y="250"/>
<UsageCount Value="10"/> <UsageCount Value="9"/>
<DefaultSyntaxHighlighter Value="LFM"/> <DefaultSyntaxHighlighter Value="LFM"/>
</Unit3> </Unit3>
<Unit4> <Unit4>
@ -45,140 +45,163 @@
<UnitName Value="RxDBGridExportSpreadSheet"/> <UnitName Value="RxDBGridExportSpreadSheet"/>
<IsVisibleTab Value="True"/> <IsVisibleTab Value="True"/>
<EditorIndex Value="2"/> <EditorIndex Value="2"/>
<TopLine Value="317"/> <TopLine Value="345"/>
<CursorPos X="13" Y="334"/> <CursorPos X="40" Y="358"/>
<UsageCount Value="10"/> <UsageCount Value="15"/>
<Bookmarks Count="1">
<Item0 Y="404" ID="1"/>
</Bookmarks>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit4> </Unit4>
<Unit5> <Unit5>
<Filename Value="../../rxdbgrid.pas"/> <Filename Value="../../rxdbgrid.pas"/>
<EditorIndex Value="3"/> <EditorIndex Value="-1"/>
<TopLine Value="290"/> <TopLine Value="913"/>
<CursorPos X="14" Y="307"/> <CursorPos X="3" Y="914"/>
<UsageCount Value="10"/> <UsageCount Value="15"/>
<Loaded Value="True"/>
</Unit5> </Unit5>
<Unit6>
<Filename Value="../../../fpspreadsheet/fpsstrings.pas"/>
<UnitName Value="fpsStrings"/>
<EditorIndex Value="-1"/>
<CursorPos X="88" Y="14"/>
<UsageCount Value="9"/>
</Unit6>
<Unit7>
<Filename Value="../../rxdbgridexportspreadsheet_paramsunit.pas"/>
<ComponentName Value="RxDBGridExportSpreadSheet_ParamsForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="RxDBGridExportSpreadSheet_ParamsUnit"/>
<EditorIndex Value="3"/>
<TopLine Value="45"/>
<CursorPos X="43" Y="82"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit7>
<Unit8>
<Filename Value="../../rxdconst.pas"/>
<EditorIndex Value="4"/>
<TopLine Value="163"/>
<CursorPos X="17" Y="182"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit8>
</Units> </Units>
<JumpHistory Count="30" HistoryIndex="28"> <JumpHistory Count="28" HistoryIndex="27">
<Position1> <Position1>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="375" Column="3" TopLine="355"/>
</Position1> </Position1>
<Position2> <Position2>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="15" Column="27"/> <Caret Line="337" Column="83" TopLine="311"/>
</Position2> </Position2>
<Position3> <Position3>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="16" Column="33"/> <Caret Line="329" Column="31" TopLine="322"/>
</Position3> </Position3>
<Position4> <Position4>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="52" Column="22" TopLine="11"/> <Caret Line="343" Column="9" TopLine="324"/>
</Position4> </Position4>
<Position5> <Position5>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="53" Column="22" TopLine="11"/> <Caret Line="345" TopLine="327"/>
</Position5> </Position5>
<Position6> <Position6>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="54" Column="22" TopLine="12"/> <Caret Line="61" Column="14" TopLine="42"/>
</Position6> </Position6>
<Position7> <Position7>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="55" Column="22" TopLine="13"/> <Caret Line="368" TopLine="348"/>
</Position7> </Position7>
<Position8> <Position8>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="57" Column="22" TopLine="15"/> <Caret Line="365" TopLine="331"/>
</Position8> </Position8>
<Position9> <Position9>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="53" Column="50" TopLine="22"/> <Caret Line="345" Column="7" TopLine="325"/>
</Position9> </Position9>
<Position10> <Position10>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="69" Column="57" TopLine="30"/> <Caret Line="391" Column="7" TopLine="374"/>
</Position10> </Position10>
<Position11> <Position11>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="67" Column="40" TopLine="36"/> <Caret Line="346" Column="15" TopLine="328"/>
</Position11> </Position11>
<Position12> <Position12>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="52" Column="59" TopLine="32"/> <Caret Line="347" Column="46" TopLine="329"/>
</Position12> </Position12>
<Position13> <Position13>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="48" Column="49" TopLine="8"/> <Caret Line="349" Column="14" TopLine="332"/>
</Position13> </Position13>
<Position14> <Position14>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="8" Column="75" TopLine="8"/> <Caret Line="351" TopLine="333"/>
</Position14> </Position14>
<Position15> <Position15>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="23" Column="22" TopLine="8"/> <Caret Line="356" Column="50" TopLine="338"/>
</Position15> </Position15>
<Position16> <Position16>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="22" Column="26" TopLine="8"/> <Caret Line="359" Column="50" TopLine="341"/>
</Position16> </Position16>
<Position17> <Position17>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="23" Column="60" TopLine="8"/> <Caret Line="345" Column="38" TopLine="331"/>
</Position17> </Position17>
<Position18> <Position18>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="83" TopLine="48"/> <Caret Line="358" Column="96" TopLine="341"/>
</Position18> </Position18>
<Position19> <Position19>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="77" TopLine="43"/> <Caret Line="138" TopLine="122"/>
</Position19> </Position19>
<Position20> <Position20>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="67" TopLine="43"/> <Caret Line="139" TopLine="122"/>
</Position20> </Position20>
<Position21> <Position21>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="72" Column="35" TopLine="43"/> <Caret Line="140" TopLine="122"/>
</Position21> </Position21>
<Position22> <Position22>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="23" Column="46" TopLine="10"/> <Caret Line="141" TopLine="122"/>
</Position22> </Position22>
<Position23> <Position23>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="25" Column="27" TopLine="10"/> <Caret Line="142" TopLine="122"/>
</Position23> </Position23>
<Position24> <Position24>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="53" Column="99" TopLine="41"/> <Caret Line="144" TopLine="122"/>
</Position24> </Position24>
<Position25> <Position25>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="52" Column="9" TopLine="40"/> <Caret Line="199" TopLine="181"/>
</Position25> </Position25>
<Position26> <Position26>
<Filename Value="../../rxdbgrid.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="1552" Column="3" TopLine="1550"/> <Caret Line="200" Column="34" TopLine="181"/>
</Position26> </Position26>
<Position27> <Position27>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="52" Column="9" TopLine="40"/> <Caret Line="211" TopLine="181"/>
</Position27> </Position27>
<Position28> <Position28>
<Filename Value="unit1.pas"/> <Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="22" Column="5" TopLine="3"/> <Caret Line="96" Column="69" TopLine="39"/>
</Position28> </Position28>
<Position29>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="335" Column="70" TopLine="317"/>
</Position29>
<Position30>
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
<Caret Line="265" Column="71" TopLine="232"/>
</Position30>
</JumpHistory> </JumpHistory>
</ProjectSession> </ProjectSession>
</CONFIG> </CONFIG>

View File

@ -43,7 +43,22 @@ object Form1: TForm1
Filter.EmptyValue = '(Нет)' Filter.EmptyValue = '(Нет)'
Filter.EmptyFont.Style = [fsItalic] Filter.EmptyFont.Style = [fsItalic]
Filter.ItemIndex = -1 Filter.ItemIndex = -1
Footers = <> Footers = <
item
Alignment = taRightJustify
Value = 'Min value'
ValueType = fvtStaticText
end
item
Alignment = taRightJustify
Value = 'Max value'
ValueType = fvtStaticText
end
item
Alignment = taRightJustify
Value = 'Summa'
ValueType = fvtStaticText
end>
end end
item item
Title.Alignment = taCenter Title.Alignment = taCenter
@ -59,7 +74,22 @@ object Form1: TForm1
Footer.Alignment = taRightJustify Footer.Alignment = taRightJustify
Footer.FieldName = 'PRICE' Footer.FieldName = 'PRICE'
Footer.ValueType = fvtSum Footer.ValueType = fvtSum
Footers = <> Footers = <
item
Alignment = taRightJustify
FieldName = 'PRICE'
ValueType = fvtMin
end
item
Alignment = taRightJustify
FieldName = 'PRICE'
ValueType = fvtMax
end
item
Alignment = taRightJustify
FieldName = 'PRICE'
ValueType = fvtSum
end>
end> end>
KeyStrokes = < KeyStrokes = <
item item
@ -119,10 +149,10 @@ object Form1: TForm1
end> end>
FooterOptions.Active = True FooterOptions.Active = True
FooterOptions.Color = clYellow FooterOptions.Color = clYellow
FooterOptions.RowCount = 1 FooterOptions.RowCount = 3
OptionsRx = [rdgAllowColumnsForm, rdgAllowDialogFind, rdgFooterRows, rdgAllowToolMenu] OptionsRx = [rdgAllowColumnsForm, rdgAllowDialogFind, rdgFooterRows, rdgAllowToolMenu]
FooterColor = clYellow FooterColor = clYellow
FooterRowCount = 1 FooterRowCount = 3
Align = alClient Align = alClient
Color = clWindow Color = clWindow
DrawFullLine = False DrawFullLine = False
@ -250,7 +280,7 @@ object Form1: TForm1
ShowSetupForm = True ShowSetupForm = True
OnBeforeExecute = RxDBGridExportSpreadSheet1BeforeExecute OnBeforeExecute = RxDBGridExportSpreadSheet1BeforeExecute
PageName = 'Test page' PageName = 'Test page'
Options = [ressExportTitle, ressExportColors, ressExportFooter, ressOverwriteExisting] Options = [ressExportTitle, ressExportColors, ressExportFooter, ressExportFormula, ressOverwriteExisting]
OpenAfterExport = True OpenAfterExport = True
left = 336 left = 336
top = 256 top = 256

View File

@ -95,6 +95,10 @@ msgstr ""
msgid "Export file name" msgid "Export file name"
msgstr "" msgstr ""
#: rxdconst.sexportformula
msgid "Export footer formula"
msgstr ""
#: rxdconst.sexprbadcompare #: rxdconst.sexprbadcompare
#, fuzzy #, fuzzy
#| msgid "Compare opertion need fielad and const" #| msgid "Compare opertion need fielad and const"

View File

@ -93,6 +93,10 @@ msgstr ""
msgid "Export file name" msgid "Export file name"
msgstr "" msgstr ""
#: rxdconst.sexportformula
msgid "Export footer formula"
msgstr ""
#: rxdconst.sexprbadcompare #: rxdconst.sexprbadcompare
msgid "Compare opertion needs field and const" msgid "Compare opertion needs field and const"
msgstr "" msgstr ""

View File

@ -95,6 +95,10 @@ msgstr ""
msgid "Export file name" msgid "Export file name"
msgstr "" msgstr ""
#: rxdconst.sexportformula
msgid "Export footer formula"
msgstr ""
#: rxdconst.sexprbadcompare #: rxdconst.sexprbadcompare
#, fuzzy #, fuzzy
#| msgid "Compare opertion need fielad and const" #| msgid "Compare opertion need fielad and const"

View File

@ -102,6 +102,10 @@ msgstr "Експортувати заголовки стовпців"
msgid "Export file name" msgid "Export file name"
msgstr "Експортувати назву файлу" msgstr "Експортувати назву файлу"
#: rxdconst.sexportformula
msgid "Export footer formula"
msgstr ""
# msgid "Compare opertion need fielad and const" # msgid "Compare opertion need fielad and const"
#: rxdconst.sexprbadcompare #: rxdconst.sexprbadcompare
msgid "Compare opertion needs field and const" msgid "Compare opertion needs field and const"

View File

@ -11,7 +11,7 @@
</SearchPaths> </SearchPaths>
</CompilerOptions> </CompilerOptions>
<License Value="LGPL"/> <License Value="LGPL"/>
<Version Minor="9" Build="2"/> <Version Minor="9" Release="1" Build="5"/>
<Files Count="3"> <Files Count="3">
<Item1> <Item1>
<Filename Value="rxdbgridexportspreadsheet.pas"/> <Filename Value="rxdbgridexportspreadsheet.pas"/>

View File

@ -42,6 +42,7 @@ type
TRxDBGridExportSpreadSheetOption = (ressExportTitle, TRxDBGridExportSpreadSheetOption = (ressExportTitle,
ressExportColors, ressExportColors,
ressExportFooter, ressExportFooter,
ressExportFormula,
ressOverwriteExisting ressOverwriteExisting
); );
@ -57,11 +58,14 @@ type
FOpenAfterExport: boolean; FOpenAfterExport: boolean;
FOptions: TRxDBGridExportSpreadSheetOptions; FOptions: TRxDBGridExportSpreadSheetOptions;
FPageName: string; FPageName: string;
function ColIndex(ACol:TRxColumn):integer;
protected protected
FDataSet:TDataSet; FDataSet:TDataSet;
FWorkbook: TsWorkbook; FWorkbook: TsWorkbook;
FWorksheet: TsWorksheet; FWorksheet: TsWorksheet;
FCurRow : integer; FCurRow : integer;
FFirstDataRow : integer;
FLastDataRow : integer;
FCurCol : integer; FCurCol : integer;
scColorBlack:TsColor; scColorBlack:TsColor;
@ -84,7 +88,7 @@ procedure Register;
implementation implementation
uses fpsallformats, LCLType, Forms, math, LazUTF8, rxdconst, Controls, LCLIntf, uses fpsallformats, LCLType, Forms, math, LazUTF8, rxdconst, Controls, LCLIntf,
RxDBGridExportSpreadSheet_ParamsUnit, dbutils; RxDBGridExportSpreadSheet_ParamsUnit, dbutils, fpsutils;
{$R rxdbgridexportspreadsheet.res} {$R rxdbgridexportspreadsheet.res}
@ -98,6 +102,23 @@ const
{ TRxDBGridExportSpeadSheet } { TRxDBGridExportSpeadSheet }
function TRxDBGridExportSpreadSheet.ColIndex(ACol: TRxColumn): integer;
var
C: TRxColumn;
i: Integer;
begin
Result:=-1;
if (not Assigned(ACol)) or (not ACol.Visible) then exit;
for i:=0 to FRxDBGrid.Columns.Count - 1 do
begin
C:=FRxDBGrid.Columns[i] as TRxColumn;
if C.Visible then
Inc(Result);
if ACol = C then
Exit;
end;
end;
procedure TRxDBGridExportSpreadSheet.DoExportTitle; procedure TRxDBGridExportSpreadSheet.DoExportTitle;
var var
i, k : Integer; i, k : Integer;
@ -217,6 +238,7 @@ begin
end; end;
inc(FCurRow, FMaxTitleHeight); inc(FCurRow, FMaxTitleHeight);
FFirstDataRow:=FCurRow;
end; end;
procedure TRxDBGridExportSpreadSheet.DoExportBody; procedure TRxDBGridExportSpreadSheet.DoExportBody;
@ -296,57 +318,93 @@ begin
inc(FCurRow); inc(FCurRow);
FDataSet.Next; FDataSet.Next;
end; end;
F.Free F.Free;
FLastDataRow:=FCurRow-1;
end; end;
procedure TRxDBGridExportSpreadSheet.DoExportFooter; procedure TRxDBGridExportSpreadSheet.DoExportFooter;
var var
i : Integer; FooterColor:TColor;
C : TRxColumn;
CT : TRxColumnTitle; procedure OutFooterCellProps;
CC : TColor; {$IFDEF OLD_fpSPREADSHEET}
{$IFDEF OLD_fpSPREADSHEET} var
scColor : TsColor; scColor : TsColor;
{$ENDIF} {$ENDIF}
begin begin
CC:=FRxDBGrid.FooterOptions.Color; if (FRxDBGrid.FooterOptions.Color and SYS_COLOR_BASE) = 0 then
FCurCol:=0;
for i:=0 to FRxDBGrid.Columns.Count - 1 do
begin begin
C:=FRxDBGrid.Columns[i] as TRxColumn; {$IFDEF OLD_fpSPREADSHEET}
CT:=C.Title as TRxColumnTitle; scColor:=FWorkbook.AddColorToPalette(CC);
if C.Visible then FWorksheet.WriteBackgroundColor(FCurRow,FCurCol, scColor);}
{$ELSE}
FWorksheet.WriteBackgroundColor(FCurRow,FCurCol, FRxDBGrid.FooterOptions.Color);
{$ENDIF}
end;
FWorksheet.WriteBorders(FCurRow,FCurCol, [cbNorth, cbWest, cbEast, cbSouth]);
FWorksheet.WriteBorderColor(FCurRow,FCurCol, cbNorth, scColorBlack);
FWorksheet.WriteBorderColor(FCurRow,FCurCol, cbWest, scColorBlack);
FWorksheet.WriteBorderColor(FCurRow,FCurCol, cbEast, scColorBlack);
FWorksheet.WriteBorderColor(FCurRow,FCurCol, cbSouth, scColorBlack);
end;
procedure OutFooterCell(Footer: TRxColumnFooterItem);
var
D: Integer;
SF: String;
begin
if (Footer.ValueType <> fvtNon) then
begin
if (ressExportFormula in FOptions) and (Footer.ValueType in [fvtSum, fvtMax, fvtMin]) and (FFirstDataRow <= FLastDataRow) and (Footer.DisplayFormat = '') then
begin begin
if (CC and SYS_COLOR_BASE) = 0 then D:=ColIndex(RxDBGrid.ColumnByFieldName(Footer.FieldName));
begin
{$IFDEF OLD_fpSPREADSHEET}
scColor:=FWorkbook.AddColorToPalette(CC);
FWorksheet.WriteBackgroundColor(FCurRow,FCurCol, scColor);}
{$ELSE}
FWorksheet.WriteBackgroundColor(FCurRow,FCurCol, CC);
{$ENDIF}
end;
if (C.Footer.ValueType <> fvtNon) then if D>=0 then
begin begin
if C.Footer.ValueType = fvtSum then case Footer.ValueType of
begin fvtSum:SF:='SUM';
//if C.Footer.FieldName; fvtMax:SF:='MIN';
FWorksheet.WriteNumber(FCurRow, FCurCol, C.Footer.NumericValue, nfFixed, 2) fvtMin:SF:='MAX';
end
else else
FWorksheet.WriteUTF8Text(FCurRow, FCurCol, C.Footer.DisplayText); SF:='Error!(';
end;
FWorksheet.WriteBorders(FCurRow,FCurCol, [cbNorth, cbWest, cbEast, cbSouth]); FWorksheet.WriteFormula(FCurRow, FCurCol,
FWorksheet.WriteBorderColor(FCurRow,FCurCol, cbNorth, scColorBlack); Format('=%s(%s%d:%s%d)', [SF, GetColString(D), FFirstDataRow, GetColString(D), FLastDataRow]));
FWorksheet.WriteBorderColor(FCurRow,FCurCol, cbWest, scColorBlack); end
FWorksheet.WriteBorderColor(FCurRow,FCurCol, cbEast, scColorBlack); else
FWorksheet.WriteBorderColor(FCurRow,FCurCol, cbSouth, scColorBlack); begin
FWorksheet.WriteNumber(FCurRow, FCurCol, Footer.NumericValue, nfFixed, 2);
FWorksheet.WriteHorAlignment(FCurRow, FCurCol, ssAligns[C.Footer.Alignment]); end;
end
else
FWorksheet.WriteUTF8Text(FCurRow, FCurCol, Footer.DisplayText);
FWorksheet.WriteHorAlignment(FCurRow, FCurCol, ssAligns[Footer.Alignment]);
end;
end;
var
i , j: Integer;
C : TRxColumn;
begin
for j:=0 to FRxDBGrid.FooterOptions.RowCount-1 do
begin
FCurCol:=0;
for i:=0 to FRxDBGrid.Columns.Count - 1 do
begin
C:=FRxDBGrid.Columns[i] as TRxColumn;
if C.Visible then
begin
OutFooterCellProps;
if C.Footers.Count>j then
OutFooterCell(C.Footers[j])
else
if J=0 then
OutFooterCell(C.Footer);
inc(FCurCol);
end; end;
inc(FCurCol);
end; end;
Inc(FCurRow);
end; end;
end; end;
@ -395,15 +453,16 @@ begin
FWorkbook := TsWorkbook.Create; FWorkbook := TsWorkbook.Create;
FWorksheet := FWorkbook.AddWorksheet(FPageName); FWorksheet := FWorkbook.AddWorksheet(FPageName);
try try
// scColorBlack:=FWorkbook.AddColorToPalette(FRxDBGrid.GridLineColor);
scColorBlack:=FRxDBGrid.GridLineColor; scColorBlack:=FRxDBGrid.GridLineColor;
FCurRow:=0; FCurRow:=0;
FFirstDataRow:=0;
FLastDataRow:=-1;
if ressExportTitle in FOptions then if ressExportTitle in FOptions then
DoExportTitle; DoExportTitle;
DoExportBody; DoExportBody;
if ressExportFooter in FOptions then if (ressExportFooter in FOptions) and (RxDBGrid.FooterOptions.Active) and (RxDBGrid.FooterOptions.RowCount>0) then
DoExportFooter; DoExportFooter;
DoExportColWidth; DoExportColWidth;
@ -436,6 +495,8 @@ begin
F.cbExportColumnHeader.Checked:=ressExportTitle in FOptions; F.cbExportColumnHeader.Checked:=ressExportTitle in FOptions;
F.cbExportCellColors.Checked:=ressExportColors in FOptions; F.cbExportCellColors.Checked:=ressExportColors in FOptions;
F.cbOverwriteExisting.Checked:=ressOverwriteExisting in FOptions; F.cbOverwriteExisting.Checked:=ressOverwriteExisting in FOptions;
F.cbExportFormula.Checked:=ressExportFormula in FOptions;
F.edtPageName.Text:=FPageName; F.edtPageName.Text:=FPageName;
Result:=F.ShowModal = mrOk; Result:=F.ShowModal = mrOk;
@ -454,6 +515,9 @@ begin
FOptions :=FOptions + [ressExportColors]; FOptions :=FOptions + [ressExportColors];
if F.cbOverwriteExisting.Checked then if F.cbOverwriteExisting.Checked then
FOptions :=FOptions + [ressOverwriteExisting]; FOptions :=FOptions + [ressOverwriteExisting];
if F.cbExportFormula.Checked then
FOptions :=FOptions + [ressExportFormula];
end; end;
F.Free; F.Free;
end; end;

View File

@ -1,21 +1,21 @@
object RxDBGridExportSpreadSheet_ParamsForm: TRxDBGridExportSpreadSheet_ParamsForm object RxDBGridExportSpreadSheet_ParamsForm: TRxDBGridExportSpreadSheet_ParamsForm
Left = 732 Left = 732
Height = 236 Height = 246
Top = 338 Top = 338
Width = 548 Width = 548
Caption = 'Export params' Caption = 'Export params'
ClientHeight = 236 ClientHeight = 246
ClientWidth = 548 ClientWidth = 548
OnCreate = FormCreate OnCreate = FormCreate
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '1.3' LCLVersion = '1.7'
object Label1: TLabel object Label1: TLabel
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner AnchorSideTop.Control = Owner
Left = 6 Left = 6
Height = 21 Height = 20
Top = 6 Top = 6
Width = 105 Width = 106
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Export file name' Caption = 'Export file name'
FocusControl = FileNameEdit1 FocusControl = FileNameEdit1
@ -28,8 +28,8 @@ object RxDBGridExportSpreadSheet_ParamsForm: TRxDBGridExportSpreadSheet_ParamsFo
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 12 Left = 12
Height = 31 Height = 30
Top = 33 Top = 32
Width = 530 Width = 530
Filter = 'All files (*.*)|*.*|LibreOffice/OpenOffice (*.ods)|*.ods|Excell 97-2003|*.xls|Excell 2007-2013|*.xlxs' Filter = 'All files (*.*)|*.*|LibreOffice/OpenOffice (*.ods)|*.ods|Excell 97-2003|*.xls|Excell 2007-2013|*.xlxs'
FilterIndex = 0 FilterIndex = 0
@ -46,8 +46,8 @@ object RxDBGridExportSpreadSheet_ParamsForm: TRxDBGridExportSpreadSheet_ParamsFo
AnchorSideTop.Control = cbOverwriteExisting AnchorSideTop.Control = cbOverwriteExisting
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 280 Left = 280
Height = 21 Height = 20
Top = 99 Top = 128
Width = 71 Width = 71
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Page name' Caption = 'Page name'
@ -61,41 +61,41 @@ object RxDBGridExportSpreadSheet_ParamsForm: TRxDBGridExportSpreadSheet_ParamsFo
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 286 Left = 286
Height = 31 Height = 30
Top = 126 Top = 154
Width = 256 Width = 256
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
TabOrder = 1 TabOrder = 7
end end
object cbExportColumnFooter: TCheckBox object cbExportColumnFooter: TCheckBox
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
AnchorSideTop.Control = cbExportColumnHeader AnchorSideTop.Control = cbExportColumnHeader
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 23 Height = 24
Top = 128 Top = 128
Width = 161 Width = 162
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Export column footer' Caption = 'Export column footer'
TabOrder = 2 TabOrder = 3
end end
object cbOpenAfterExport: TCheckBox object cbOpenAfterExport: TCheckBox
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
AnchorSideTop.Control = FileNameEdit1 AnchorSideTop.Control = FileNameEdit1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 23 Height = 24
Top = 70 Top = 68
Width = 140 Width = 141
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Open after export' Caption = 'Open after export'
TabOrder = 3 TabOrder = 1
end end
object ButtonPanel1: TButtonPanel object ButtonPanel1: TButtonPanel
Left = 6 Left = 6
Height = 41 Height = 42
Top = 189 Top = 198
Width = 536 Width = 536
OKButton.Name = 'OKButton' OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True OKButton.DefaultCaption = True
@ -105,7 +105,7 @@ object RxDBGridExportSpreadSheet_ParamsForm: TRxDBGridExportSpreadSheet_ParamsFo
CloseButton.DefaultCaption = True CloseButton.DefaultCaption = True
CancelButton.Name = 'CancelButton' CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True CancelButton.DefaultCaption = True
TabOrder = 4 TabOrder = 8
ShowButtons = [pbOK, pbCancel, pbHelp] ShowButtons = [pbOK, pbCancel, pbHelp]
end end
object cbExportColumnHeader: TCheckBox object cbExportColumnHeader: TCheckBox
@ -113,24 +113,24 @@ object RxDBGridExportSpreadSheet_ParamsForm: TRxDBGridExportSpreadSheet_ParamsFo
AnchorSideTop.Control = cbOpenAfterExport AnchorSideTop.Control = cbOpenAfterExport
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 23 Height = 24
Top = 99 Top = 98
Width = 165 Width = 166
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Export column header' Caption = 'Export column header'
TabOrder = 5 TabOrder = 2
end end
object cbExportCellColors: TCheckBox object cbExportCellColors: TCheckBox
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
AnchorSideTop.Control = cbExportColumnFooter AnchorSideTop.Control = cbExportColumnFooter
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 23 Height = 24
Top = 157 Top = 158
Width = 136 Width = 137
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Export cell colors' Caption = 'Export cell colors'
TabOrder = 6 TabOrder = 4
end end
object Label4: TLabel object Label4: TLabel
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
@ -143,15 +143,27 @@ object RxDBGridExportSpreadSheet_ParamsForm: TRxDBGridExportSpreadSheet_ParamsFo
ParentColor = False ParentColor = False
end end
object cbOverwriteExisting: TCheckBox object cbOverwriteExisting: TCheckBox
AnchorSideLeft.Control = Label4
AnchorSideTop.Control = cbExportFormula
AnchorSideTop.Side = asrBottom
Left = 280
Height = 24
Top = 98
Width = 168
BorderSpacing.Around = 6
Caption = 'Overwrite existing file'
TabOrder = 6
end
object cbExportFormula: TCheckBox
AnchorSideLeft.Control = Label4 AnchorSideLeft.Control = Label4
AnchorSideTop.Control = FileNameEdit1 AnchorSideTop.Control = FileNameEdit1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 280 Left = 280
Height = 23 Height = 24
Top = 70 Top = 68
Width = 166 Width = 120
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Overwrite existing file' Caption = 'Export formula'
TabOrder = 7 TabOrder = 5
end end
end end

View File

@ -45,6 +45,7 @@ type
TRxDBGridExportSpreadSheet_ParamsForm = class(TForm) TRxDBGridExportSpreadSheet_ParamsForm = class(TForm)
ButtonPanel1: TButtonPanel; ButtonPanel1: TButtonPanel;
cbExportFormula: TCheckBox;
cbExportColumnFooter: TCheckBox; cbExportColumnFooter: TCheckBox;
cbOpenAfterExport: TCheckBox; cbOpenAfterExport: TCheckBox;
cbExportColumnHeader: TCheckBox; cbExportColumnHeader: TCheckBox;
@ -78,6 +79,7 @@ begin
cbExportColumnFooter.Caption:=sExportColumnFooter; cbExportColumnFooter.Caption:=sExportColumnFooter;
cbExportCellColors.Caption:=sExportCellColors; cbExportCellColors.Caption:=sExportCellColors;
cbOverwriteExisting.Caption:=sOverwriteExisting; cbOverwriteExisting.Caption:=sOverwriteExisting;
cbExportFormula.Caption:=sExportFormula;
end; end;
end. end.

View File

@ -179,6 +179,7 @@ resourcestring
sExportColumnHeader = 'Export column header'; sExportColumnHeader = 'Export column header';
sExportColumnFooter = 'Export column footer'; sExportColumnFooter = 'Export column footer';
sExportCellColors = 'Export cell colors'; sExportCellColors = 'Export cell colors';
sExportFormula = 'Export footer formula';
sOverwriteExisting = 'Overwrite existing'; sOverwriteExisting = 'Overwrite existing';
sShowColumnHeaderOnAllPage = 'Show column header on all pages'; sShowColumnHeaderOnAllPage = 'Show column header on all pages';
sPageMargins = 'Page margins'; sPageMargins = 'Page margins';