You've already forked lazarus-ccr
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:
@ -3,13 +3,13 @@
|
||||
<ProjectSession>
|
||||
<Version Value="9"/>
|
||||
<BuildModes Active="Default"/>
|
||||
<Units Count="6">
|
||||
<Units Count="9">
|
||||
<Unit0>
|
||||
<Filename Value="project1.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<CursorPos Y="20"/>
|
||||
<UsageCount Value="21"/>
|
||||
<UsageCount Value="32"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
@ -20,24 +20,24 @@
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Unit1"/>
|
||||
<TopLine Value="3"/>
|
||||
<CursorPos X="5" Y="22"/>
|
||||
<UsageCount Value="21"/>
|
||||
<CursorPos X="16" Y="18"/>
|
||||
<UsageCount Value="32"/>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="../../../fpspreadsheet/fpspreadsheet.pas"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="4364"/>
|
||||
<CursorPos Y="4385"/>
|
||||
<UsageCount Value="10"/>
|
||||
<TopLine Value="874"/>
|
||||
<CursorPos X="78" Y="863"/>
|
||||
<UsageCount Value="15"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="unit1.lfm"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="223"/>
|
||||
<CursorPos X="56" Y="250"/>
|
||||
<UsageCount Value="10"/>
|
||||
<UsageCount Value="9"/>
|
||||
<DefaultSyntaxHighlighter Value="LFM"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
@ -45,140 +45,163 @@
|
||||
<UnitName Value="RxDBGridExportSpreadSheet"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<TopLine Value="317"/>
|
||||
<CursorPos X="13" Y="334"/>
|
||||
<UsageCount Value="10"/>
|
||||
<TopLine Value="345"/>
|
||||
<CursorPos X="40" Y="358"/>
|
||||
<UsageCount Value="15"/>
|
||||
<Bookmarks Count="1">
|
||||
<Item0 Y="404" ID="1"/>
|
||||
</Bookmarks>
|
||||
<Loaded Value="True"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="../../rxdbgrid.pas"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<TopLine Value="290"/>
|
||||
<CursorPos X="14" Y="307"/>
|
||||
<UsageCount Value="10"/>
|
||||
<Loaded Value="True"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<TopLine Value="913"/>
|
||||
<CursorPos X="3" Y="914"/>
|
||||
<UsageCount Value="15"/>
|
||||
</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>
|
||||
<JumpHistory Count="30" HistoryIndex="28">
|
||||
<JumpHistory Count="28" HistoryIndex="27">
|
||||
<Position1>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="375" Column="3" TopLine="355"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="15" Column="27"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="337" Column="83" TopLine="311"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="16" Column="33"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="329" Column="31" TopLine="322"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="52" Column="22" TopLine="11"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="343" Column="9" TopLine="324"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="53" Column="22" TopLine="11"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="345" TopLine="327"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="54" Column="22" TopLine="12"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="61" Column="14" TopLine="42"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="55" Column="22" TopLine="13"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="368" TopLine="348"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="57" Column="22" TopLine="15"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="365" TopLine="331"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="53" Column="50" TopLine="22"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="345" Column="7" TopLine="325"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="69" Column="57" TopLine="30"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="391" Column="7" TopLine="374"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="67" Column="40" TopLine="36"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="346" Column="15" TopLine="328"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="52" Column="59" TopLine="32"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="347" Column="46" TopLine="329"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="48" Column="49" TopLine="8"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="349" Column="14" TopLine="332"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="8" Column="75" TopLine="8"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="351" TopLine="333"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="23" Column="22" TopLine="8"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="356" Column="50" TopLine="338"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="22" Column="26" TopLine="8"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="359" Column="50" TopLine="341"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="23" Column="60" TopLine="8"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="345" Column="38" TopLine="331"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="83" TopLine="48"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="358" Column="96" TopLine="341"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="77" TopLine="43"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="138" TopLine="122"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="67" TopLine="43"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="139" TopLine="122"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="72" Column="35" TopLine="43"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="140" TopLine="122"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="23" Column="46" TopLine="10"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="141" TopLine="122"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="25" Column="27" TopLine="10"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="142" TopLine="122"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="53" Column="99" TopLine="41"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="144" TopLine="122"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="52" Column="9" TopLine="40"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="199" TopLine="181"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="../../rxdbgrid.pas"/>
|
||||
<Caret Line="1552" Column="3" TopLine="1550"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="200" Column="34" TopLine="181"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="52" Column="9" TopLine="40"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="211" TopLine="181"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="22" Column="5" TopLine="3"/>
|
||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||
<Caret Line="96" Column="69" TopLine="39"/>
|
||||
</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>
|
||||
</ProjectSession>
|
||||
</CONFIG>
|
||||
|
@ -43,7 +43,22 @@ object Form1: TForm1
|
||||
Filter.EmptyValue = '(Нет)'
|
||||
Filter.EmptyFont.Style = [fsItalic]
|
||||
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
|
||||
item
|
||||
Title.Alignment = taCenter
|
||||
@ -59,7 +74,22 @@ object Form1: TForm1
|
||||
Footer.Alignment = taRightJustify
|
||||
Footer.FieldName = 'PRICE'
|
||||
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>
|
||||
KeyStrokes = <
|
||||
item
|
||||
@ -119,10 +149,10 @@ object Form1: TForm1
|
||||
end>
|
||||
FooterOptions.Active = True
|
||||
FooterOptions.Color = clYellow
|
||||
FooterOptions.RowCount = 1
|
||||
FooterOptions.RowCount = 3
|
||||
OptionsRx = [rdgAllowColumnsForm, rdgAllowDialogFind, rdgFooterRows, rdgAllowToolMenu]
|
||||
FooterColor = clYellow
|
||||
FooterRowCount = 1
|
||||
FooterRowCount = 3
|
||||
Align = alClient
|
||||
Color = clWindow
|
||||
DrawFullLine = False
|
||||
@ -250,7 +280,7 @@ object Form1: TForm1
|
||||
ShowSetupForm = True
|
||||
OnBeforeExecute = RxDBGridExportSpreadSheet1BeforeExecute
|
||||
PageName = 'Test page'
|
||||
Options = [ressExportTitle, ressExportColors, ressExportFooter, ressOverwriteExisting]
|
||||
Options = [ressExportTitle, ressExportColors, ressExportFooter, ressExportFormula, ressOverwriteExisting]
|
||||
OpenAfterExport = True
|
||||
left = 336
|
||||
top = 256
|
||||
|
@ -95,6 +95,10 @@ msgstr ""
|
||||
msgid "Export file name"
|
||||
msgstr ""
|
||||
|
||||
#: rxdconst.sexportformula
|
||||
msgid "Export footer formula"
|
||||
msgstr ""
|
||||
|
||||
#: rxdconst.sexprbadcompare
|
||||
#, fuzzy
|
||||
#| msgid "Compare opertion need fielad and const"
|
||||
|
@ -93,6 +93,10 @@ msgstr ""
|
||||
msgid "Export file name"
|
||||
msgstr ""
|
||||
|
||||
#: rxdconst.sexportformula
|
||||
msgid "Export footer formula"
|
||||
msgstr ""
|
||||
|
||||
#: rxdconst.sexprbadcompare
|
||||
msgid "Compare opertion needs field and const"
|
||||
msgstr ""
|
||||
|
@ -95,6 +95,10 @@ msgstr ""
|
||||
msgid "Export file name"
|
||||
msgstr ""
|
||||
|
||||
#: rxdconst.sexportformula
|
||||
msgid "Export footer formula"
|
||||
msgstr ""
|
||||
|
||||
#: rxdconst.sexprbadcompare
|
||||
#, fuzzy
|
||||
#| msgid "Compare opertion need fielad and const"
|
||||
|
@ -102,6 +102,10 @@ msgstr "Експортувати заголовки стовпців"
|
||||
msgid "Export file name"
|
||||
msgstr "Експортувати назву файлу"
|
||||
|
||||
#: rxdconst.sexportformula
|
||||
msgid "Export footer formula"
|
||||
msgstr ""
|
||||
|
||||
# msgid "Compare opertion need fielad and const"
|
||||
#: rxdconst.sexprbadcompare
|
||||
msgid "Compare opertion needs field and const"
|
||||
|
@ -11,7 +11,7 @@
|
||||
</SearchPaths>
|
||||
</CompilerOptions>
|
||||
<License Value="LGPL"/>
|
||||
<Version Minor="9" Build="2"/>
|
||||
<Version Minor="9" Release="1" Build="5"/>
|
||||
<Files Count="3">
|
||||
<Item1>
|
||||
<Filename Value="rxdbgridexportspreadsheet.pas"/>
|
||||
|
@ -42,6 +42,7 @@ type
|
||||
TRxDBGridExportSpreadSheetOption = (ressExportTitle,
|
||||
ressExportColors,
|
||||
ressExportFooter,
|
||||
ressExportFormula,
|
||||
ressOverwriteExisting
|
||||
);
|
||||
|
||||
@ -57,11 +58,14 @@ type
|
||||
FOpenAfterExport: boolean;
|
||||
FOptions: TRxDBGridExportSpreadSheetOptions;
|
||||
FPageName: string;
|
||||
function ColIndex(ACol:TRxColumn):integer;
|
||||
protected
|
||||
FDataSet:TDataSet;
|
||||
FWorkbook: TsWorkbook;
|
||||
FWorksheet: TsWorksheet;
|
||||
FCurRow : integer;
|
||||
FFirstDataRow : integer;
|
||||
FLastDataRow : integer;
|
||||
FCurCol : integer;
|
||||
scColorBlack:TsColor;
|
||||
|
||||
@ -84,7 +88,7 @@ procedure Register;
|
||||
|
||||
implementation
|
||||
uses fpsallformats, LCLType, Forms, math, LazUTF8, rxdconst, Controls, LCLIntf,
|
||||
RxDBGridExportSpreadSheet_ParamsUnit, dbutils;
|
||||
RxDBGridExportSpreadSheet_ParamsUnit, dbutils, fpsutils;
|
||||
|
||||
{$R rxdbgridexportspreadsheet.res}
|
||||
|
||||
@ -98,6 +102,23 @@ const
|
||||
|
||||
{ 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;
|
||||
var
|
||||
i, k : Integer;
|
||||
@ -217,6 +238,7 @@ begin
|
||||
end;
|
||||
|
||||
inc(FCurRow, FMaxTitleHeight);
|
||||
FFirstDataRow:=FCurRow;
|
||||
end;
|
||||
|
||||
procedure TRxDBGridExportSpreadSheet.DoExportBody;
|
||||
@ -296,58 +318,94 @@ begin
|
||||
inc(FCurRow);
|
||||
FDataSet.Next;
|
||||
end;
|
||||
F.Free
|
||||
F.Free;
|
||||
FLastDataRow:=FCurRow-1;
|
||||
end;
|
||||
|
||||
procedure TRxDBGridExportSpreadSheet.DoExportFooter;
|
||||
var
|
||||
i : Integer;
|
||||
C : TRxColumn;
|
||||
CT : TRxColumnTitle;
|
||||
CC : TColor;
|
||||
FooterColor:TColor;
|
||||
|
||||
procedure OutFooterCellProps;
|
||||
{$IFDEF OLD_fpSPREADSHEET}
|
||||
var
|
||||
scColor : TsColor;
|
||||
{$ENDIF}
|
||||
begin
|
||||
CC:=FRxDBGrid.FooterOptions.Color;
|
||||
FCurCol:=0;
|
||||
for i:=0 to FRxDBGrid.Columns.Count - 1 do
|
||||
begin
|
||||
C:=FRxDBGrid.Columns[i] as TRxColumn;
|
||||
CT:=C.Title as TRxColumnTitle;
|
||||
if C.Visible then
|
||||
begin
|
||||
if (CC and SYS_COLOR_BASE) = 0 then
|
||||
if (FRxDBGrid.FooterOptions.Color and SYS_COLOR_BASE) = 0 then
|
||||
begin
|
||||
{$IFDEF OLD_fpSPREADSHEET}
|
||||
scColor:=FWorkbook.AddColorToPalette(CC);
|
||||
FWorksheet.WriteBackgroundColor(FCurRow,FCurCol, scColor);}
|
||||
{$ELSE}
|
||||
FWorksheet.WriteBackgroundColor(FCurRow,FCurCol, CC);
|
||||
FWorksheet.WriteBackgroundColor(FCurRow,FCurCol, FRxDBGrid.FooterOptions.Color);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
if (C.Footer.ValueType <> fvtNon) then
|
||||
begin
|
||||
if C.Footer.ValueType = fvtSum then
|
||||
begin
|
||||
//if C.Footer.FieldName;
|
||||
FWorksheet.WriteNumber(FCurRow, FCurCol, C.Footer.NumericValue, nfFixed, 2)
|
||||
end
|
||||
else
|
||||
FWorksheet.WriteUTF8Text(FCurRow, FCurCol, C.Footer.DisplayText);
|
||||
|
||||
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);
|
||||
|
||||
FWorksheet.WriteHorAlignment(FCurRow, FCurCol, ssAligns[C.Footer.Alignment]);
|
||||
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
|
||||
D:=ColIndex(RxDBGrid.ColumnByFieldName(Footer.FieldName));
|
||||
|
||||
if D>=0 then
|
||||
begin
|
||||
case Footer.ValueType of
|
||||
fvtSum:SF:='SUM';
|
||||
fvtMax:SF:='MIN';
|
||||
fvtMin:SF:='MAX';
|
||||
else
|
||||
SF:='Error!(';
|
||||
end;
|
||||
|
||||
FWorksheet.WriteFormula(FCurRow, FCurCol,
|
||||
Format('=%s(%s%d:%s%d)', [SF, GetColString(D), FFirstDataRow, GetColString(D), FLastDataRow]));
|
||||
end
|
||||
else
|
||||
begin
|
||||
FWorksheet.WriteNumber(FCurRow, FCurCol, Footer.NumericValue, nfFixed, 2);
|
||||
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(FCurRow);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TRxDBGridExportSpreadSheet.DoExportColWidth;
|
||||
@ -395,15 +453,16 @@ begin
|
||||
FWorkbook := TsWorkbook.Create;
|
||||
FWorksheet := FWorkbook.AddWorksheet(FPageName);
|
||||
try
|
||||
// scColorBlack:=FWorkbook.AddColorToPalette(FRxDBGrid.GridLineColor);
|
||||
scColorBlack:=FRxDBGrid.GridLineColor;
|
||||
FCurRow:=0;
|
||||
FFirstDataRow:=0;
|
||||
FLastDataRow:=-1;
|
||||
|
||||
if ressExportTitle in FOptions then
|
||||
DoExportTitle;
|
||||
DoExportBody;
|
||||
|
||||
if ressExportFooter in FOptions then
|
||||
if (ressExportFooter in FOptions) and (RxDBGrid.FooterOptions.Active) and (RxDBGrid.FooterOptions.RowCount>0) then
|
||||
DoExportFooter;
|
||||
|
||||
DoExportColWidth;
|
||||
@ -436,6 +495,8 @@ begin
|
||||
F.cbExportColumnHeader.Checked:=ressExportTitle in FOptions;
|
||||
F.cbExportCellColors.Checked:=ressExportColors in FOptions;
|
||||
F.cbOverwriteExisting.Checked:=ressOverwriteExisting in FOptions;
|
||||
F.cbExportFormula.Checked:=ressExportFormula in FOptions;
|
||||
|
||||
F.edtPageName.Text:=FPageName;
|
||||
|
||||
Result:=F.ShowModal = mrOk;
|
||||
@ -454,6 +515,9 @@ begin
|
||||
FOptions :=FOptions + [ressExportColors];
|
||||
if F.cbOverwriteExisting.Checked then
|
||||
FOptions :=FOptions + [ressOverwriteExisting];
|
||||
if F.cbExportFormula.Checked then
|
||||
FOptions :=FOptions + [ressExportFormula];
|
||||
|
||||
end;
|
||||
F.Free;
|
||||
end;
|
||||
|
@ -1,21 +1,21 @@
|
||||
object RxDBGridExportSpreadSheet_ParamsForm: TRxDBGridExportSpreadSheet_ParamsForm
|
||||
Left = 732
|
||||
Height = 236
|
||||
Height = 246
|
||||
Top = 338
|
||||
Width = 548
|
||||
Caption = 'Export params'
|
||||
ClientHeight = 236
|
||||
ClientHeight = 246
|
||||
ClientWidth = 548
|
||||
OnCreate = FormCreate
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '1.3'
|
||||
LCLVersion = '1.7'
|
||||
object Label1: TLabel
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = Owner
|
||||
Left = 6
|
||||
Height = 21
|
||||
Height = 20
|
||||
Top = 6
|
||||
Width = 105
|
||||
Width = 106
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'Export file name'
|
||||
FocusControl = FileNameEdit1
|
||||
@ -28,8 +28,8 @@ object RxDBGridExportSpreadSheet_ParamsForm: TRxDBGridExportSpreadSheet_ParamsFo
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 12
|
||||
Height = 31
|
||||
Top = 33
|
||||
Height = 30
|
||||
Top = 32
|
||||
Width = 530
|
||||
Filter = 'All files (*.*)|*.*|LibreOffice/OpenOffice (*.ods)|*.ods|Excell 97-2003|*.xls|Excell 2007-2013|*.xlxs'
|
||||
FilterIndex = 0
|
||||
@ -46,8 +46,8 @@ object RxDBGridExportSpreadSheet_ParamsForm: TRxDBGridExportSpreadSheet_ParamsFo
|
||||
AnchorSideTop.Control = cbOverwriteExisting
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 280
|
||||
Height = 21
|
||||
Top = 99
|
||||
Height = 20
|
||||
Top = 128
|
||||
Width = 71
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'Page name'
|
||||
@ -61,41 +61,41 @@ object RxDBGridExportSpreadSheet_ParamsForm: TRxDBGridExportSpreadSheet_ParamsFo
|
||||
AnchorSideRight.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
Left = 286
|
||||
Height = 31
|
||||
Top = 126
|
||||
Height = 30
|
||||
Top = 154
|
||||
Width = 256
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
BorderSpacing.Around = 6
|
||||
TabOrder = 1
|
||||
TabOrder = 7
|
||||
end
|
||||
object cbExportColumnFooter: TCheckBox
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = cbExportColumnHeader
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 23
|
||||
Height = 24
|
||||
Top = 128
|
||||
Width = 161
|
||||
Width = 162
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'Export column footer'
|
||||
TabOrder = 2
|
||||
TabOrder = 3
|
||||
end
|
||||
object cbOpenAfterExport: TCheckBox
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = FileNameEdit1
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 23
|
||||
Top = 70
|
||||
Width = 140
|
||||
Height = 24
|
||||
Top = 68
|
||||
Width = 141
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'Open after export'
|
||||
TabOrder = 3
|
||||
TabOrder = 1
|
||||
end
|
||||
object ButtonPanel1: TButtonPanel
|
||||
Left = 6
|
||||
Height = 41
|
||||
Top = 189
|
||||
Height = 42
|
||||
Top = 198
|
||||
Width = 536
|
||||
OKButton.Name = 'OKButton'
|
||||
OKButton.DefaultCaption = True
|
||||
@ -105,7 +105,7 @@ object RxDBGridExportSpreadSheet_ParamsForm: TRxDBGridExportSpreadSheet_ParamsFo
|
||||
CloseButton.DefaultCaption = True
|
||||
CancelButton.Name = 'CancelButton'
|
||||
CancelButton.DefaultCaption = True
|
||||
TabOrder = 4
|
||||
TabOrder = 8
|
||||
ShowButtons = [pbOK, pbCancel, pbHelp]
|
||||
end
|
||||
object cbExportColumnHeader: TCheckBox
|
||||
@ -113,24 +113,24 @@ object RxDBGridExportSpreadSheet_ParamsForm: TRxDBGridExportSpreadSheet_ParamsFo
|
||||
AnchorSideTop.Control = cbOpenAfterExport
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 23
|
||||
Top = 99
|
||||
Width = 165
|
||||
Height = 24
|
||||
Top = 98
|
||||
Width = 166
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'Export column header'
|
||||
TabOrder = 5
|
||||
TabOrder = 2
|
||||
end
|
||||
object cbExportCellColors: TCheckBox
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = cbExportColumnFooter
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 23
|
||||
Top = 157
|
||||
Width = 136
|
||||
Height = 24
|
||||
Top = 158
|
||||
Width = 137
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'Export cell colors'
|
||||
TabOrder = 6
|
||||
TabOrder = 4
|
||||
end
|
||||
object Label4: TLabel
|
||||
AnchorSideLeft.Control = Owner
|
||||
@ -143,15 +143,27 @@ object RxDBGridExportSpreadSheet_ParamsForm: TRxDBGridExportSpreadSheet_ParamsFo
|
||||
ParentColor = False
|
||||
end
|
||||
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
|
||||
AnchorSideTop.Control = FileNameEdit1
|
||||
AnchorSideTop.Side = asrBottom
|
||||
Left = 280
|
||||
Height = 23
|
||||
Top = 70
|
||||
Width = 166
|
||||
Height = 24
|
||||
Top = 68
|
||||
Width = 120
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'Overwrite existing file'
|
||||
TabOrder = 7
|
||||
Caption = 'Export formula'
|
||||
TabOrder = 5
|
||||
end
|
||||
end
|
||||
|
@ -45,6 +45,7 @@ type
|
||||
|
||||
TRxDBGridExportSpreadSheet_ParamsForm = class(TForm)
|
||||
ButtonPanel1: TButtonPanel;
|
||||
cbExportFormula: TCheckBox;
|
||||
cbExportColumnFooter: TCheckBox;
|
||||
cbOpenAfterExport: TCheckBox;
|
||||
cbExportColumnHeader: TCheckBox;
|
||||
@ -78,6 +79,7 @@ begin
|
||||
cbExportColumnFooter.Caption:=sExportColumnFooter;
|
||||
cbExportCellColors.Caption:=sExportCellColors;
|
||||
cbOverwriteExisting.Caption:=sOverwriteExisting;
|
||||
cbExportFormula.Caption:=sExportFormula;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -179,6 +179,7 @@ resourcestring
|
||||
sExportColumnHeader = 'Export column header';
|
||||
sExportColumnFooter = 'Export column footer';
|
||||
sExportCellColors = 'Export cell colors';
|
||||
sExportFormula = 'Export footer formula';
|
||||
sOverwriteExisting = 'Overwrite existing';
|
||||
sShowColumnHeaderOnAllPage = 'Show column header on all pages';
|
||||
sPageMargins = 'Page margins';
|
||||
|
Reference in New Issue
Block a user