You've already forked lazarus-ccr
RxFPC:TRxDBGridExportSpreadSheet allow export selected rows. tnx rellai2
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5359 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -9,7 +9,7 @@
|
|||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<EditorIndex Value="-1"/>
|
<EditorIndex Value="-1"/>
|
||||||
<CursorPos Y="20"/>
|
<CursorPos Y="20"/>
|
||||||
<UsageCount Value="32"/>
|
<UsageCount Value="33"/>
|
||||||
</Unit0>
|
</Unit0>
|
||||||
<Unit1>
|
<Unit1>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
@ -18,10 +18,9 @@
|
|||||||
<HasResources Value="True"/>
|
<HasResources Value="True"/>
|
||||||
<ResourceBaseClass Value="Form"/>
|
<ResourceBaseClass Value="Form"/>
|
||||||
<UnitName Value="Unit1"/>
|
<UnitName Value="Unit1"/>
|
||||||
<IsVisibleTab Value="True"/>
|
|
||||||
<TopLine Value="3"/>
|
<TopLine Value="3"/>
|
||||||
<CursorPos X="6" Y="84"/>
|
<CursorPos X="105" Y="24"/>
|
||||||
<UsageCount Value="32"/>
|
<UsageCount Value="33"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
<LoadedDesigner Value="True"/>
|
<LoadedDesigner Value="True"/>
|
||||||
</Unit1>
|
</Unit1>
|
||||||
@ -43,19 +42,17 @@
|
|||||||
<Unit4>
|
<Unit4>
|
||||||
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
<UnitName Value="RxDBGridExportSpreadSheet"/>
|
<UnitName Value="RxDBGridExportSpreadSheet"/>
|
||||||
<EditorIndex Value="-1"/>
|
<EditorIndex Value="1"/>
|
||||||
<TopLine Value="345"/>
|
<TopLine Value="197"/>
|
||||||
<CursorPos X="40" Y="358"/>
|
<CursorPos X="7" Y="217"/>
|
||||||
<UsageCount Value="15"/>
|
<UsageCount Value="15"/>
|
||||||
<Bookmarks Count="1">
|
<Loaded Value="True"/>
|
||||||
<Item0 Y="404" ID="1"/>
|
|
||||||
</Bookmarks>
|
|
||||||
</Unit4>
|
</Unit4>
|
||||||
<Unit5>
|
<Unit5>
|
||||||
<Filename Value="../../rxdbgrid.pas"/>
|
<Filename Value="../../rxdbgrid.pas"/>
|
||||||
<EditorIndex Value="1"/>
|
<EditorIndex Value="4"/>
|
||||||
<TopLine Value="5397"/>
|
<TopLine Value="4700"/>
|
||||||
<CursorPos X="54" Y="5421"/>
|
<CursorPos Y="4718"/>
|
||||||
<UsageCount Value="15"/>
|
<UsageCount Value="15"/>
|
||||||
<Bookmarks Count="2">
|
<Bookmarks Count="2">
|
||||||
<Item0 X="14" Y="822" ID="1"/>
|
<Item0 X="14" Y="822" ID="1"/>
|
||||||
@ -76,17 +73,21 @@
|
|||||||
<HasResources Value="True"/>
|
<HasResources Value="True"/>
|
||||||
<ResourceBaseClass Value="Form"/>
|
<ResourceBaseClass Value="Form"/>
|
||||||
<UnitName Value="RxDBGridExportSpreadSheet_ParamsUnit"/>
|
<UnitName Value="RxDBGridExportSpreadSheet_ParamsUnit"/>
|
||||||
<EditorIndex Value="-1"/>
|
<EditorIndex Value="2"/>
|
||||||
<TopLine Value="53"/>
|
<TopLine Value="51"/>
|
||||||
<CursorPos X="43" Y="82"/>
|
<CursorPos X="33" Y="85"/>
|
||||||
<UsageCount Value="11"/>
|
<UsageCount Value="11"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
|
<LoadedDesigner Value="True"/>
|
||||||
</Unit7>
|
</Unit7>
|
||||||
<Unit8>
|
<Unit8>
|
||||||
<Filename Value="../../rxdconst.pas"/>
|
<Filename Value="../../rxdconst.pas"/>
|
||||||
<EditorIndex Value="-1"/>
|
<IsVisibleTab Value="True"/>
|
||||||
<TopLine Value="163"/>
|
<EditorIndex Value="3"/>
|
||||||
<CursorPos X="17" Y="182"/>
|
<TopLine Value="173"/>
|
||||||
|
<CursorPos X="21" Y="185"/>
|
||||||
<UsageCount Value="11"/>
|
<UsageCount Value="11"/>
|
||||||
|
<Loaded Value="True"/>
|
||||||
</Unit8>
|
</Unit8>
|
||||||
<Unit9>
|
<Unit9>
|
||||||
<Filename Value="../../../../lcl/include/control.inc"/>
|
<Filename Value="../../../../lcl/include/control.inc"/>
|
||||||
@ -104,54 +105,127 @@
|
|||||||
<UsageCount Value="10"/>
|
<UsageCount Value="10"/>
|
||||||
</Unit10>
|
</Unit10>
|
||||||
</Units>
|
</Units>
|
||||||
<JumpHistory Count="9" HistoryIndex="8">
|
<JumpHistory Count="30" HistoryIndex="29">
|
||||||
<Position1>
|
<Position1>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="unit1.pas"/>
|
||||||
<Caret Line="73" TopLine="57"/>
|
<Caret Line="22" Column="5" TopLine="3"/>
|
||||||
</Position1>
|
</Position1>
|
||||||
<Position2>
|
<Position2>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
<Caret Line="78" TopLine="57"/>
|
<Caret Line="443" Column="3" TopLine="439"/>
|
||||||
</Position2>
|
</Position2>
|
||||||
<Position3>
|
<Position3>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
<Caret Line="78" TopLine="57"/>
|
<Caret Line="63" Column="30" TopLine="54"/>
|
||||||
</Position3>
|
</Position3>
|
||||||
<Position4>
|
<Position4>
|
||||||
<Filename Value="unit1.pas"/>
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
<Caret Line="84" Column="6" TopLine="3"/>
|
<Caret Line="504" Column="3" TopLine="500"/>
|
||||||
</Position4>
|
</Position4>
|
||||||
<Position5>
|
<Position5>
|
||||||
<Filename Value="../../rxdbgrid.pas"/>
|
<Filename Value="../../rxdbgridexportspreadsheet_paramsunit.pas"/>
|
||||||
<Caret Line="117" Column="37" TopLine="100"/>
|
<Caret Line="46" Column="3" TopLine="27"/>
|
||||||
</Position5>
|
</Position5>
|
||||||
<Position6>
|
<Position6>
|
||||||
<Filename Value="../../rxdbgrid.pas"/>
|
<Filename Value="../../rxdbgridexportspreadsheet_paramsunit.pas"/>
|
||||||
<Caret Line="990" Column="61" TopLine="959"/>
|
<Caret Line="85" Column="33" TopLine="51"/>
|
||||||
</Position6>
|
</Position6>
|
||||||
<Position7>
|
<Position7>
|
||||||
<Filename Value="../../rxdbgrid.pas"/>
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
<Caret Line="4542" Column="24" TopLine="4512"/>
|
<Caret Line="504" Column="3" TopLine="500"/>
|
||||||
</Position7>
|
</Position7>
|
||||||
<Position8>
|
<Position8>
|
||||||
<Filename Value="../../rxdbgrid.pas"/>
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
<Caret Line="5445" Column="9" TopLine="5409"/>
|
<Caret Line="47" Column="7" TopLine="23"/>
|
||||||
</Position8>
|
</Position8>
|
||||||
<Position9>
|
<Position9>
|
||||||
<Filename Value="../../rxdbgrid.pas"/>
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
<Caret Line="5425" Column="15" TopLine="5407"/>
|
<Caret Line="273" TopLine="250"/>
|
||||||
</Position9>
|
</Position9>
|
||||||
|
<Position10>
|
||||||
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
|
<Caret Line="329" TopLine="323"/>
|
||||||
|
</Position10>
|
||||||
|
<Position11>
|
||||||
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
|
<Caret Line="204" Column="3" TopLine="173"/>
|
||||||
|
</Position11>
|
||||||
|
<Position12>
|
||||||
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
|
<Caret Line="129" Column="3" TopLine="108"/>
|
||||||
|
</Position12>
|
||||||
|
<Position13>
|
||||||
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
|
<Caret Line="135" Column="9" TopLine="115"/>
|
||||||
|
</Position13>
|
||||||
|
<Position14>
|
||||||
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
|
<Caret Line="138" Column="7" TopLine="118"/>
|
||||||
|
</Position14>
|
||||||
|
<Position15>
|
||||||
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
|
<Caret Line="140" Column="7" TopLine="120"/>
|
||||||
|
</Position15>
|
||||||
|
<Position16>
|
||||||
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
|
<Caret Line="146" Column="11" TopLine="127"/>
|
||||||
|
</Position16>
|
||||||
|
<Position17>
|
||||||
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
|
<Caret Line="149" Column="13" TopLine="131"/>
|
||||||
|
</Position17>
|
||||||
|
<Position18>
|
||||||
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
|
<Caret Line="173" Column="11" TopLine="154"/>
|
||||||
|
</Position18>
|
||||||
|
<Position19>
|
||||||
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
|
<Caret Line="224" Column="11" TopLine="194"/>
|
||||||
|
</Position19>
|
||||||
|
<Position20>
|
||||||
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
|
<Caret Line="227" Column="13" TopLine="209"/>
|
||||||
|
</Position20>
|
||||||
|
<Position21>
|
||||||
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
|
<Caret Line="63" Column="24" TopLine="45"/>
|
||||||
|
</Position21>
|
||||||
|
<Position22>
|
||||||
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
|
<Caret Line="134" TopLine="116"/>
|
||||||
|
</Position22>
|
||||||
|
<Position23>
|
||||||
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
|
<Caret Line="168" Column="9" TopLine="147"/>
|
||||||
|
</Position23>
|
||||||
|
<Position24>
|
||||||
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
|
<Caret Line="174" TopLine="164"/>
|
||||||
|
</Position24>
|
||||||
|
<Position25>
|
||||||
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
|
<Caret Line="126" Column="38" TopLine="107"/>
|
||||||
|
</Position25>
|
||||||
|
<Position26>
|
||||||
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
|
<Caret Line="63" Column="15" TopLine="44"/>
|
||||||
|
</Position26>
|
||||||
|
<Position27>
|
||||||
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
|
<Caret Line="171" Column="59" TopLine="152"/>
|
||||||
|
</Position27>
|
||||||
|
<Position28>
|
||||||
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
|
<Caret Line="134" TopLine="126"/>
|
||||||
|
</Position28>
|
||||||
|
<Position29>
|
||||||
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
|
<Caret Line="203" Column="16" TopLine="184"/>
|
||||||
|
</Position29>
|
||||||
|
<Position30>
|
||||||
|
<Filename Value="../../rxdbgridexportspreadsheet.pas"/>
|
||||||
|
<Caret Line="193" TopLine="193"/>
|
||||||
|
</Position30>
|
||||||
</JumpHistory>
|
</JumpHistory>
|
||||||
</ProjectSession>
|
</ProjectSession>
|
||||||
<Debugging>
|
|
||||||
<BreakPoints Count="1">
|
|
||||||
<Item1>
|
|
||||||
<Kind Value="bpkSource"/>
|
|
||||||
<WatchScope Value="wpsLocal"/>
|
|
||||||
<WatchKind Value="wpkWrite"/>
|
|
||||||
<Source Value="../../rxdbgrid.pas"/>
|
|
||||||
<Line Value="4718"/>
|
|
||||||
</Item1>
|
|
||||||
</BreakPoints>
|
|
||||||
</Debugging>
|
|
||||||
</CONFIG>
|
</CONFIG>
|
||||||
|
@ -117,6 +117,10 @@ msgstr ""
|
|||||||
msgid "Export params"
|
msgid "Export params"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: rxdconst.sexportselectedrows
|
||||||
|
msgid "Export only selected rows"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: rxdconst.sexprbadcompare
|
#: rxdconst.sexprbadcompare
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
#| msgid "Compare opertion need fielad and const"
|
#| msgid "Compare opertion need fielad and const"
|
||||||
|
@ -113,6 +113,10 @@ msgstr ""
|
|||||||
msgid "Export params"
|
msgid "Export params"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: rxdconst.sexportselectedrows
|
||||||
|
msgid "Export only selected rows"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: rxdconst.sexprbadcompare
|
#: rxdconst.sexprbadcompare
|
||||||
msgid "Compare opertion needs field and const"
|
msgid "Compare opertion needs field and const"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -123,6 +123,10 @@ msgstr "Экспорт изображений"
|
|||||||
msgid "Export params"
|
msgid "Export params"
|
||||||
msgstr "Параметры экспорта"
|
msgstr "Параметры экспорта"
|
||||||
|
|
||||||
|
#: rxdconst.sexportselectedrows
|
||||||
|
msgid "Export only selected rows"
|
||||||
|
msgstr "Экспорт только помеченных строк"
|
||||||
|
|
||||||
#: rxdconst.sexprbadcompare
|
#: rxdconst.sexprbadcompare
|
||||||
msgid "Compare opertion needs field and const"
|
msgid "Compare opertion needs field and const"
|
||||||
msgstr "Операции сравнения требуют наличия поля и константы"
|
msgstr "Операции сравнения требуют наличия поля и константы"
|
||||||
|
@ -122,6 +122,10 @@ msgstr "Експортувати зображення"
|
|||||||
msgid "Export params"
|
msgid "Export params"
|
||||||
msgstr "Експортувати параметри"
|
msgstr "Експортувати параметри"
|
||||||
|
|
||||||
|
#: rxdconst.sexportselectedrows
|
||||||
|
msgid "Export only selected rows"
|
||||||
|
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"
|
||||||
|
@ -43,7 +43,8 @@ type
|
|||||||
ressExportColors,
|
ressExportColors,
|
||||||
ressExportFooter,
|
ressExportFooter,
|
||||||
ressExportFormula,
|
ressExportFormula,
|
||||||
ressOverwriteExisting
|
ressOverwriteExisting,
|
||||||
|
ressExportSelectedRows
|
||||||
);
|
);
|
||||||
|
|
||||||
TRxDBGridExportSpreadSheetOptions = set of TRxDBGridExportSpreadSheetOption;
|
TRxDBGridExportSpreadSheetOptions = set of TRxDBGridExportSpreadSheetOption;
|
||||||
@ -59,6 +60,9 @@ type
|
|||||||
FOptions: TRxDBGridExportSpreadSheetOptions;
|
FOptions: TRxDBGridExportSpreadSheetOptions;
|
||||||
FPageName: string;
|
FPageName: string;
|
||||||
function ColIndex(ACol:TRxColumn):integer;
|
function ColIndex(ACol:TRxColumn):integer;
|
||||||
|
procedure ExpCurRow(AFont: TFont);
|
||||||
|
procedure ExpAllRow;
|
||||||
|
procedure ExpSelectedRow;
|
||||||
protected
|
protected
|
||||||
FDataSet:TDataSet;
|
FDataSet:TDataSet;
|
||||||
FWorkbook: TsWorkbook;
|
FWorkbook: TsWorkbook;
|
||||||
@ -88,7 +92,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, rxdbutils, fpsutils;
|
RxDBGridExportSpreadSheet_ParamsUnit, rxdbutils, fpsutils, DBGrids;
|
||||||
|
|
||||||
{$R rxdbgridexportspreadsheet.res}
|
{$R rxdbgridexportspreadsheet.res}
|
||||||
|
|
||||||
@ -119,6 +123,106 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TRxDBGridExportSpreadSheet.ExpCurRow(AFont:TFont);
|
||||||
|
var
|
||||||
|
i, J: Integer;
|
||||||
|
C: TRxColumn;
|
||||||
|
CT: TRxColumnTitle;
|
||||||
|
S: String;
|
||||||
|
CC: TColor;
|
||||||
|
begin
|
||||||
|
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 Assigned(C.Field) then
|
||||||
|
begin
|
||||||
|
S:=C.Field.DisplayText;
|
||||||
|
if (C.KeyList.Count > 0) and (C.PickList.Count > 0) then
|
||||||
|
begin
|
||||||
|
J := C.KeyList.IndexOf(S);
|
||||||
|
if (J >= 0) and (J < C.PickList.Count) then
|
||||||
|
S := C.PickList[j];
|
||||||
|
FWorksheet.WriteUTF8Text(FCurRow, FCurCol, S);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if Assigned(C.Field.OnGetText) then
|
||||||
|
FWorksheet.WriteUTF8Text(FCurRow, FCurCol, S)
|
||||||
|
else
|
||||||
|
if C.Field.DataType in [ftCurrency] then
|
||||||
|
FWorksheet.WriteCurrency(FCurRow, FCurCol, C.Field.AsCurrency, nfCurrency, '')
|
||||||
|
else
|
||||||
|
if C.Field.DataType in IntegerDataTypes then
|
||||||
|
FWorksheet.WriteNumber(FCurRow, FCurCol, C.Field.AsInteger, nfFixed, 0)
|
||||||
|
else
|
||||||
|
if C.Field.DataType in NumericDataTypes then
|
||||||
|
FWorksheet.WriteNumber(FCurRow, FCurCol, C.Field.AsFloat, nfFixed, 2)
|
||||||
|
else
|
||||||
|
FWorksheet.WriteUTF8Text(FCurRow, FCurCol, S);
|
||||||
|
end;
|
||||||
|
|
||||||
|
if ressExportColors in FOptions then
|
||||||
|
begin
|
||||||
|
CC:=C.Color;
|
||||||
|
if Assigned(RxDBGrid.OnGetCellProps) then
|
||||||
|
RxDBGrid.OnGetCellProps(RxDBGrid, C.Field, AFont, CC);
|
||||||
|
if (CC 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);
|
||||||
|
{$ENDIF}
|
||||||
|
end;
|
||||||
|
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);
|
||||||
|
|
||||||
|
FWorksheet.WriteHorAlignment(FCurRow, FCurCol, ssAligns[C.Alignment]);
|
||||||
|
inc(FCurCol);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TRxDBGridExportSpreadSheet.ExpAllRow;
|
||||||
|
var
|
||||||
|
F: TFont;
|
||||||
|
begin
|
||||||
|
F:=TFont.Create;
|
||||||
|
FDataSet.First;
|
||||||
|
while not FDataSet.EOF do
|
||||||
|
begin
|
||||||
|
ExpCurRow(F);
|
||||||
|
inc(FCurRow);
|
||||||
|
FDataSet.Next;
|
||||||
|
end;
|
||||||
|
F.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TRxDBGridExportSpreadSheet.ExpSelectedRow;
|
||||||
|
var
|
||||||
|
F: TFont;
|
||||||
|
k: Integer;
|
||||||
|
begin
|
||||||
|
F:=TFont.Create;
|
||||||
|
FDataSet.First;
|
||||||
|
for k:=0 to FRxDBGrid.SelectedRows.Count-1 do
|
||||||
|
begin
|
||||||
|
FDataSet.Bookmark:=FRxDBGrid.SelectedRows[k];
|
||||||
|
ExpCurRow(F);
|
||||||
|
inc(FCurRow);
|
||||||
|
end;
|
||||||
|
F.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TRxDBGridExportSpreadSheet.DoExportTitle;
|
procedure TRxDBGridExportSpreadSheet.DoExportTitle;
|
||||||
var
|
var
|
||||||
i, k : Integer;
|
i, k : Integer;
|
||||||
@ -242,83 +346,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TRxDBGridExportSpreadSheet.DoExportBody;
|
procedure TRxDBGridExportSpreadSheet.DoExportBody;
|
||||||
var
|
|
||||||
i : Integer;
|
|
||||||
C : TRxColumn;
|
|
||||||
CT : TRxColumnTitle;
|
|
||||||
CC : TColor;
|
|
||||||
scColor : TsColor;
|
|
||||||
F:TFont;
|
|
||||||
S: String;
|
|
||||||
J: Integer;
|
|
||||||
begin
|
begin
|
||||||
F:=TFont.Create;
|
if (dgMultiselect in RxDBGrid.Options) and (RxDBGrid.SelectedRows.Count > 0) and (ressExportSelectedRows in FOptions) then
|
||||||
FDataSet.First;
|
ExpSelectedRow
|
||||||
while not FDataSet.EOF do
|
|
||||||
begin
|
|
||||||
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 Assigned(C.Field) then
|
|
||||||
begin
|
|
||||||
S:=C.Field.DisplayText;
|
|
||||||
if (C.KeyList.Count > 0) and (C.PickList.Count > 0) then
|
|
||||||
begin
|
|
||||||
J := C.KeyList.IndexOf(S);
|
|
||||||
if (J >= 0) and (J < C.PickList.Count) then
|
|
||||||
S := C.PickList[j];
|
|
||||||
FWorksheet.WriteUTF8Text(FCurRow, FCurCol, S);
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
if Assigned(C.Field.OnGetText) then
|
ExpAllRow;
|
||||||
FWorksheet.WriteUTF8Text(FCurRow, FCurCol, S)
|
|
||||||
else
|
|
||||||
if C.Field.DataType in [ftCurrency] then
|
|
||||||
FWorksheet.WriteCurrency(FCurRow, FCurCol, C.Field.AsCurrency, nfCurrency, '')
|
|
||||||
else
|
|
||||||
if C.Field.DataType in IntegerDataTypes then
|
|
||||||
FWorksheet.WriteNumber(FCurRow, FCurCol, C.Field.AsInteger, nfFixed, 0)
|
|
||||||
else
|
|
||||||
if C.Field.DataType in NumericDataTypes then
|
|
||||||
FWorksheet.WriteNumber(FCurRow, FCurCol, C.Field.AsFloat, nfFixed, 2)
|
|
||||||
else
|
|
||||||
FWorksheet.WriteUTF8Text(FCurRow, FCurCol, S);
|
|
||||||
end;
|
|
||||||
|
|
||||||
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
|
|
||||||
{$IFDEF OLD_fpSPREADSHEET}
|
|
||||||
scColor:=FWorkbook.AddColorToPalette(CC);
|
|
||||||
FWorksheet.WriteBackgroundColor(FCurRow,FCurCol, scColor);
|
|
||||||
{$ELSE}
|
|
||||||
FWorksheet.WriteBackgroundColor(FCurRow,FCurCol, CC);
|
|
||||||
{$ENDIF}
|
|
||||||
end;
|
|
||||||
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);
|
|
||||||
|
|
||||||
FWorksheet.WriteHorAlignment(FCurRow, FCurCol, ssAligns[C.Alignment]);
|
|
||||||
inc(FCurCol);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
inc(FCurRow);
|
|
||||||
FDataSet.Next;
|
|
||||||
end;
|
|
||||||
F.Free;
|
|
||||||
FLastDataRow:=FCurRow-1;
|
FLastDataRow:=FCurRow-1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -497,6 +530,8 @@ begin
|
|||||||
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.cbExportFormula.Checked:=ressExportFormula in FOptions;
|
||||||
|
F.cbExportSelectedRows.Checked:=ressExportSelectedRows in FOptions;
|
||||||
|
F.cbExportSelectedRows.Enabled:=(dgMultiselect in RxDBGrid.Options) and (RxDBGrid.SelectedRows.Count > 0);
|
||||||
|
|
||||||
F.edtPageName.Text:=FPageName;
|
F.edtPageName.Text:=FPageName;
|
||||||
|
|
||||||
@ -518,7 +553,8 @@ begin
|
|||||||
FOptions :=FOptions + [ressOverwriteExisting];
|
FOptions :=FOptions + [ressOverwriteExisting];
|
||||||
if F.cbExportFormula.Checked then
|
if F.cbExportFormula.Checked then
|
||||||
FOptions :=FOptions + [ressExportFormula];
|
FOptions :=FOptions + [ressExportFormula];
|
||||||
|
if F.cbExportSelectedRows.Enabled and F.cbExportSelectedRows.Checked then
|
||||||
|
FOptions :=FOptions + [ressExportSelectedRows];
|
||||||
end;
|
end;
|
||||||
F.Free;
|
F.Free;
|
||||||
end;
|
end;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
object RxDBGridExportSpreadSheet_ParamsForm: TRxDBGridExportSpreadSheet_ParamsForm
|
object RxDBGridExportSpreadSheet_ParamsForm: TRxDBGridExportSpreadSheet_ParamsForm
|
||||||
Left = 732
|
Left = 732
|
||||||
Height = 246
|
Height = 294
|
||||||
Top = 338
|
Top = 338
|
||||||
Width = 548
|
Width = 548
|
||||||
Caption = 'Export params'
|
Caption = 'Export params'
|
||||||
ClientHeight = 246
|
ClientHeight = 294
|
||||||
ClientWidth = 548
|
ClientWidth = 548
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
Position = poScreenCenter
|
Position = poScreenCenter
|
||||||
@ -96,7 +96,7 @@ object RxDBGridExportSpreadSheet_ParamsForm: TRxDBGridExportSpreadSheet_ParamsFo
|
|||||||
object ButtonPanel1: TButtonPanel
|
object ButtonPanel1: TButtonPanel
|
||||||
Left = 6
|
Left = 6
|
||||||
Height = 46
|
Height = 46
|
||||||
Top = 194
|
Top = 242
|
||||||
Width = 536
|
Width = 536
|
||||||
OKButton.Name = 'OKButton'
|
OKButton.Name = 'OKButton'
|
||||||
OKButton.DefaultCaption = True
|
OKButton.DefaultCaption = True
|
||||||
@ -167,4 +167,16 @@ object RxDBGridExportSpreadSheet_ParamsForm: TRxDBGridExportSpreadSheet_ParamsFo
|
|||||||
Caption = 'Export formula'
|
Caption = 'Export formula'
|
||||||
TabOrder = 5
|
TabOrder = 5
|
||||||
end
|
end
|
||||||
|
object cbExportSelectedRows: TCheckBox
|
||||||
|
AnchorSideLeft.Control = Owner
|
||||||
|
AnchorSideTop.Control = cbExportCellColors
|
||||||
|
AnchorSideTop.Side = asrBottom
|
||||||
|
Left = 6
|
||||||
|
Height = 24
|
||||||
|
Top = 195
|
||||||
|
Width = 163
|
||||||
|
BorderSpacing.Around = 6
|
||||||
|
Caption = 'Export selected rows'
|
||||||
|
TabOrder = 9
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -45,6 +45,7 @@ type
|
|||||||
|
|
||||||
TRxDBGridExportSpreadSheet_ParamsForm = class(TForm)
|
TRxDBGridExportSpreadSheet_ParamsForm = class(TForm)
|
||||||
ButtonPanel1: TButtonPanel;
|
ButtonPanel1: TButtonPanel;
|
||||||
|
cbExportSelectedRows: TCheckBox;
|
||||||
cbExportFormula: TCheckBox;
|
cbExportFormula: TCheckBox;
|
||||||
cbExportColumnFooter: TCheckBox;
|
cbExportColumnFooter: TCheckBox;
|
||||||
cbOpenAfterExport: TCheckBox;
|
cbOpenAfterExport: TCheckBox;
|
||||||
@ -81,6 +82,7 @@ begin
|
|||||||
cbExportCellColors.Caption:=sExportCellColors;
|
cbExportCellColors.Caption:=sExportCellColors;
|
||||||
cbOverwriteExisting.Caption:=sOverwriteExisting;
|
cbOverwriteExisting.Caption:=sOverwriteExisting;
|
||||||
cbExportFormula.Caption:=sExportFormula;
|
cbExportFormula.Caption:=sExportFormula;
|
||||||
|
cbExportSelectedRows.Caption:=sExportSelectedRows;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -185,6 +185,7 @@ resourcestring
|
|||||||
sExportCellColors = 'Export cell colors';
|
sExportCellColors = 'Export cell colors';
|
||||||
sExportFormula = 'Export footer formula';
|
sExportFormula = 'Export footer formula';
|
||||||
sExportImages = 'Export images';
|
sExportImages = 'Export images';
|
||||||
|
sExportSelectedRows = 'Export only selected rows';
|
||||||
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';
|
||||||
|
Reference in New Issue
Block a user