📄 qimport3wizard.pas
字号:
procedure TuneFormats;
procedure SetEnabledDataFormatControls;
procedure ShowFormatItem(Item: TListItem);
//---- Utilities
procedure LoadTemplateFromFile(const AFileName: qiString);
procedure SaveTemplateToFile(const AFileName: qiString);
procedure SetTitle;
procedure TuneStart;
procedure TuneFinish;
procedure TuneMap;
procedure TuneButtons;
function StartReady: boolean;
//---- Property's methods
procedure SetXLSSkipCols(const Value: Integer);
procedure SetXLSSkipRows(const Value: Integer);
procedure SetDBFSkipDeleted(const Value: boolean);
procedure SetTXTSkipLines(const Value: Integer);
procedure SetTXTEncoding(const Value: TQICharsetType);
procedure SetCSVSkipLines(const Value: Integer);
{$IFDEF HTML}
{$IFDEF VCL6}
procedure SetHTMLSkipLines(const Value: Integer);
{$ENDIF}
{$ENDIF}
{$IFDEF XLSX}
{$IFDEF VCL6}
procedure SetXlsxSkipLines(const Value: Integer);
procedure SetXlsxSheetName(const Value: qiString);
procedure SetXlsxLoadHiddenSheet(const Value: Boolean);
procedure SetXlsxNeedFillMerge(const Value: Boolean);
{$ENDIF}
{$ENDIF}
{$IFDEF DOCX}
{$IFDEF VCL6}
procedure SetDocxSkipLines(const Value: Integer);
procedure SetDocxTableNumber(const Value: Integer);
// procedure SetXlsxNeedFillMerge(const Value: Boolean);
{$ENDIF}
{$ENDIF}
{$IFDEF ODS}
{$IFDEF VCL6}
procedure SetODSSkipLines(const Value: Integer);
procedure SetODSSheetName(const Value: AnsiString);
{$ENDIF}
{$ENDIF}
{$IFDEF ODT}
{$IFDEF VCL6}
procedure SetODTSkipLines(const Value: Integer);
procedure SetODTSheetName(const Value: AnsiString);
{$ENDIF}
{$ENDIF}
procedure SetXMLWriteOnFly(const Value: boolean);
{$IFDEF XMLDOC}
{$IFDEF VCL6}
procedure SetXMLDocSkipLines(const Value: Integer);
procedure SetXMLDocXPath(const Value: qiString);
procedure SetXMLDocDataLocation(const Value: TXMLDataLocation);
{$ENDIF}
{$ENDIF}
procedure SetDecimalSeparator(const Value: Char);
procedure SetThousandSeparator(const Value: Char);
procedure SetShortDateFormat(const Value: String);
procedure SetLongDateFormat(const Value: String);
procedure SetDateSeparator(const Value: Char);
procedure SetShortTimeFormat(const Value: String);
procedure SetLongTimeFormat(const Value: String);
procedure SetTimeSeparator(const Value: Char);
procedure SetCommitAfterDone(const Value: boolean);
procedure SetCommitRecCount(const Value: Integer);
procedure SetImportRecCount(const Value: Integer);
procedure SetCloseAfterImport(const Value: boolean);
procedure SetEnableErrorLog(const Value: boolean);
procedure SetErrorLogFileName(const Value: qiString);
procedure SetRewriteErrorLogFile(const Value: boolean);
procedure SetShowErrorLog(const Value: boolean);
procedure SetImportMode(const Value: TQImportMode);
procedure SetAddType(const Value: TQImportAddType);
procedure ApplyDataFormats(AImport: TQImport3);
{$IFDEF ADO}
procedure bAccessAddMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure bAccessAddMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure bAccessAutoFillMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure bAccessAutoFillMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure bAccessClearMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure bAccessClearMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure bAccessRemoveMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure bAccessRemoveMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure pbAccessAddPaint(Sender: TObject);
procedure pbAccessAutoFillPaint(Sender: TObject);
procedure pbAccessClearPaint(Sender: TObject);
procedure pbAccessRemovePaint(Sender: TObject);
{$ENDIF}
protected
{$IFDEF HTML}
{$IFDEF VCL6}
sgrHTML: TqiStringGrid;
{$ENDIF}
{$ENDIF}
{$IFDEF XMLDOC}
{$IFDEF VCL6}
sgrXMLDoc: TqiStringGrid;
{$ENDIF}
{$ENDIF}
sgrCSV: TqiStringGrid;
vwTXT: TQImport3TXTViewer;
paTip: TInfoPanel;
property Wizard: TQImport3Wizard read GetWizard;
property TemplateFileName: qiString read GetTemplateFileName;
property AutoLoadTemplate: boolean read GetAutoLoadTemplate;
property ImportDestination: TQImportDestination read GetImportDestination;
property GridCaptionRow: Integer read GetGridCaptionRow;
property GridStartRow: Integer read GetGridStartRow;
property KeyColumns: TStrings read GetKeyColumns;
property ImportType: TAllowedImport read FImportType write SetImportType;
property FileName: qiString read FFileName write SetFileName;
property GoToLastPage: boolean read FGoToLastPage write SetGoToLastPage;
property AutoSaveTemplate: boolean read FAutoSaveTemplate
write SetAutoSaveTemplate;
property DataSet: TDataSet read FDataSet write FDataSet;
property DBGrid: TDBGrid read FDBGrid write FDBGrid;
property ListView: TListView read FListView write FListView;
property StringGrid: TStringGrid read FStringGrid write FStringGrid;
property Comma: AnsiChar read FComma write SetComma;
property Quote: AnsiChar read FQuote write SetQuote;
property Step: Integer read FStep write SetStep;
property FieldFormats: TQImportFieldFormats read FDataFormats
write FDataFormats;
// XLS
property XLSSkipCols: Integer read FXLSSkipCols write SetXLSSkipCols;
property XLSSkipRows: Integer read FXLSSkipRows write SetXLSSkipRows;
{$IFDEF ADO}
// Access
property AccessPassword: string read FAccessPassword
write SetAccessPassword;
property AccessSourceType: TQImportAccessSourceType read FAccessSourceType
write SetAccessSourceType;
{$ENDIF}
// DBF
property DBFSkipDeleted: boolean read FDBFSkipDeleted
write SetDBFSkipDeleted;
// TXT
property TXTSkipLines: Integer read FTXTSkipLines write SetTXTSkipLines;
property TXTEncoding: TQICharsetType read FTXTEncoding write SetTXTEncoding;
// CSV
property CSVSkipLines: Integer read FCSVSkipLines write SetCSVSkipLines;
{$IFDEF HTML}
{$IFDEF VCL6}
// HTML
property HTMLSkipLines: Integer read FHTMLSkipLines write SetHTMLSkipLines;
{$ENDIF}
{$ENDIF}
{$IFDEF XLSX}
{$IFDEF VCL6}
// Xlsx
property XlsxSkipLines: Integer read FXlsxSkipLines write SetXlsxSkipLines;
property XlsxSheetName: qiString read FXlsxSheetName write SetXlsxSheetName;
property XlsxNeedFillMerge: Boolean read FXlsxNeedFillMerge write SetXlsxNeedFillMerge;
property XlsxLoadHiddenSheet: Boolean read FXlsxLoadHiddenSheet write SetXlsxLoadHiddenSheet;
{$ENDIF}
{$ENDIF}
{$IFDEF DOCX}
{$IFDEF VCL6}
// Docx
property DocxSkipLines: Integer read FDocxSkipLines write SetDocxSkipLines;
property DocxTableNumber: Integer read FDocxTableNumber write SetDocxTableNumber;
{$ENDIF}
{$ENDIF}
{$IFDEF ODS}
{$IFDEF VCL6}
// ODS
property ODSSkipLines: Integer read FODSSkipLines write SetODSSkipLines;
property ODSSheetName: AnsiString read FODSSheetName write SetODSSheetName;
{$ENDIF}
{$ENDIF}
{$IFDEF ODT}
{$IFDEF VCL6}
// ODT
property ODTSkipLines: Integer read FODTSkipLines write SetODTSkipLines;
property ODTSheetName: AnsiString read FODTSheetName write SetODTSheetName;
property ODTUseHeader: Boolean read FODTUseHeader write FODTUseHeader;
property ODTComplex: Boolean read FODTComplex write FODTComplex;
{$ENDIF}
{$ENDIF}
// XML
property XMLWriteOnFly: boolean read FXMLWriteOnFly write SetXMLWriteOnFly;
{$IFDEF XMLDOC}
{$IFDEF VCL6}
// XMLDoc
property XMLDocSkipLines: Integer read FXMLDocSkipLines
write SetXMLDocSkipLines;
property XMLDocXPath: qiString read FXMLDocXPath write SetXMLDocXPath;
property XMLDocDataLocation: TXMLDataLocation read FXMLDocDataLocation
write SetXMLDocDataLocation;
{$ENDIF}
{$ENDIF}
// Base format
property DecimalSeparator: Char read FDecimalSeparator
write SetDecimalSeparator;
property ThousandSeparator: Char read FThousandSeparator
write SetThousandSeparator;
property ShortDateFormat: String read FShortDateFormat
write SetShortDateFormat;
property LongDateFormat: String read FLongDateFormat
write SetLongDateFormat;
property DateSeparator: Char read FDateSeparator write SetDateSeparator;
property ShortTimeFormat: String read FShortTimeFormat
write SetShortTimeFormat;
property LongTimeFormat: String read FLongTimeFormat
write SetLongTimeFormat;
property TimeSeparator: Char read FTimeSeparator write SetTimeSeparator;
//---- Last Step
property CommitAfterDone: boolean read FCommitAfterDone
write SetCommitAfterDone;
property CommitRecCount: Integer read FCommitRecCount
write SetCommitRecCount;
property ImportRecCount: Integer read FImportRecCount
write SetImportRecCount;
property CloseAfterImport: boolean read FCloseAfterImport
write SetCloseAfterImport;
property EnableErrorLog: boolean read FEnableErrorLog
write SetEnableErrorLog;
property ErrorLogFileName: qiString read FErrorLogFileName
write SetErrorLogFileName;
property RewriteErrorLogFile: boolean read FRewriteErrorLogFile
write SetRewriteErrorLogFile;
property ShowErrorLog: boolean read FShowErrorLog
write SetShowErrorLog;
property ImportMode: TQImportMode read FImportMode
write SetImportMode;
property AddType: TQImportAddType read FAddType
write SetAddType;
public
property Import: TQImport3 read FImport write FImport;
end;
implementation
uses
{$IFDEF QI_UNICODE}GpTextFile, {$ENDIF}
{$IFDEF VCL6} Variants, {$ENDIF}
QImport3StrIDs, DBFFile3, fuQImport3Loading, Math, QImport3Common,
SysUtils, Messages, IniFiles, XLSUtils3, XLSCalculate3, fuQImport3XLSRangeEdit,
fuQImport3ReplacementEdit, EmsWideStringCanvas;
{$R *.DFM}
{ TQImport3Wizard }
constructor TQImport3Wizard.Create(AOwner: TComponent);
begin
inherited;
FAllowedImports := [Low(TAllowedImport)..High(TAllowedImport)];
FImportRecCount := 0;
FCommitRecCount := 100;
FCommitAfterDone := True;
FErrorLog := False;
FErrorLogFileName := 'error.log';
FRewriteErrorLogFile := True;
FShowErrorLog := False;
FShowProgress := True;
FAutoChangeExtension := True;
FShowHelpButton := True;
FCloseAfterImport := False;
FFormats := TQImportFormats.Create;
FFieldFormats := TQImportFieldFormats.Create(Self);
FShowSaveLoadButtons := False;
FAutoLoadTemplate := False;
FAutoSaveTemplate := False;
FGoToLastPage := False;
FImportDestination := qidDataSet;
FImportMode := qimInsertAll;
FAddType := qatInsert;
FKeyColumns := TStringList.Create;
FGridCaptionRow := -1;
FGridStartRow := -1;
FConfirmOnCancel := True;
FPicture := TPicture.Create;
FTextViewerRows := 20;
FCSVViewerRows := 20;
FExcelViewerRows := 256;
FExcelMaxColWidth := 130;
end;
destructor TQImport3Wizard.Destroy;
begin
FPicture.Free;
FFieldFormats.Free;
FFormats.Free;
FKeyColumns.Free;
inherited;
end;
procedure TQImport3Wizard.Execute;
begin
{$IFNDEF HTML}
Exclude(FAllowedImports, aiHTML);
{$ENDIF}
{$IFNDEF XLSX}
Exclude(FAllowedImports, aiXlsx);
{$ENDIF}
{$IFNDEF DOCX}
Exclude(FAllowedImports, aiDocx);
{$ENDIF}
{$IFNDEF ODS}
Exclude(FAllowedImports, aiODS);
{$ENDIF}
{$IFNDEF ODT}
Exclude(FAllowedImports, aiODT);
{$ENDIF}
{$IFNDEF XMLDOC}
Exclude(FAllowedImports, aiXMLDoc);
{$ENDIF}
{$IFNDEF ADO}
Exclude(FAllowedImports, aiAccess);
{$ENDIF}
if AllowedImports = [] then
raise EQImportError.Create(QImportLoadStr(QIE_AllowedImportsEmpty));
QImportCheckDestination(False, ImportDestination, DataSet, DBGrid, ListView,
StringGrid);
with TQImport3WizardF.Create(Self) do
try
ShowModal;
finally
Free;
end;
end;
procedure TQImport3Wizard.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -