⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qexport3common.pas

📁 DELPHI开发VCL
💻 PAS
📖 第 1 页 / 共 4 页
字号:
unit QExport3Common;

{$I VerCtrl.inc}

{$IFDEF VCL6} {$WARN SYMBOL_PLATFORM OFF} {$ENDIF}

interface

uses
  Classes, QExport3, QExport3XLS, QExport3RTF, IniFiles, Db, TypInfo,
  QExport3Types, QExport3CustomSource, QExport3XLSCommon
  {$IFDEF WIN32}
    , Windows {$IFNDEF NOGUI}, Graphics, Controls, ExtCtrls, ComCtrls, Dialogs,
    DbGrids, Grids, StdCtrls, Messages{$ELSE}, QExport3Graphics{$ENDIF}
  {$ENDIF}
  {$IFDEF LINUX}
    {$IFNDEF NOGUI}, QGraphics, QDialogs, QExtCtrls, QControls,
    QComCtrls, Types, QDbGrids, QGrids, QStdCtrls{$ELSE}, QExportG3raphics{$ENDIF}
  {$ENDIF};

{$IFNDEF NOGUI}
type
  TListItemProc = procedure(Item: TListItem) of object;
  TxlsCustomItemProc = procedure(Item: TxlsCustomItem) of object;
{$ENDIF}

const
  //------------------------
  // Don't localize this !!!
  //------------------------
  S_PRODUCT_NAME = 'EMS AdvancedExport';
  S_ABOUT = '(About EMS AdvancedExport)';
{$IFDEF CS}
  S_REG_URL = 'http://www.componentsource.com';
{$ELSE}
  S_REG_URL = 'http://www.sqlmanager.net/products/tools/advancedexport/buy';
{$ENDIF}  
  //--------------
  S_FULL_PRODUCT_NAME = 'Advanced Data Export for Delphi(R) and C++ Builder(R) (%s)';
  S_COPYRIGHT = '(C) 1999-2006  EMS Database Management Solutions, Ltd.  All rights reserved.';
  S_VERSION = '3.44';
  S_COMPONENT_PAGE = 'EMS Advanced Export';

  CRLF = #13#10;

  S_INTEGER_FORMAT = '#,###,##0';
  S_FLOAT_FORMAT = '#,###,##0.00';
  S_BOOLEAN_TRUE = 'true';
  S_BOOLEAN_FALSE = 'false';
  S_NULL_STRING = 'null';

  S_XLS_MAX_ROWS = {$IFDEF WIN32}65536{$ELSE}32000{$ENDIF};
  XL = 8;

  S_RTF_SAMPLE_TEXT = 'AaBbCc XxYyZz';

  S_GENERAL = 'GENERAL';
    S_FileName = 'FileName';
    S_ExportType = 'ExportType';
    S_ShowFile = 'ShowFile';
    S_PrintFile = 'PrintFile';
    S_GoToFirstRecord = 'GoToFirstRecord';
    S_CurrentRecordOnly = 'CurrentRecordOnly';
    S_ExportEmpty = 'ExportEmpty';
    S_ExportAllRecords = 'ExportAllRecords';
    S_ExportRecCount = 'ExportRecCount';
    S_SkipRecCount = 'SkipRecCount';
    S_AllowCaptions = 'AllowCaptions';
    S_OnlyVisibleFields = 'OnlyVisibleFields';
    S_AutoCalcStrType = 'AutocalcStrType';
    S_CaptionRow = 'CaptionRow';
  S_FORMATS = 'FORMATS';
    S_Integer = 'Integer';
    S_Float = 'Float';
    S_Date = 'Date';
    S_Time = 'Time';
    S_DateTime = 'DateTime';
    S_Currency = 'Currency';
    S_BooleanTrue = 'BooleanTrue';
    S_BooleanFalse = 'BooleanFalse';
    S_NullString = 'NullString';
  S_USER_FORMATS = 'USER_FORMATS';
  S_FIELDS = 'FIELDS';
    S_Field = 'field';
  S_HEADER = 'HEADER';
  S_FOOTER = 'FOOTER';
    S_Line = 'line';
  S_CAPTIONS = 'CAPTIONS';
  S_WIDTH = 'WIDTH';
  S_ALIGN = 'ALIGN';
  S_LENGTH = 'LENGTH';
  S_XLS = 'XLS';
    S_PageHeader = 'PageHeader';
    S_PageFooter = 'PageFooter';
    S_SheetTitle = 'SheetTitle';
    S_StripType = 'StripType';
    S_AutoCalcColWidth = 'AutoCalcColWidth';
    S_PageBackground = 'PageBackground';
  S_XLS_FIELD = 'XLS_FIELD_';
  S_XLS_OPTION = 'XLS_OPTION_';
  S_XLS_OPTION_HEADER = 'XLS_OPTION_HEADER';
  S_XLS_OPTION_CAPTION = 'XLS_OPTION_CAPTION';
  S_XLS_OPTION_AGGREGATE = 'XLS_OPTION_AGGREGATE';
  S_XLS_OPTION_FOOTER = 'XLS_OPTION_FOOTER';
  S_XLS_STYLE = 'XLS_STYLE_';
  S_XLS_HYPERLINK = 'XLS_HYPERLINK_';
  S_XLS_NOTE = 'XLS_NOTE_';
  S_XLS_SERIES = '_SERIES_';
  S_XLS_CHART = 'XLS_CHART_';
  S_XLS_CELL = 'XLS_CELL_';
  S_XLS_MERGED_CELL = 'XLS_MERGED_CELL_';
    S_XLS_FontName = 'FontName';
    S_XLS_FontSize = 'FontSize';
    S_XLS_FontColor = 'FontColor';
    S_XLS_FontBold = 'FontBold';
    S_XLS_FontItalic = 'FontItalic';
    S_XLS_FontStrikeOut = 'FontStrikeOut';
    S_XLS_FontUnderline = 'FontUnderline';
    S_XLS_HorAlignment = 'HorAlignment';
    S_XLS_VertAlignment = 'VertAlignment';
    S_XLS_BorderTop = 'BorderTop';
    S_XLS_BorderTopColor = 'BorderTopColor';
    S_XLS_BorderBottom = 'BorderBottom';
    S_XLS_BorderBottomColor = 'BorderBottomColor';
    S_XLS_BorderLeft = 'BorderLeft';
    S_XLS_BorderLeftColor = 'BorderLeftColor';
    S_XLS_BorderRight = 'BorderRight';
    S_XLS_BorderRightColor = 'BorderRightColor';
    S_XLS_FillPattern = 'FillPattern';
    S_XLS_FillBackground = 'FillBackground';
    S_XLS_FillForeground = 'FillForeground';
    S_XLS_Aggregate = 'Aggregate';
    S_XLS_Hyperlink_Col = 'Col';
    S_XLS_Hyperlink_Row = 'Row';
    S_XLS_Hyperlink_Style = 'Style';
    S_XLS_Hyperlink_Title = 'Title';
    S_XLS_Hyperlink_Target = 'Target';
    S_XLS_Hyperlink_ScreenTip = 'ScreenTip';
    S_XLS_Note_Col = 'Col';
    S_XLS_Note_Row = 'Row';
    S_XLS_Note_Lines = 'LINES';
    S_XLS_Note_FontName = 'FontName';
    S_XLS_Note_FontSize = 'FontSize';
    S_XLS_Note_FontColor = 'FontColor';
    S_XLS_Note_FontBold = 'FontBold';
    S_XLS_Note_FontItalic = 'FontItalic';
    S_XLS_Note_FontStrikeOut = 'FontStrikeOut';
    S_XLS_Note_FontUnderline = 'FontUnderline';
    S_XLS_Note_HorAlignment = 'HorAlignment';
    S_XLS_Note_VertAlignment = 'VertAlignment';
    S_XLS_Note_BackgroundColor = 'BackgroundColor';
    S_XLS_Note_ForegroundColor = 'ForegroundColor';
    S_XLS_Note_FillType = 'FillType';
    S_XLS_Note_Transparency = 'Transparency';
    S_XLS_Note_Orientation = 'Orientation';
    S_XLS_Note_Gradient = 'Gradient';
    S_XLS_DataRange_Col1 = 'Col1';
    S_XLS_DataRange_Row1 = 'Row1';
    S_XLS_DataRange_Col2 = 'Col2';
    S_XLS_DataRange_Row2 = 'Row2';
    S_XLS_Series_Color = 'Color';
    S_XLS_Series_Title = 'Title';
    S_XLS_Series_DataColumn = 'Column';
    S_XLS_Series_DataRangeType = 'DataRangeType';
    S_XLS_ChartPlacement = 'ChartPlacement';
    S_XLS_ChartHeight = 'ChartHeight';
    S_XLS_ChartLeft = 'ChartLeft';
    S_XLS_ChartTop = 'ChartTop';
    S_XLS_ChartWidth = 'ChartWidth';
    S_XLS_ChartPosition_X1 = 'X1';
    S_XLS_ChartPosition_Y1 = 'Y1';
    S_XLS_ChartPosition_X2 = 'X2';
    S_XLS_ChartPosition_Y2 = 'Y2';
    S_XLS_ChartPositionType = 'PositionType';
    S_XLS_Chart_AutoColor = 'AutoColor';
    S_XLS_Chart_LegendPlacement = 'LegendPlacement';
    S_XLS_Chart_ShowLegend = 'ShowLegend';
    S_XLS_Chart_Style = 'Style';
    S_XLS_Chart_Title = 'Title';
    S_XLS_Chart_CategoryLabelsType = 'CategoryLabelsType';
    S_XLS_Chart_CategoryLabelsColumn = 'CategoryLabelsColumn';
    S_XLS_Cell_CellType = 'CellType';
    S_XLS_Cell_Col = 'Col';
    S_XLS_Cell_Row = 'Row';
    S_XLS_Cell_DateTimeFormat = 'DateTimeFormat';
    S_XLS_Cell_NumericFormat = 'NumericFormat';
    S_XLS_Cell_BooleanValue = 'BooleanValue';
    S_XLS_Cell_DateTimeValue_Year = 'Year';
    S_XLS_Cell_DateTimeValue_Month = 'Month';
    S_XLS_Cell_DateTimeValue_Day = 'Day';
    S_XLS_Cell_DateTimeValue_Hour = 'Hour';
    S_XLS_Cell_DateTimeValue_Min = 'Min';
    S_XLS_Cell_DateTimeValue_Sec = 'Sec';
    S_XLS_Cell_DateTimeValue_MSec = 'MSec';
    S_XLS_Cell_NumericValue_Separator = 'Separator';
    S_XLS_Cell_NumericValue = 'NumericValue';
    S_XLS_Cell_StringValue = 'StringValue';
    S_XLS_MergedCell_FirstCol = 'FirstCol';
    S_XLS_MergedCell_FirstRow = 'FirstRow';
    S_XLS_MergedCell_LastCol = 'LastCol';
    S_XLS_MergedCell_LastRow = 'LastRow';
  S_RTF = 'RTF';
    S_RTF_PageOrientation = 'PageOrientation';
//    S_RTF_DefaultCaptionAlign = 'DefaultCaptionAlign';
    S_RTF_StripType = 'StripType';
  S_RTF_STYLE = 'RTF_STYLE_';
  S_RTF_STYLE_HEADER = 'RTF_STYLE_HEADER';
  S_RTF_STYLE_CAPTION = 'RTF_STYLE_CAPTION';
  S_RTF_STYLE_DATA = 'RTF_STYLE_DATA';
  S_RTF_STYLE_FOOTER = 'RTF_STYLE_FOOTER';
  S_RTF_STRIP_STYLE = 'RTF_STRIP_STYLE_';
    S_RTF_FontName = 'FontName';
    S_RTF_FontSize = 'FontSize';
    S_RTF_FontColor = 'FontColor';
    S_RTF_FontBold = 'FontBold';
    S_RTF_FontItalic = 'FontItalic';
    S_RTF_FontUnderline = 'FontUnderline';
    S_RTF_FontStrikeOut = 'FontStrikeOut';
    S_RTF_BackgroundColor = 'BackgroundColor';
    S_RTF_HighlightColor = 'HighlightColor';
    S_RTF_AllowHighlight = 'AllowHighlight';
    S_RTF_AllowBackground = 'AllowBackground';
    S_RTF_Alignment = 'Alignment';
  S_HTML = 'HTML';
    S_HTML_Title = 'Title';
    S_HTML_CSS = 'CSS';
    S_HTML_CSSFile = 'CSSFile';
    S_HTML_OverwriteCSSFile='OverwriteCSSFile';
    S_HTML_FileRecCount = 'FileRecCount';
    S_HTML_GenerateIndex = 'GenerateIndex';
    S_HTML_IndexLinkTemplate = 'IndexLinkTemplate';
    S_HTML_NavigationOnTop = 'NavigationOnTop';
    S_HTML_NavigationOnBottom = 'NavigationOnBottom';
    S_HTML_IndexLinkTitle = 'IndexLinkTitle';
    S_HTML_FirstLinkTitle = 'FirstLinkTitle';
    S_HTML_PriorLinkTitle = 'PriorLinkTitle';
    S_HTML_NextLinkTitle = 'NextLinkTitle';
    S_HTML_LastLinkTitle = 'LastLinkTitle';
    S_HTML_FontName = 'FontName';
    S_HTML_FontColor = 'FontColor';
    S_HTML_BackgroundColor = 'BackgroundColor';
    S_HTML_BackgroundFile = 'BackgroundFile';
    S_HTML_BodyAdvanced = 'BodyAdvanced';
    S_HTML_CellPadding = 'CellPadding';
    S_HTML_CellSpacing = 'CellSpacing';
    S_HTML_BorderWidth = 'BorderWidth';
    S_HTML_TableBackground = 'TableBackground';
    S_HTML_TableAdvanced = 'TableAdvanced';
    S_HTML_HeadBackgroundColor = 'HeadBackgroundColor';
    S_HTML_HeadFontColor = 'HeadFontColor';
    S_HTML_OddRowBackgroundColor = 'OddRowBackgroundColor';
    S_HTML_EvenRowBackgroundColor = 'EvenRowBackgroundColor';
    S_HTML_DataFontColor = 'DataFontColor';
    S_HTML_LinkColor = 'LinkColor';
    S_HTML_VLinkColor = 'VLinkColor';
    S_HTML_ALinkColor = 'ALinkColor';
    S_HTML_InterpretTags = 'InterpretTags';
  S_XML = 'XML';
    S_XML_Standalone = 'Standalone';
    S_XML_Encoding = 'Encoding';
  S_SQL = 'SQL';
    S_SQL_TableName = 'TableName';
    S_SQL_CreateTable = 'CreateTable';
    S_SQL_CommitRecCount = 'CommitRecCount';
    S_SQL_CommitAfterScript = 'CommitAfterScript';
    S_SQL_CommitStatement = 'CommitStatement';
    S_SQL_NullValues = 'NullValues';
    S_SQL_StatementTerm = 'StatementTerm';
  S_TXT = 'TXT';
    S_TXT_AutoCalcColWidth = 'AutoCalcColWidth';
    S_TXT_Spacing = 'Spacing';
  S_CSV = 'CSV';
    S_CSV_QuoteStrings = 'QuoteStrings';
    S_CSV_Comma = 'Comma';
    S_CSV_Quote = 'Quote';
  S_ASCII = 'ASCII';
    S_ASCII_ExportType = 'ExportType';
    S_ASCII_AutoCalcColWidth = 'AutoCalcColWidth';
  S_ACCESS = 'ACCESS';
    S_ACCESS_Password = 'Password';
    S_ACCESS_TableName = 'TableName';
    S_ACCESS_CreateTable = 'CreateTable';
  S_PDF = 'PDF';
    S_PDF_ColSpacing = 'ColSpacing';
    S_PDF_RowSpacing = 'RowSpacing';
    S_PDF_GridLineWidth = 'GridLineWidth';
    S_PDF_PageFormat = 'PageFormat';
    S_PDF_PageWidth = 'PageWidth';
    S_PDF_PageHeight = 'PageHeight';
    S_PDF_PageUnits = 'PageUnits';
    S_PDF_PageOrientation = 'PageOrientation';
    S_PDF_PageMarginLeft = 'PageMarginLeft';
    S_PDF_PageMarginRight = 'PageMarginRight';
    S_PDF_PageMarginTop = 'PageMarginTop';
    S_PDF_PageMarginBottom = 'PageMarginBottom';
  S_PDF_OPTION_HEADER = 'PDF_OPTION_HEADER';
  S_PDF_OPTION_CAPTION = 'PDF_OPTION_CAPTION';
  S_PDF_OPTION_DATA = 'PDF_OPTION_DATA';
  S_PDF_OPTION_FOOTER = 'PDF_OPTION_FOOTER';
    S_PDF_FontName = 'FontName';
    S_PDF_FontEncoding = 'FontEncoding';
    S_PDF_FontSize = 'FontSize';
    S_PDF_FontColor = 'FontColor'; 

  //--- TFont
  S_FontName      = 'FontName';
  S_FontSize      = 'FontSize';
  S_FontBold      = 'FontBold';
  S_FontItalic    = 'FontItalic';
  S_FontUnderline = 'FontUnderline';
  S_FontStrikeOut = 'FontStrikeOut';
  S_FontColor     = 'FontColor';
  S_FontCharset   = 'FontCharset';

  S_Commit = 'COMMIT WORK;';
  S_CreateTable = 'CREATE TABLE %s';
  S_Insert = 'INSERT INTO %s';
  S_Values = 'VALUES';

  S_Index = 'Index';
  S_First = 'First';
  S_Prior = 'Prior';
  S_Next = 'Next';
  S_Last = 'Last';

  DefaultDotPerInch = 72;
  DefaultMMPerInch  = 25.4;

var
  DefaultDateFormat: string;
  DefaultTimeFormat: string;
  DefaultDateTimeFormat: string;
  DefaultCurrencyFormat: string;

procedure EditFontStyle(Font: TFont; Style: TFontStyle; Add: boolean);
procedure EditFontStyleXLS(Font: TxlsFont; Style: TxlsFontStyle; Add: boolean);
procedure SaveFontToIniFile(Font: TFont; IniFile: TIniFile;
  const Section: string);
procedure LoadFontFromIniFile(Font, Default: TFont; IniFile: TIniFile;
  const Section: string);

{$IFNDEF NOGUI}
procedure RTFItemEditFontStyle(Item: TListItem; Style: TFontStyle;
  Add: boolean);
procedure XLSItemEditFontStyle(Item: TListItem; Style: TxlsFontStyle;
  Add: boolean); // uncomment by pai
procedure XLSCustomFormatEditFontStyle(Item: TxlsCustomItem;
  Style: TxlsFontStyle; Add: boolean);
procedure PaintXLSColors(PaintBox: TPaintBox; AColor: TxlsColor);
procedure PaintStandardColors(PaintBox: TPaintBox; AColor: TColor);
procedure XLSItemSetUnderline(Item: TListItem; Underline: TxlsFontUnderline); // uncomment by pai
procedure XLSCustomItemSetUnderline(Item: TxlsCustomItem;
  Underline: TxlsFontUnderline);
procedure XLSItemSetHorAlignment(Item: TListItem;
  HorAlignment: TxlsHorizontalAlignment); // uncomment by pai
procedure XLSCustomItemSetHorAlignment(Item: TxlsCustomItem;
  HorAlignment: TxlsHorizontalAlignment);
procedure RTFItemSetAlignment(Item: TListItem; Alignment: TrtfTextAlignment);
procedure XLSItemSetVertAlignment(Item: TListItem;
  VertAlignment: TxlsVerticalAlignment); // uncomment by pai
procedure XLSCustomItemSetVertAlignment(Item: TxlsCustomItem;
  VertAlignment: TxlsVerticalAlignment);
procedure DrawXLSCell(PaintBox: TPaintBox; Format: TxlsFormat);
procedure DrawRTFSample(PaintBox: TPaintBox; rtfStyle: TrtfStyle);
procedure DrawBorderStyle(Style: TxlsBorderStyle; Canvas: TCanvas; Rect: TRect);

procedure SelectFontForPaintBox(FontDialog: TFontDialog; AFont: TFont;
  APaintBox: TPaintBox);
procedure PaintSampleFont(AFont: TFont; APaintBox: TPaintBox;
  PaintColor: boolean);

procedure DrawPattern(Canvas: TCanvas; Index, X, Y: integer);

procedure IncLeftAndTop(Control: TControl);
procedure DecLeftAndTop(Control: TControl);

procedure SetListItemIndex(Item: TListItem; Index: integer);
function MoveListItem(Item: TListItem; Dst: TListView; Move: boolean;
  Index: integer): TListItem;

function GetTextWidth(Control: TControl; const Text: string): integer;

procedure ForAllListViewItems(ListView: TListView; Proc: TListItemProc;
  IsDownTo, All: boolean);
procedure ForAllListViewCustomItems(ListView: TListView;
  Proc: TxlsCustomItemProc; IsDownTo, All: boolean);

function GetMemoCaretPos(Memo: TMemo): {$IFDEF WIN32}TPoint{$ELSE}TCaretPos{$ENDIF};
{$ENDIF}

procedure SetDefaultRTFCaption(Style: TrtfStyle);
procedure SetDefaultXLSCaption(Format: TxlsFormat);
function ColorByXLSColor(XLSColor: TxlsColor): TColor;
function ColorToXLSColor(Color: TColor): TxlsColor;


function CalcStringType(const S,
  BooleanTrue, BooleanFalse: string): TQExportColType;

procedure QExportCheckSource(ExportSource: TQExportSource;
  DataSet: TDataSet; CustomSource: TqeCustomSource 
  {$IFNDEF NOGUI}; DBGrid: TDBGrid; ListView: TListView;
  StringGrid: TStringGrid{$ENDIF});
function QExportSource(ExportSource: TQExportSource;
  DataSet: TDataSet; CustomSource: TqeCustomSource
  {$IFNDEF NOGUI}; DBGrid: TDBGrid; ListView: TListView;
  StringGrid: TStringGrid{$ENDIF}): TComponent;
procedure QExportGetColumns(ExportSource: TQExportSource;
  DataSet: TDataSet; CustomSource: TqeCustomSource; 
  {$IFNDEF NOGUI}DBGrid: TDBGrid; ListView: TListView;
  StringGrid: TStringGrid;{$ENDIF}ExportedFields, AvailableCols,
  ExportedCols: TStrings);
function QExportIsActive(ExportSource: TQExportSource;
  DataSet: TDataSet; CustomSource: TqeCustomSource
  {$IFNDEF NOGUI}; DBGrid: TDBGrid; ListView: TListView;
  StringGrid: TStringGrid{$ENDIF}): boolean;
function QExportIsEmpty(ExportSource: TQExportSource;
  DataSet: TDataSet; CustomSource: TqeCustomSource
  {$IFNDEF NOGUI}; DBGrid: TDBGrid; ListView: TListView;
  StringGrid: TStringGrid{$ENDIF}): boolean;
function QExportGetBookmark(ExportSource: TQExportSource; DataSet: TDataSet;
  CustomSource: TqeCustomSource{$IFNDEF NOGUI}; DBGrid: TDBGrid;
  ListView: TListView; StringGrid: TStringGrid{$ENDIF}): TBookmark;
procedure QExportGotoBookmark(ExportSource: TQExportSource; DataSet: TDataSet;
  CustomSource: TqeCustomSource;{$IFNDEF NOGUI}DBGrid: TDBGrid;
  ListView: TListView; StringGrid: TStringGrid;{$ENDIF} Bookmark: TBookmark);
procedure QExportFreeBookmark(ExportSource: TQExportSource; DataSet: TDataSet;
  {$IFNDEF NOGUI}DBGrid: TDBGrid; ListView: TListView;
  StringGrid: TStringGrid;{$ENDIF} Bookmark: TBookmark);
procedure QExportFirst(ExportSource: TQExportSource;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -