Class TrXLSExport

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TrXLSExport = class(TComponent)

Description

non visual component which provides functionality for exporting of any data directly to XLS file using OLE

Hierarchy

  • TComponent
  • TrXLSExport

Overview

Fields

Public Data: Variant;

Methods

Public function IsAppExist: boolean;
Public function OpenFile(NewFile: boolean; const OpenFileName: string = ''; CanReadOnly: boolean = true): boolean;
Public function SaveCloseFile(CloseApp, SaveFile: boolean; const SaveFileName: string = ''; FileFormat: integer = 0): boolean;
Public procedure Disconnect;
Public procedure SetVisibility(Visible: boolean);
Public function GetSheetsCount: integer;
Public function SelectSheet(NewSheet: boolean; const SheetName: string = ''; SheetIndex: integer = 0): boolean;
Public function DeleteSheet(AllUnselected: boolean; const SheetName: string = ''): boolean;
Public procedure RememberActiveSheet;
Public procedure SelectRememberSheet;
Public function ActivateRangeSheet(var RangeName: string): boolean;
Public procedure SetCurrentRange(Row, Col, RowCount, ColCount: integer);
Public procedure SetStartPos(ClearExistingRows: boolean = true; AddToExistingRows: boolean = false);
Public function GetCellValue(Row, Col: integer): Variant;
Public procedure SetCellValue(Row, Col: integer; Value: Variant; const NumberFormat: string = '');
Public procedure SetRangeValue(RangeName: string; Value: Variant; const NumberFormat: string = '');
Public procedure SetDataSizeFromRange(RangeName: string);
Public procedure SetDataSize(RowCount, ColCount: integer);
Public function CopyCellsToData: boolean;
Public function CopyCellsToClipboard: boolean;
Public function CopyUsedRangeToData: boolean;
Public function CopyUsedRangeToClipboard: boolean;
Public function CopyCurrentRegionToData: boolean;
Public function CopyCurrentRegionToClipboard: boolean;
Public function PasteDataToCells(SetAutoFilter: boolean = false): boolean;
Public function PasteClipboardToCells(SetAutoFilter: boolean = false): boolean;
Public procedure FreezePanes(Row, Col: integer);
Public procedure SetColumnWidth(Col: integer; ColWidth: integer);
Public procedure SetRowHeight(Row: integer; RowHeight: integer);
Public procedure ColumnAutoFit(Col: integer; MaxColWidth: integer);
Public procedure RowAutoFit(Row: integer; MaxRowHeight: integer);
Public procedure UsedRangeAutoFit(MaxColWidth: integer = 0; MaxRowHeight: integer = 0);
Public procedure FormatCells(Row, Col, RowCount, ColCount: integer; const NumberFormat: string; const FontName: string = ''; FontSize: integer = 0; Frm: TXLSCellFormats = [cfNone]);
Public procedure BorderCells(Row, Col, RowCount, ColCount: integer; Border: integer = xlAllBorders; LineColor: TColor = clNone; LineWidth: integer = xlThin; LineStyle: integer = xlContinuous);
Public procedure SetPageZoom(Zoom: integer; FitToPagesTall: integer = 1; FitToPagesWide: integer = 1; Orientation: byte = 0);
Public procedure SetWindowZoom(Zoom: integer);
Public function ExportDBTable(DBGrid: TDBGrid; AutoCloseApp: boolean = true; const ExportToSheetName: string = ''): boolean; overload;
Public function ExportDBTable(Dataset: TDataSet; AutoCloseApp: boolean = true; const ExportToSheetName: string = ''): boolean; overload;

Properties

Public property DataRowCount: integer read FDataRowCount;
Public property DataColCount: integer read FDataColCount;
Public property App: OleVariant read FApp;
Public property AppOpened: boolean read FAppOpened;
Public property Workbook: OleVariant read FWorkbook;
Public property Worksheet: OleVariant read FWorksheet;
Public property Range: OleVariant read FRange;
Public property ExportStructureOnly: boolean read FExportStructureOnly write FExportStructureOnly;
Published property StartRow: integer read FStartRow write SetStartRow default 1;
Published property StartCol: integer read FStartCol write SetStartCol default 1;
Published property ExportFile: string read FExportFile write FExportFile;
Published property SetFontName: string read FSetFontName write FSetFontName;
Published property SetFontSize: integer read FSetFontSize write FSetFontSize default 0;
Published property DefaultDateFormat: string read FDefaultDateFormat write FDefaultDateFormat;
Published property DefaultTimeFormat: string read FDefaultTimeFormat write FDefaultTimeFormat;
Published property DefaultNumFormat: string read FDefaultNumFormat write FDefaultNumFormat;
Published property MaxColWidth: integer read FMaxColWidth write FMaxColWidth default 100;
Published property PageZoom: integer read FPageZoom write FPageZoom default 0;
Published property WindowZoom: integer read FWindowZoom write FWindowZoom default 0;
Published property Options: TXLSExportOptions read FOptions write FOptions default[xleExportTitles, xleBoldTitles, xleOnlyVisibleFields, xleAddSumRow, xleSetCellFormat, xleSetColumnWidth];
Published property ActionAfter: TActionAfter read FActionAfter write FActionAfter default aaShow;
Published property OnBeforeExport: TNotifyEvent read FOnBeforeExport write FOnBeforeExport;
Published property OnAfterExport: TNotifyEvent read FOnAfterExport write FOnAfterExport;
Published property UseDisableControl: boolean read FUseDisableControl write FUseDisableControl default true;
Published property ShowProgressBar: boolean read FShowProgressBar write FShowProgressBar default false;
Published property OnProgressEvent: TProgressEvent read FOnProgressEvent write FOnProgressEvent;

Description

Fields

Public Data: Variant;

Data array contain data which was read from cells or which should be stored to cells

Methods

Public function IsAppExist: boolean;

test if Excel App is available

Public function OpenFile(NewFile: boolean; const OpenFileName: string = ''; CanReadOnly: boolean = true): boolean;

run Excel and open new or existing file

Public function SaveCloseFile(CloseApp, SaveFile: boolean; const SaveFileName: string = ''; FileFormat: integer = 0): boolean;

close Excel and optionally save file

Public procedure Disconnect;

Disconnect from current excel application, Excel keep opened

Public procedure SetVisibility(Visible: boolean);

set visibility of Excel application

Public function GetSheetsCount: integer;

return number of sheets

Public function SelectSheet(NewSheet: boolean; const SheetName: string = ''; SheetIndex: integer = 0): boolean;

add new sheet and set its name or select active sheet according SheetName

Public function DeleteSheet(AllUnselected: boolean; const SheetName: string = ''): boolean;

delete all unselected sheets or delete one sheet according SheetName

Public procedure RememberActiveSheet;

remember actual active sheet

Public procedure SelectRememberSheet;

select active sheet after open or after call RememberActiveSheet

Public function ActivateRangeSheet(var RangeName: string): boolean;

select sheet by name defined in range name and return range name without sheet: sheet!range

Public procedure SetCurrentRange(Row, Col, RowCount, ColCount: integer);

set Range object

Public procedure SetStartPos(ClearExistingRows: boolean = true; AddToExistingRows: boolean = false);

set starting row for export, select first empty row if AddToExisting is true

Public function GetCellValue(Row, Col: integer): Variant;

return value of one cell

Public procedure SetCellValue(Row, Col: integer; Value: Variant; const NumberFormat: string = '');

set value of one cell

Public procedure SetRangeValue(RangeName: string; Value: Variant; const NumberFormat: string = '');

set value of RangeName

Public procedure SetDataSizeFromRange(RangeName: string);

prepare Data array according RangeName size

Public procedure SetDataSize(RowCount, ColCount: integer);

prepare Data array according RowCount and ColCount

Public function CopyCellsToData: boolean;

read values from cells to Data array, StartRow and StartCol + DataRowCount and DataColCount is used to define source range

Public function CopyCellsToClipboard: boolean;

copy values from cells to Clipboard, StartRow and StartCol + DataRowCount and DataColCount is used to define source range

Public function CopyUsedRangeToData: boolean;

read values from UsedRange of selected Sheet to Data array, size is set according UsedRange

Public function CopyUsedRangeToClipboard: boolean;

read values from UsedRange of selected Sheet to Clipboard

Public function CopyCurrentRegionToData: boolean;

read values from UsedRange of selected Sheet to Data array, size is set according UsedRange

Public function CopyCurrentRegionToClipboard: boolean;

read values from UsedRange of selected Sheet to Clipboard

Public function PasteDataToCells(SetAutoFilter: boolean = false): boolean;

write values from Data array to cells, StartRow and StartCol + DataRowCount and DataColCount is used to define target range

Public function PasteClipboardToCells(SetAutoFilter: boolean = false): boolean;

paste values from Clipboard to cells, StartRow and StartCol is used to define target range

Public procedure FreezePanes(Row, Col: integer);

switch on FreezePanes in selected sheet, if Row and Col is 0 FreezePanes is switched off

Public procedure SetColumnWidth(Col: integer; ColWidth: integer);

set width of one column

Public procedure SetRowHeight(Row: integer; RowHeight: integer);

set height of one row

Public procedure ColumnAutoFit(Col: integer; MaxColWidth: integer);

set automatic width of one column

Public procedure RowAutoFit(Row: integer; MaxRowHeight: integer);

set automatic height of one row

Public procedure UsedRangeAutoFit(MaxColWidth: integer = 0; MaxRowHeight: integer = 0);

set automatic width of all columns and rows in selected sheet

Public procedure FormatCells(Row, Col, RowCount, ColCount: integer; const NumberFormat: string; const FontName: string = ''; FontSize: integer = 0; Frm: TXLSCellFormats = [cfNone]);

set Number format and/or Font for cells in square defined by Row/Col/Count

Public procedure BorderCells(Row, Col, RowCount, ColCount: integer; Border: integer = xlAllBorders; LineColor: TColor = clNone; LineWidth: integer = xlThin; LineStyle: integer = xlContinuous);

set Number format and/or Font for cells in square defined by Row/Col/Count

Public procedure SetPageZoom(Zoom: integer; FitToPagesTall: integer = 1; FitToPagesWide: integer = 1; Orientation: byte = 0);

set page zoom or number of pages for printout

Public procedure SetWindowZoom(Zoom: integer);

set window zoom

Public function ExportDBTable(DBGrid: TDBGrid; AutoCloseApp: boolean = true; const ExportToSheetName: string = ''): boolean; overload;

execute creating export for DBGrid (columns collection is used)

Public function ExportDBTable(Dataset: TDataSet; AutoCloseApp: boolean = true; const ExportToSheetName: string = ''): boolean; overload;

execute creating export for Dataset (fields collection is used)

Properties

Public property DataRowCount: integer read FDataRowCount;

indicate size of Data array

Public property DataColCount: integer read FDataColCount;

indicate size of Data array

Public property App: OleVariant read FApp;

return Excel application OLE object

Public property AppOpened: boolean read FAppOpened;

indicate whether excel app is opened by component

Public property Workbook: OleVariant read FWorkbook;

return active Workbook OLE object

Public property Worksheet: OleVariant read FWorksheet;

return active Worksheet OLE object

Public property Range: OleVariant read FRange;

return current Range OLE object

Public property ExportStructureOnly: boolean read FExportStructureOnly write FExportStructureOnly;

define that only structure (name of fields) will be exported

Published property StartRow: integer read FStartRow write SetStartRow default 1;

Defines first row for export

Published property StartCol: integer read FStartCol write SetStartCol default 1;

Defines first collumn for export

Published property ExportFile: string read FExportFile write FExportFile;

Defines output file name, if missing new file is opened

Published property SetFontName: string read FSetFontName write FSetFontName;

Defines FontName which will be set in output file

Published property SetFontSize: integer read FSetFontSize write FSetFontSize default 0;

Defines FontSize which will be set in output file

Published property DefaultDateFormat: string read FDefaultDateFormat write FDefaultDateFormat;

Defines default format for date fields

Published property DefaultTimeFormat: string read FDefaultTimeFormat write FDefaultTimeFormat;

Defines default format for time fields

Published property DefaultNumFormat: string read FDefaultNumFormat write FDefaultNumFormat;

Defines default format for numeric fields

Published property MaxColWidth: integer read FMaxColWidth write FMaxColWidth default 100;

Defines maximal width of columns after AutoFit

Published property PageZoom: integer read FPageZoom write FPageZoom default 0;

Defines standard page zoom

Published property WindowZoom: integer read FWindowZoom write FWindowZoom default 0;

Defines standard window zoom

Published property Options: TXLSExportOptions read FOptions write FOptions default[xleExportTitles, xleBoldTitles, xleOnlyVisibleFields, xleAddSumRow, xleSetCellFormat, xleSetColumnWidth];

Defines options for ExportDBTable function

Published property ActionAfter: TActionAfter read FActionAfter write FActionAfter default aaShow;

Defines action after exporting (None, Show, Print)

Published property OnBeforeExport: TNotifyEvent read FOnBeforeExport write FOnBeforeExport;

Defines event for user defined action

Published property OnAfterExport: TNotifyEvent read FOnAfterExport write FOnAfterExport;

Defines event for user defined action

Published property UseDisableControl: boolean read FUseDisableControl write FUseDisableControl default true;

indicate whether DisableControls is used during dataset scan

Published property ShowProgressBar: boolean read FShowProgressBar write FShowProgressBar default false;

indicate whether progress bar is shown

Published property OnProgressEvent: TProgressEvent read FOnProgressEvent write FOnProgressEvent;

Defines event used periodically during exporting of data


Generated by PasDoc 0.13.0 on 2017-06-17 14:57:07