解决enlib控件4.3.21版本在导出到html格式时将所有行写在一行的问题DBGridEhImpExp

更新时间:2023-06-16 06:32:58 阅读: 评论:0

{*******************************************************}
{                                                      }
{                      EhLib v4.3                      }
{            DBGridEh import/export routines          }
{                      Build 4.3.03                    }
{                                                      }
{  Copyright (c) 1998-2008 by Dmitry V. Bolshakov      }
{                                                      }
{*******************************************************}
{$I EhLib.Inc}
{$IFDEF EH_LIB_VCL}
unit DBGridEhImpExp {$IFDEF CIL} platform {$ENDIF};
{$ELSE}
unit QDBGridEhImpExp;
{$ENDIF}
interface
{$IFDEF EH_LIB_VCL}
us
Windows, SysUtils, Class, Graphics, Dialogs, GridsEh, Controls,
{$IFDEF EH_LIB_6}Variants, {$ENDIF}
{$IFDEF CIL}
EhLibVCLNET,
独特的自我介绍
System.Runtime.InteropServices, System.Reflection,
{$ELSE}
EhLibVCL,
说话算话
{$ENDIF}
DBGridEh, Db, Clipbrd;
{$ELSE}
us百雀羚三生花
SysUtils, Class, QGraphics, QDialogs, QGrids, QDBGrids, QControls,
Variants, QDBGridEh, Db, QClipbrd;
{$ENDIF}
type
/
/{$IFNDEF CIL}
戴面具的动漫人物//  TFooterValues = array[0..MaxListSize - 1] of Currency;
//  PFooterValues = ^TFooterValues;
//{$ENDIF}
TFooterValues = array of Currency;
{ TDBGridEhExport }
TDBGridEhExport = class(TObject)
private
FColCellParamsEh: TColCellParamsEh;
FDBGridEh: TCustomDBGridEh;
FExpCols: TColumnsEhList;
FStream: TStream;
function GetFooterValue(Row, Col: Integer): String;
procedure CalcFooterValues;
protected
FooterValues: TFooterValues;
procedure WritePrefix; virtual;
procedure WriteSuffix; virtual;
procedure WriteTitle(ColumnsList: TColumnsEhList); virtual;
秋天干燥procedure WriteRecord(ColumnsList: TColumnsEhList);overload; virtual;
procedure WriteRecord(ColumnsList: TColumnsEhList;LastColumns:TStrings);overload; virtual;
procedure WriteDataCell(Column: TColumnEh; FColCellParamsEh: TColCellParamsEh);  virtual;
procedure WriteFooter(ColumnsList: TColumnsEhList; FooterNo: Integer); virtual;
他的东西一直放在里面一整夜procedure WriteFooterCell(DataCol, Row: Integer; Column: TColumnEh; AFont: TFont;
Background: TColor; Alignment: TAlignment; Text: String); virtual;
property Stream: TStream read FStream write FStream;
property ExpCols: TColumnsEhList read FExpCols write FExpCols;
public
constructor Create; virtual;
destructor Destroy; override;
procedure ExportToStream(AStream: TStream; IsExportAll: Boolean); virtual;
procedure ExportToFile(FileName: String; IsExportAll: Boolean); virtual;
property DBGridEh: TCustomDBGridEh read FDBGridEh write FDBGridEh;
end;
TDBGridEhExportClass = class of TDBGridEhExport;
{ TDBGridEhExportAsText }
TDBGridEhExportAsText = class(TDBGridEhExport)
private
FirstRec: Boolean;
FirstCell: Boolean;
protected
procedure CheckFirstRec; virtual;
procedure CheckFirstCell; virtual;
proced
ure WritePrefix; override;
procedure WriteSuffix; override;
procedure WriteTitle(ColumnsList: TColumnsEhList); override;
procedure WriteFooter(ColumnsList: TColumnsEhList; FooterNo: Integer); override;
procedure WriteRecord(ColumnsList: TColumnsEhList); override;
procedure WriteDataCell(Column: TColumnEh; FColCellParamsEh: TColCellParamsEh); override;
procedure WriteFooterCell(DataCol, Row: Integer; Column: TColumnEh; AFont: TFont;
Background: TColor; Alignment: TAlignment; Text: String); override;
public
procedure ExportToStream(Stream: TStream; IsExportAll: Boolean); override;
end;
{ TDBGridEhExportAsUnicodeText }
TDBGridEhExportAsUnicodeText = class(TDBGridEhExport)
private
FirstRec: Boolean;
FirstCell: Boolean;
protected
procedure CheckFirstRec; virtual;
procedure CheckFirstCell; virtual;
procedure WritePrefix; override;
procedure WriteSuffix; override;
procedure WriteTitle(ColumnsList: TColumnsEhList); override;
procedure WriteFooter(ColumnsList: TColumnsEhList; FooterNo: Integer); override;
procedure WriteRecord(ColumnsList: TColumnsEhList); override;
procedure WriteDataCell(Column: TColumnEh; FColCellParamsEh: TColCellParamsEh); override;
procedure WriteFooterCell(DataCol, Row: Integer; Column: TColumnEh; AFont: TFont;
Background: TColor; Alignment: TAlignment; Text: String); override;
public
procedure ExportToStream(Stream: TStream; IsExportAll: Boolean); override;
end;
{ TDBGridEhExportAsCSV }
TDBGridEhExportAsCSV = class(TDBGridEhExportAsText)
private
FSeparator: AnsiChar;
protected
procedure CheckFirstCell; override;
procedure WriteTitle(ColumnsList: TColumnsEhList); override;
procedure WriteDataCell(Column: TColumnEh; FColCellParamsEh: TColCellParamsEh); override;
procedure WriteFooterCell(DataCol, Row: Integer; Column: TColumnEh; AFont: TFont;
Background: TColor; Alignment: TAlignment; Text: String); override;
public
constructor Create; override;
property Separator: AnsiChar read FSeparator write FSeparator;
end;
{ TDBGridEhExportAsHTML }
TDBGridEhExportAsHTML = class(TDBGridEhExport)
private
function GetAlignment(Alignment: TAlignment): String;
function GetColor(Color: TColor): String;
procedure PutText(Font: TFont; Text: String);
procedure Put(Text: String);
procedure PutL(Text: String);
protected
procedure WritePrefix; override;
procedure WriteSuffix; override;
procedure WriteTitle(ColumnsList: TColumnsEhList); override;
procedure WriteRecord(ColumnsList: TColumnsEhList);override;
procedure WriteRecord(ColumnsList: TColumnsEhList;LastColumns:TStrings);override; // Added by 杨海生 2013-06-17 16:36:19
procedure WriteDataCell(Column: TColumnEh; FColCellParamsEh: TColCellParamsEh); override;
procedure WriteFooter(ColumnsList: TColumnsEhList; FooterNo: Integer)
; override;
procedure WriteFooterCell(DataCol, Row: Integer; Column: TColumnEh; AFont: TFont;
Background: TColor; Alignment: TAlignment; Text: String); override;
end;
{ TDBGridEhExportAsRTF }
TDBGridEhExportAsRTF = class(TDBGridEhExport)
private
FCacheStream: TMemoryStreamEh;
ColorTblList: TStrings;
FontTblList: TStrings;
function GetFontIndex(FontName: String): Integer;
function GetColorIndex(Color: TColor): Integer;
function GetAlignment(Alignment: TAlignment): String;
function GetDataCellColor(ColumnsList: TColumnsEhList; ColIndex: Integer): TColor;
function GetFooterCellColor(ColumnsList: TColumnsEhList; ColIndex: Integer;
FooterNo: Integer): TColor;
procedure PutText(Font: TFont; Text: String; Background: TColor);
procedure Put(Text: String);
procedure PutL(Text: String);
protected
procedure WriteCellBorder(LeftBorder, TopBorder, BottomBorder, RightBorder: Boolean);
procedure WritePrefix; override;
procedure WriteSuffix; override;
procedure WriteTitle(ColumnsList: TColumnsEhList); override;
procedure WriteRecord(ColumnsList: TColumnsEhList); override;
procedure WriteDataCell(Column: TColumnEh; FColCellParamsEh: TColCellParamsEh); override;
procedure WriteFooter(ColumnsList: TColumnsEhList; FooterNo: Integer); override;
procedure WriteFooterCell(DataCol, Row: Integer; Column: TColumnEh; AFont: TFont;
Background: TColor; Alignment: TAlignment; Text: String); override;
public
procedure ExportToStream(AStream: TStream; IsExportAll: Boolean); override;
end;
{ TDBGridEhExportAsXLS }
TDBGridEhExportAsXLS = class(TDBGridEhExport)
private
FCol, FRow: Word;
procedure WriteBlankCell;
procedure WriteIntegerCell(const AValue: Integer);
procedure WriteFloatCell(const AValue: Double);
procedure WriteStringCell(const AValue: String);
procedure IncColRow;
protected
procedure WritePrefix; override;
procedure WriteSuffix; override;
procedure WriteTitle(ColumnsList: TColumnsEhList); override;
procedure WriteDataCell(Column: TColumnEh; FColCellParamsEh: TColCellParamsEh); override;
procedure WriteFooterCell(DataCol, Row: Integer; Column: TColumnEh; AFont: TFont;
Background: TColor; Alignment: TAlignment; Text: String); override;
public
procedure ExportToStream(AStream: TStream; IsExportAll: Boolean); override;
end;
{ TDBGridEhExportAsVCLDBIF }
{Internal format for interchange between DataSet bad components}
{ BOF (Beginning of File)
Byte      |  0    1    2    3    4    5    6 |  0 |  0    1    2    3 |
-------------------------------------------------------------
Contents  |  V |  C |  L |  D |  B |  I |  F |  1 |  X |  X |  X |  X |
-------------------------------------------------------------
|  Signatura                      |Vers|  Columns count
|
|                                  |ion |                  |
Fields Names
Byte      |  0 |  0    1    2    3  ...  X |  0 |  0    1    2    3  ...
------------------------------------------------------------- ...
Contents  |  X |  N |  a |  m |  e |  1 |  0 |  X |  N |  a |  m |  e |  2 | 0
------------------------------------------------------------- ...
|Colu| Null terminated field name  |Colu| Null terminated field name
|mn  |                            |mn  |
|visi|                            |visi|
|ble 1 or 0                        |ble 1 or 0
Values
----------------
Unassigned, skip value
ftUnknown,  ftCursor, ftADT, ftArray, ftReference, ftDataSet, ftVariant,
ftInterface, ftIDispatch,
Byte      |  0 |
------
Contents  |  1 |
------
|Type|
----------------
NULL
Byte      |  0 |
-
-----
Contents  |  2 |
------
|Type|
----------------
INTEGER32
ftSmallint, ftInteger, ftWord, ftBoolean, ftAutoInc
Byte      |  0 |  0    1    2    3 |
--------------------------
Contents  |  3 |  X |  X |  X |  X |
--------------------------
|Type|  Intetger value  |
|  (Longint)      |
----------------
FLOAT64
ftFloat, ftCurrency, ftBCD, ftDate, ftTime, ftDateTime,
Byte      |  0 |  0    1    2    3    4    5    6    7 |
----------------------------------------------
Contents  |  4 |  X |  X |  X |  X |  X |  X |  X |  X |
----------------------------------------------
|Type|  Float value (Double)                |
----------------
STRING
ftString, ftMemo, ftFixedChar, ftLargeint, ftOraClob, ftGuid
Byte      |  0 |  0    1    2    3 |  0    1    2  ...  N |
---------------------------------------------------
Contents  |  5 |  X |  X |  X |  X |  a |  b |  c | ...  0 |
---------------------------------------------------
|Type|  Size (Longint)  |  String body including |
|  null terminator      |
----------------
BINARY DATA
ftBlob, ftGraphic, ftFmtMemo, ftParadoxOle, ftDBaOle, ftOraBlob,
ftBytes, ftTypedBinary, ftVarBytes, ftWideString,
Byte      |  0 |  0    1    2    3 |  0    1    2  ...  N |
---------------------------------------------------
Contents  |  6 |  X |  X |  X |  X |  a |  b |  c | ...  X |
---------------------------------------------------
|Type|  Size (Longword)  |  data                  |
----------------
EOF (End of File)
Byte      |  0 |
------
Contents  |  0 |
-教我
-----
|Type|
}
TVCLDBIF_BOF = packed record
Signatura: array[0..6] of AnsiChar;
Version: Byte;
ColCount: Longint;
end;
TVCLDBIF_INTEGER32 = packed record
AType: Byte;
Value: Longint;
end;
TVCLDBIF_FLOAT64 = packed record
AType: Byte;
Value: Double;
end;
TVCLDBIF_ANSI_STRING = packed record
AType: Byte;
Size: Longint;
end;
TVCLDBIF_WIDE_STRING = packed record
AType: Byte;
Size: Longint;
end;
TVCLDBIF_BINARY_DATA = packed record
AType: Byte;
Size: Longint;
end;
const
TVCLDBIF_TYPE_EOF = 0;
TVCLDBIF_TYPE_UNASSIGNED = 1;
TVCLDBIF_TYPE_NULL = 2;
TVCLDBIF_TYPE_INTEGER32 = 3;
TVCLDBIF_TYPE_FLOAT64 = 4;
TVCLDBIF_TYPE_ANSI_STRING = 5;
TVCLDBIF_TYPE_BINARY_DATA = 6;
TVCLDBIF_TYPE_WIDE_STRING = 7;
type
TDBGridEhExportAsVCLDBIF = class(TDBGridEhExport)
private
//    function CalcColCount:Word;
procedure WriteUnassigned;
procedure WriteNull;
procedure WriteInteger(AValue: Longint);
procedure WriteFloat(AValue: Double);
procedure WriteAnsiString(AValue: AnsiString);
procedure WriteWideString(AValue: WideString);
procedure WriteBinaryData(AValue: AnsiString);
protected
procedure WritePrefix; override;
procedure WriteSuffix; override;
procedure WriteDataCell(Column: TColumnEh; FColCellParamsEh: TColCellParamsEh); override;
end;
{ TDBGridEhImport }
TDBGridEhImport = class(TObject)
private
FDBGridEh: TCustomDBGridEh;
FStream: TStream;
FImpCols: TColumnsEhList;
protected
Eos: Boolean;
procedure ReadPrefix; virtual;
procedure ReadSuffix; virtual;
procedure ReadRecord(ColumnsList: TColumnsEhList); virtual;
procedure ReadDataCell(Column: TColumnEh); virtual;
property Stream: TStream read FStream write FStream;
property ImpCols: TColumnsEhList read FImpCols write FImpCols;
public
constructor Create; virtual;
procedure ImportFromStream(AStream: TStream; IsImportAll: Boolean); virtual;
优秀团员有什么用procedure ImportFromFile(FileName: String; IsImportAll: Boolean); virtual;
property DBGridEh: TCustomDBGridEh read FDBGridEh write FDBGridEh;
end;
TDBGridEhImportClass = class of TDBGridEhImport;
{ TDBGridEhImportAsText }
TImportTextSreamState = (itssChar, itssTab, itssNewLine, itssEof);
TDBGridEhImportAsText = class(TDBGridEhImport)
private
FLastChar: AnsiChar;
FLastState: TImportTextSreamState;
FLastString: AnsiString;
FIgnoreAll: Boolean;
function GetChar(var ch: AnsiChar): Boolean;
function CheckState: TImportTextSreamState;
function GetString(var Value: AnsiString): TImportTextSreamState;
protected
procedure ReadPrefix; override;
procedure ReadRecord(ColumnsList: TColumnsEhList); override;
procedure ReadDataCell(Column: TColumnEh); override;
public
procedure ImportFromStream(AStream: T

本文发布于:2023-06-16 06:32:58,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1040717.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:动漫   放在   人物   东西
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图