Poder exportar a un ficheros Excel los grids.
git-svn-id: https://192.168.0.254/svn/Proyectos.Acana_FactuGES2/trunk@306 f4e31baf-9722-1c47-927c-6f952f962d4b
This commit is contained in:
parent
f0bc0610ab
commit
91217446eb
@ -33,6 +33,7 @@ function DarFicheroJPGTemporal : String;
|
|||||||
function DarFicheroBMPTemporal : String;
|
function DarFicheroBMPTemporal : String;
|
||||||
function DarFicheroTIFFTemporal : String;
|
function DarFicheroTIFFTemporal : String;
|
||||||
function DarFicheroExportar (var Fichero : String) : Boolean;
|
function DarFicheroExportar (var Fichero : String) : Boolean;
|
||||||
|
function PreguntarFicheroExcelExportar (var Fichero : String) : Boolean;
|
||||||
function DarVersionFichero (Executable : String) : String;
|
function DarVersionFichero (Executable : String) : String;
|
||||||
function DarFechaFichero (Executable : String) : String;
|
function DarFechaFichero (Executable : String) : String;
|
||||||
procedure CopiarFichero(const Origen, Destino: string);
|
procedure CopiarFichero(const Origen, Destino: string);
|
||||||
@ -172,6 +173,27 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function PreguntarFicheroExcelExportar (var Fichero : String) : Boolean;
|
||||||
|
var
|
||||||
|
DialogoSalvar : TSaveDialog;
|
||||||
|
begin
|
||||||
|
DialogoSalvar := TSaveDialog.Create(NIL);
|
||||||
|
try
|
||||||
|
with DialogoSalvar do
|
||||||
|
begin
|
||||||
|
DefaultExt := 'xls';
|
||||||
|
Filter := 'Documento de Excel (*.xls)|*.xls';
|
||||||
|
FilterIndex := 0;
|
||||||
|
Options := [ofOverwritePrompt, ofHideReadOnly, ofPathMustExist, ofEnableSizing];
|
||||||
|
end;
|
||||||
|
Result := DialogoSalvar.Execute;
|
||||||
|
if Result then
|
||||||
|
Fichero := DialogoSalvar.FileName;
|
||||||
|
finally
|
||||||
|
DialogoSalvar.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function DarFechaFichero (Executable : String) : String;
|
function DarFechaFichero (Executable : String) : String;
|
||||||
var
|
var
|
||||||
FileTime, LocalFileTime : TFileTime;
|
FileTime, LocalFileTime : TFileTime;
|
||||||
|
|||||||
@ -37,7 +37,6 @@ object fEditorBase: TfEditorBase
|
|||||||
ImageIndex = 0
|
ImageIndex = 0
|
||||||
StyleManager = dmBase.StyleManager
|
StyleManager = dmBase.StyleManager
|
||||||
ParentStyleManager = False
|
ParentStyleManager = False
|
||||||
ExplicitWidth = 793
|
|
||||||
object Image1: TImage
|
object Image1: TImage
|
||||||
Left = 919
|
Left = 919
|
||||||
Top = 0
|
Top = 0
|
||||||
@ -73,7 +72,6 @@ object fEditorBase: TfEditorBase
|
|||||||
Top = 0
|
Top = 0
|
||||||
Width = 946
|
Width = 946
|
||||||
Height = 49
|
Height = 49
|
||||||
ExplicitWidth = 793
|
|
||||||
object tbxMain: TTBXToolbar
|
object tbxMain: TTBXToolbar
|
||||||
Left = 0
|
Left = 0
|
||||||
Top = 23
|
Top = 23
|
||||||
@ -250,8 +248,6 @@ object fEditorBase: TfEditorBase
|
|||||||
Width = 946
|
Width = 946
|
||||||
Height = 19
|
Height = 19
|
||||||
Panels = <>
|
Panels = <>
|
||||||
ExplicitTop = 437
|
|
||||||
ExplicitWidth = 793
|
|
||||||
end
|
end
|
||||||
object EditorActionList: TActionList
|
object EditorActionList: TActionList
|
||||||
Images = SmallImages
|
Images = SmallImages
|
||||||
@ -400,6 +396,7 @@ object fEditorBase: TfEditorBase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
object SmallImages: TPngImageList
|
object SmallImages: TPngImageList
|
||||||
|
ShareImages = True
|
||||||
PngImages = <
|
PngImages = <
|
||||||
item
|
item
|
||||||
PngImage.Data = {
|
PngImage.Data = {
|
||||||
@ -889,6 +886,7 @@ object fEditorBase: TfEditorBase
|
|||||||
end
|
end
|
||||||
object LargeImages: TPngImageList
|
object LargeImages: TPngImageList
|
||||||
Height = 24
|
Height = 24
|
||||||
|
ShareImages = True
|
||||||
Width = 24
|
Width = 24
|
||||||
PngImages = <
|
PngImages = <
|
||||||
item
|
item
|
||||||
|
|||||||
@ -30,7 +30,7 @@ inherited fEditorGridBase: TfEditorGridBase
|
|||||||
DockPos = 0
|
DockPos = 0
|
||||||
DragHandleStyle = dhDouble
|
DragHandleStyle = dhDouble
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
ExplicitWidth = 457
|
ExplicitWidth = 543
|
||||||
inherited TBXItem29: TTBXItem
|
inherited TBXItem29: TTBXItem
|
||||||
Visible = False
|
Visible = False
|
||||||
end
|
end
|
||||||
@ -47,21 +47,26 @@ inherited fEditorGridBase: TfEditorGridBase
|
|||||||
end
|
end
|
||||||
inherited TBXItem3: TTBXItem [11]
|
inherited TBXItem3: TTBXItem [11]
|
||||||
end
|
end
|
||||||
inherited TBXSeparatorItem10: TTBXSeparatorItem [12]
|
object TBXSeparatorItem173: TTBXSeparatorItem [12]
|
||||||
end
|
end
|
||||||
inherited TBXItem26: TTBXItem [13]
|
object TBXItem382: TTBXItem [13]
|
||||||
|
Action = actExportarExcel
|
||||||
|
end
|
||||||
|
inherited TBXSeparatorItem10: TTBXSeparatorItem [14]
|
||||||
|
end
|
||||||
|
inherited TBXItem26: TTBXItem [15]
|
||||||
Visible = False
|
Visible = False
|
||||||
end
|
end
|
||||||
inherited TBXSeparatorItem2: TTBXSeparatorItem [14]
|
inherited TBXItem25: TTBXItem [16]
|
||||||
|
Visible = False
|
||||||
|
end
|
||||||
|
inherited TBXSeparatorItem2: TTBXSeparatorItem [17]
|
||||||
Visible = True
|
Visible = True
|
||||||
end
|
end
|
||||||
inherited TBXItem25: TTBXItem
|
|
||||||
Visible = False
|
|
||||||
end
|
|
||||||
inherited TBXSeparatorItem11: TTBXSeparatorItem
|
inherited TBXSeparatorItem11: TTBXSeparatorItem
|
||||||
Visible = False
|
Visible = False
|
||||||
end
|
end
|
||||||
object TBXItem36: TTBXItem [18]
|
object TBXItem36: TTBXItem [20]
|
||||||
Action = actAnchoAuto
|
Action = actAnchoAuto
|
||||||
DisplayMode = nbdmImageAndText
|
DisplayMode = nbdmImageAndText
|
||||||
end
|
end
|
||||||
@ -145,6 +150,12 @@ inherited fEditorGridBase: TfEditorGridBase
|
|||||||
object TBXSeparatorItem16: TTBXSeparatorItem [1]
|
object TBXSeparatorItem16: TTBXSeparatorItem [1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
object TBXSubmenuItem32: TTBXSubmenuItem [4]
|
||||||
|
Caption = 'A&cciones'
|
||||||
|
object TBXItem1039: TTBXItem
|
||||||
|
Action = actExportarExcel
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
object TBXTMain2: TTBXToolbar
|
object TBXTMain2: TTBXToolbar
|
||||||
Left = 337
|
Left = 337
|
||||||
@ -219,6 +230,12 @@ inherited fEditorGridBase: TfEditorGridBase
|
|||||||
OnExecute = actFiltrarExecute
|
OnExecute = actFiltrarExecute
|
||||||
OnUpdate = actFiltrarUpdate
|
OnUpdate = actFiltrarUpdate
|
||||||
end
|
end
|
||||||
|
object actExportarExcel: TAction
|
||||||
|
Category = 'Archivo'
|
||||||
|
Caption = 'Exportar a fichero Excel...'
|
||||||
|
OnExecute = actExportarExcelExecute
|
||||||
|
OnUpdate = actExportarExcelUpdate
|
||||||
|
end
|
||||||
end
|
end
|
||||||
inherited SmallImages: TPngImageList
|
inherited SmallImages: TPngImageList
|
||||||
PngImages = <
|
PngImages = <
|
||||||
@ -1527,6 +1544,9 @@ inherited fEditorGridBase: TfEditorGridBase
|
|||||||
Left = 440
|
Left = 440
|
||||||
Top = 160
|
Top = 160
|
||||||
end
|
end
|
||||||
|
inherited StatusBarImages: TPngImageList
|
||||||
|
Left = 8
|
||||||
|
end
|
||||||
object GridPopupMenu: TPopupMenu
|
object GridPopupMenu: TPopupMenu
|
||||||
Images = SmallImages
|
Images = SmallImages
|
||||||
Left = 64
|
Left = 64
|
||||||
@ -1555,7 +1575,13 @@ inherited fEditorGridBase: TfEditorGridBase
|
|||||||
object Imprimir1: TMenuItem
|
object Imprimir1: TMenuItem
|
||||||
Action = actImprimir
|
Action = actImprimir
|
||||||
end
|
end
|
||||||
object N3: TMenuItem
|
object N41: TMenuItem
|
||||||
|
Caption = '-'
|
||||||
|
end
|
||||||
|
object ExportaraficheroExcel1: TMenuItem
|
||||||
|
Action = actExportarExcel
|
||||||
|
end
|
||||||
|
object N33: TMenuItem
|
||||||
Caption = '-'
|
Caption = '-'
|
||||||
end
|
end
|
||||||
object Actualizar1: TMenuItem
|
object Actualizar1: TMenuItem
|
||||||
|
|||||||
@ -45,7 +45,7 @@ type
|
|||||||
Imprimir1: TMenuItem;
|
Imprimir1: TMenuItem;
|
||||||
TBXSeparatorItem14: TTBXSeparatorItem;
|
TBXSeparatorItem14: TTBXSeparatorItem;
|
||||||
TBXItem33: TTBXItem;
|
TBXItem33: TTBXItem;
|
||||||
N3: TMenuItem;
|
N33: TMenuItem;
|
||||||
Actualizar1: TMenuItem;
|
Actualizar1: TMenuItem;
|
||||||
TBXItem34: TTBXItem;
|
TBXItem34: TTBXItem;
|
||||||
actAnchoAuto: TAction;
|
actAnchoAuto: TAction;
|
||||||
@ -57,6 +57,13 @@ type
|
|||||||
actFiltrar: TAction;
|
actFiltrar: TAction;
|
||||||
TBXItem37: TTBXItem;
|
TBXItem37: TTBXItem;
|
||||||
TBXTMain2: TTBXToolbar;
|
TBXTMain2: TTBXToolbar;
|
||||||
|
actExportarExcel: TAction;
|
||||||
|
TBXItem382: TTBXItem;
|
||||||
|
TBXSeparatorItem173: TTBXSeparatorItem;
|
||||||
|
ExportaraficheroExcel1: TMenuItem;
|
||||||
|
N41: TMenuItem;
|
||||||
|
TBXSubmenuItem32: TTBXSubmenuItem;
|
||||||
|
TBXItem1039: TTBXItem;
|
||||||
procedure tbxEditFiltroChange(Sender: TObject; const Text: String);
|
procedure tbxEditFiltroChange(Sender: TObject; const Text: String);
|
||||||
procedure FormShow(Sender: TObject);
|
procedure FormShow(Sender: TObject);
|
||||||
procedure actQuitarFiltroExecute(Sender: TObject);
|
procedure actQuitarFiltroExecute(Sender: TObject);
|
||||||
@ -69,6 +76,8 @@ type
|
|||||||
procedure actFiltrarExecute(Sender: TObject);
|
procedure actFiltrarExecute(Sender: TObject);
|
||||||
procedure actFiltrarUpdate(Sender: TObject);
|
procedure actFiltrarUpdate(Sender: TObject);
|
||||||
procedure CustomEditorDestroy(Sender: TObject);
|
procedure CustomEditorDestroy(Sender: TObject);
|
||||||
|
procedure actExportarExcelExecute(Sender: TObject);
|
||||||
|
procedure actExportarExcelUpdate(Sender: TObject);
|
||||||
protected
|
protected
|
||||||
FViewGrid : IViewGridBase;
|
FViewGrid : IViewGridBase;
|
||||||
procedure SetViewGrid(const Value : IViewGridBase); virtual;
|
procedure SetViewGrid(const Value : IViewGridBase); virtual;
|
||||||
@ -170,6 +179,19 @@ begin
|
|||||||
(Sender as TAction).Enabled := False;
|
(Sender as TAction).Enabled := False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TfEditorGridBase.actExportarExcelExecute(Sender: TObject);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
if Assigned(ViewGrid) then
|
||||||
|
ViewGrid.ExportToExcel;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfEditorGridBase.actExportarExcelUpdate(Sender: TObject);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
(Sender as TAction).Enabled := Assigned(ViewGrid);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TfEditorGridBase.actFiltrarExecute(Sender: TObject);
|
procedure TfEditorGridBase.actFiltrarExecute(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
|||||||
@ -37,6 +37,9 @@ type
|
|||||||
procedure GotoFirst;
|
procedure GotoFirst;
|
||||||
procedure GotoLast;
|
procedure GotoLast;
|
||||||
|
|
||||||
|
procedure ExportToExcel(const AFileName: string); overload;
|
||||||
|
procedure ExportToExcel; overload;
|
||||||
|
|
||||||
function GetFocusedView : TcxGridDBTableView;
|
function GetFocusedView : TcxGridDBTableView;
|
||||||
property _FocusedView : TcxGridDBTableView read GetFocusedView;
|
property _FocusedView : TcxGridDBTableView read GetFocusedView;
|
||||||
|
|
||||||
@ -71,7 +74,7 @@ type
|
|||||||
|
|
||||||
function EsSeleccionCeldaDatos: Boolean;
|
function EsSeleccionCeldaDatos: Boolean;
|
||||||
|
|
||||||
function getNumSeleccionados: Integer;
|
function GetNumSeleccionados: Integer;
|
||||||
property NumSeleccionados: Integer read getNumSeleccionados;
|
property NumSeleccionados: Integer read getNumSeleccionados;
|
||||||
|
|
||||||
{function Locate(const AItemIndex: Integer; const AValue: String;
|
{function Locate(const AItemIndex: Integer; const AValue: String;
|
||||||
@ -131,6 +134,9 @@ type
|
|||||||
procedure GotoFirst;
|
procedure GotoFirst;
|
||||||
procedure GotoLast;
|
procedure GotoLast;
|
||||||
|
|
||||||
|
procedure ExportToExcel(const AFileName: string); overload;
|
||||||
|
procedure ExportToExcel; overload;
|
||||||
|
|
||||||
procedure StoreToRegistry (const Path : String); virtual;
|
procedure StoreToRegistry (const Path : String); virtual;
|
||||||
procedure RestoreFromRegistry (const Path : String); virtual;
|
procedure RestoreFromRegistry (const Path : String); virtual;
|
||||||
|
|
||||||
@ -159,7 +165,8 @@ procedure Register;
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
CCReg, uDMBase, uDBSelectionListUtils, uSistemaFunc, SHFolder, uAppInfoUtils;
|
CCReg, uDMBase, uDBSelectionListUtils, uSistemaFunc, SHFolder,
|
||||||
|
uAppInfoUtils, cxGridExportLink;
|
||||||
|
|
||||||
{$R *.dfm}
|
{$R *.dfm}
|
||||||
|
|
||||||
@ -203,6 +210,20 @@ begin
|
|||||||
_FocusedView.ViewData.Expand(True);
|
_FocusedView.ViewData.Expand(True);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TfrViewGridBase.ExportToExcel(const AFileName: string);
|
||||||
|
begin
|
||||||
|
if Assigned(_Grid) then
|
||||||
|
ExportGridToExcel(AFileName, _Grid);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TfrViewGridBase.ExportToExcel;
|
||||||
|
var
|
||||||
|
AFileName : String;
|
||||||
|
begin
|
||||||
|
if PreguntarFicheroExcelExportar(AFileName) then
|
||||||
|
ExportToExcel(AFileName);
|
||||||
|
end;
|
||||||
|
|
||||||
function TfrViewGridBase.GetDblClick: TNotifyEvent;
|
function TfrViewGridBase.GetDblClick: TNotifyEvent;
|
||||||
begin
|
begin
|
||||||
Result := FOnDblClick;
|
Result := FOnDblClick;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user