mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 20:50:20 +08:00
Provide edit box for custom NULL value, in grid export dialog. See http://www.heidisql.com/forum.php?t=13075
This commit is contained in:
@ -3,7 +3,7 @@ object frmExportGrid: TfrmExportGrid
|
||||
Top = 0
|
||||
BorderStyle = bsDialog
|
||||
Caption = 'Export grid rows'
|
||||
ClientHeight = 403
|
||||
ClientHeight = 432
|
||||
ClientWidth = 383
|
||||
Color = clBtnFace
|
||||
Font.Charset = DEFAULT_CHARSET
|
||||
@ -19,12 +19,12 @@ object frmExportGrid: TfrmExportGrid
|
||||
OnShow = FormShow
|
||||
DesignSize = (
|
||||
383
|
||||
403)
|
||||
432)
|
||||
PixelsPerInch = 96
|
||||
TextHeight = 13
|
||||
object btnOK: TButton
|
||||
Left = 219
|
||||
Top = 370
|
||||
Top = 399
|
||||
Width = 75
|
||||
Height = 25
|
||||
Anchors = [akRight, akBottom]
|
||||
@ -36,7 +36,7 @@ object frmExportGrid: TfrmExportGrid
|
||||
end
|
||||
object btnCancel: TButton
|
||||
Left = 300
|
||||
Top = 370
|
||||
Top = 399
|
||||
Width = 75
|
||||
Height = 25
|
||||
Anchors = [akRight, akBottom]
|
||||
@ -49,7 +49,7 @@ object frmExportGrid: TfrmExportGrid
|
||||
Left = 8
|
||||
Top = 112
|
||||
Width = 137
|
||||
Height = 252
|
||||
Height = 281
|
||||
Anchors = [akLeft, akTop, akBottom]
|
||||
Caption = 'Output format'
|
||||
ItemIndex = 0
|
||||
@ -151,13 +151,13 @@ object frmExportGrid: TfrmExportGrid
|
||||
Left = 151
|
||||
Top = 184
|
||||
Width = 224
|
||||
Height = 180
|
||||
Height = 209
|
||||
Anchors = [akLeft, akTop, akRight, akBottom]
|
||||
Caption = 'Options'
|
||||
TabOrder = 5
|
||||
DesignSize = (
|
||||
224
|
||||
180)
|
||||
209)
|
||||
object lblSeparator: TLabel
|
||||
Left = 6
|
||||
Top = 97
|
||||
@ -179,8 +179,15 @@ object frmExportGrid: TfrmExportGrid
|
||||
Height = 13
|
||||
Caption = 'Line terminator:'
|
||||
end
|
||||
object lblNull: TLabel
|
||||
Left = 6
|
||||
Top = 175
|
||||
Width = 57
|
||||
Height = 13
|
||||
Caption = 'NULL value:'
|
||||
end
|
||||
object chkIncludeColumnNames: TCheckBox
|
||||
Left = 8
|
||||
Left = 6
|
||||
Top = 18
|
||||
Width = 201
|
||||
Height = 17
|
||||
@ -200,7 +207,7 @@ object frmExportGrid: TfrmExportGrid
|
||||
RightButton.DisabledImageIndex = 107
|
||||
RightButton.ImageIndex = 108
|
||||
RightButton.Visible = True
|
||||
TabOrder = 1
|
||||
TabOrder = 3
|
||||
Text = ';'
|
||||
OnChange = editCSVChange
|
||||
OnRightButtonClick = editCSVRightButtonClick
|
||||
@ -215,7 +222,7 @@ object frmExportGrid: TfrmExportGrid
|
||||
RightButton.DisabledImageIndex = 107
|
||||
RightButton.ImageIndex = 108
|
||||
RightButton.Visible = True
|
||||
TabOrder = 2
|
||||
TabOrder = 4
|
||||
OnChange = editCSVChange
|
||||
OnRightButtonClick = editCSVRightButtonClick
|
||||
end
|
||||
@ -229,34 +236,48 @@ object frmExportGrid: TfrmExportGrid
|
||||
RightButton.DisabledImageIndex = 107
|
||||
RightButton.ImageIndex = 108
|
||||
RightButton.Visible = True
|
||||
TabOrder = 3
|
||||
TabOrder = 5
|
||||
Text = '\r\n'
|
||||
OnChange = editCSVChange
|
||||
OnRightButtonClick = editCSVRightButtonClick
|
||||
end
|
||||
object chkIncludeAutoIncrement: TCheckBox
|
||||
Left = 8
|
||||
Left = 6
|
||||
Top = 41
|
||||
Width = 201
|
||||
Height = 17
|
||||
Anchors = [akLeft, akTop, akRight]
|
||||
Caption = 'Include auto increment column'
|
||||
TabOrder = 4
|
||||
TabOrder = 1
|
||||
OnClick = CalcSize
|
||||
end
|
||||
object chkIncludeQuery: TCheckBox
|
||||
Left = 8
|
||||
Left = 6
|
||||
Top = 64
|
||||
Width = 177
|
||||
Height = 17
|
||||
Caption = 'Include SQL query'
|
||||
TabOrder = 5
|
||||
TabOrder = 2
|
||||
end
|
||||
object editNull: TButtonedEdit
|
||||
Left = 106
|
||||
Top = 172
|
||||
Width = 103
|
||||
Height = 21
|
||||
Anchors = [akLeft, akTop, akRight]
|
||||
Images = MainForm.ImageListMain
|
||||
RightButton.DisabledImageIndex = 107
|
||||
RightButton.ImageIndex = 108
|
||||
RightButton.Visible = True
|
||||
TabOrder = 6
|
||||
OnChange = editCSVChange
|
||||
OnRightButtonClick = editCSVRightButtonClick
|
||||
end
|
||||
end
|
||||
object popupCSVchar: TPopupMenu
|
||||
AutoHotkeys = maManual
|
||||
Left = 8
|
||||
Top = 366
|
||||
Left = 24
|
||||
Top = 390
|
||||
object menuCSVtab: TMenuItem
|
||||
Caption = 'Tab'
|
||||
Hint = '\t'
|
||||
@ -265,10 +286,12 @@ object frmExportGrid: TfrmExportGrid
|
||||
object menuCSVcomma: TMenuItem
|
||||
Caption = 'Comma'
|
||||
Hint = ','
|
||||
OnClick = menuCSVClick
|
||||
end
|
||||
object menuCSVsemicolon: TMenuItem
|
||||
Caption = 'Semicolon'
|
||||
Hint = ';'
|
||||
OnClick = menuCSVClick
|
||||
end
|
||||
object N1: TMenuItem
|
||||
Caption = '-'
|
||||
@ -276,10 +299,12 @@ object frmExportGrid: TfrmExportGrid
|
||||
object menuCSVsinglequote: TMenuItem
|
||||
Caption = 'Single quote'
|
||||
Hint = #39
|
||||
OnClick = menuCSVClick
|
||||
end
|
||||
object menuCSVdoublequote: TMenuItem
|
||||
Caption = 'Double quote'
|
||||
Hint = '"'
|
||||
OnClick = menuCSVClick
|
||||
end
|
||||
object N2: TMenuItem
|
||||
Caption = '-'
|
||||
@ -292,10 +317,12 @@ object frmExportGrid: TfrmExportGrid
|
||||
object menuCSVunixlinebreak: TMenuItem
|
||||
Caption = 'UNIX linebreak'
|
||||
Hint = '\n'
|
||||
OnClick = menuCSVClick
|
||||
end
|
||||
object menuCSVmaclinebreak: TMenuItem
|
||||
Caption = 'Mac OS linebreak'
|
||||
Hint = '\r'
|
||||
OnClick = menuCSVClick
|
||||
end
|
||||
object N3: TMenuItem
|
||||
Caption = '-'
|
||||
@ -303,20 +330,23 @@ object frmExportGrid: TfrmExportGrid
|
||||
object menuCSVnul: TMenuItem
|
||||
Caption = 'NUL character'
|
||||
Hint = '\0'
|
||||
OnClick = menuCSVClick
|
||||
end
|
||||
object menuCSVbackspace: TMenuItem
|
||||
Caption = 'Backspace'
|
||||
Hint = '\b'
|
||||
OnClick = menuCSVClick
|
||||
end
|
||||
object menuCSVcontrolz: TMenuItem
|
||||
Caption = 'Control+Z'
|
||||
Hint = '\Z'
|
||||
OnClick = menuCSVClick
|
||||
end
|
||||
end
|
||||
object popupRecentFiles: TPopupMenu
|
||||
AutoHotkeys = maManual
|
||||
OnPopup = popupRecentFilesPopup
|
||||
Left = 40
|
||||
Top = 366
|
||||
Left = 112
|
||||
Top = 390
|
||||
end
|
||||
end
|
||||
|
@ -46,6 +46,8 @@ type
|
||||
N3: TMenuItem;
|
||||
chkIncludeAutoIncrement: TCheckBox;
|
||||
chkIncludeQuery: TCheckBox;
|
||||
lblNull: TLabel;
|
||||
editNull: TButtonedEdit;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure CalcSize(Sender: TObject);
|
||||
@ -63,7 +65,7 @@ type
|
||||
private
|
||||
{ Private declarations }
|
||||
FCSVEditor: TButtonedEdit;
|
||||
FCSVSeparator, FCSVEncloser, FCSVTerminator: String;
|
||||
FCSVSeparator, FCSVEncloser, FCSVTerminator, FCSVNull: String;
|
||||
FGrid: TVirtualStringTree;
|
||||
FRecentFiles: TStringList;
|
||||
const FFormatToFileExtension: Array[TGridExportFormat] of String =
|
||||
@ -114,6 +116,7 @@ begin
|
||||
FCSVSeparator := AppSettings.ReadString(asGridExportSeparator);
|
||||
FCSVEncloser := AppSettings.ReadString(asGridExportEncloser);
|
||||
FCSVTerminator := AppSettings.ReadString(asGridExportTerminator);
|
||||
FCSVNull := AppSettings.ReadString(asGridExportNull);
|
||||
ValidateControls(Sender);
|
||||
end;
|
||||
|
||||
@ -135,6 +138,7 @@ begin
|
||||
AppSettings.WriteString(asGridExportSeparator, FCSVSeparator);
|
||||
AppSettings.WriteString(asGridExportEncloser, FCSVEncloser);
|
||||
AppSettings.WriteString(asGridExportTerminator, FCSVTerminator);
|
||||
AppSettings.WriteString(asGridExportNull, FCSVNull);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -171,16 +175,19 @@ begin
|
||||
editSeparator.Text := ',';
|
||||
editEncloser.Text := '"';
|
||||
editTerminator.Text := '\r\n';
|
||||
editNull.Text := FCSVNull;
|
||||
end;
|
||||
efCSV: begin
|
||||
editSeparator.Text := FCSVSeparator;
|
||||
editEncloser.Text := FCSVEncloser;
|
||||
editTerminator.Text := FCSVTerminator;
|
||||
editNull.Text := FCSVNull;
|
||||
end;
|
||||
else begin
|
||||
editSeparator.Text := '';
|
||||
editEncloser.Text := '';
|
||||
editTerminator.Text := '';
|
||||
editNull.Text := '';
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -195,6 +202,9 @@ begin
|
||||
lblTerminator.Enabled := Enable;
|
||||
editTerminator.Enabled := Enable;
|
||||
editTerminator.RightButton.Enabled := Enable;
|
||||
lblNull.Enabled := ExportFormat in [efExcel, efCSV];
|
||||
editNull.Enabled := lblNull.Enabled;
|
||||
editNull.RightButton.Enabled := lblNull.Enabled;
|
||||
btnOK.Enabled := radioOutputCopyToClipboard.Checked or (radioOutputFile.Checked and (editFilename.Text <> ''));
|
||||
if radioOutputFile.Checked then
|
||||
editFilename.Font.Color := clWindowText
|
||||
@ -387,7 +397,9 @@ begin
|
||||
else if Edit = editEncloser then
|
||||
FCSVEncloser := Edit.Text
|
||||
else if Edit = editTerminator then
|
||||
FCSVTerminator := Edit.Text;
|
||||
FCSVTerminator := Edit.Text
|
||||
else if Edit = editNull then
|
||||
FCSVNull := Edit.Text;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -415,7 +427,6 @@ begin
|
||||
FCSVEditor := Sender as TButtonedEdit;
|
||||
p := FCSVEditor.ClientToScreen(FCSVEditor.ClientRect.BottomRight);
|
||||
for Item in popupCSVchar.Items do begin
|
||||
Item.OnClick := menuCSVClick;
|
||||
Item.Checked := FCSVEditor.Text = Item.Hint;
|
||||
end;
|
||||
popupCSVchar.Popup(p.X-16, p.Y);
|
||||
@ -688,8 +699,8 @@ begin
|
||||
efExcel, efCSV, efLaTeX, efWiki: begin
|
||||
// Escape encloser characters inside data per de-facto CSV.
|
||||
Data := StringReplace(Data, Encloser, Encloser+Encloser, [rfReplaceAll]);
|
||||
if GridData.IsNull(Col) and (ExportFormat = efCSV) then
|
||||
Data := '\N'
|
||||
if GridData.IsNull(Col) and (ExportFormat in [efExcel, efCSV]) then
|
||||
Data := FCSVNull
|
||||
else
|
||||
Data := Encloser + Data + Encloser;
|
||||
tmp := tmp + Data + Separator;
|
||||
|
@ -153,7 +153,7 @@ type
|
||||
asExportSQLDatabase, asExportSQLServerDatabase, asExportSQLOutput, asGridExportOutputCopy, asGridExportOutputFile,
|
||||
asGridExportFilename, asGridExportRecentFiles, asGridExportEncoding, asGridExportFormat, asGridExportSelection,
|
||||
asGridExportColumnNames, asGridExportIncludeAutoInc, asGridExportIncludeQuery,
|
||||
asGridExportSeparator, asGridExportEncloser, asGridExportTerminator, asCSVImportSeparator,
|
||||
asGridExportSeparator, asGridExportEncloser, asGridExportTerminator, asGridExportNull, asCSVImportSeparator,
|
||||
asCSVImportEncloser, asCSVImportTerminator, asCSVImportFieldEscaper, asCSVImportWindowWidth, asCSVImportWindowHeight,
|
||||
asCSVImportFilename, asCSVImportFieldsEnclosedOptionally, asCSVImportIgnoreLines, asCSVImportLowPriority, asCSVImportLocalNumbers,
|
||||
asCSVImportDuplicateHandling, asCSVImportParseMethod, asUpdatecheck, asUpdatecheckBuilds,
|
||||
@ -3230,6 +3230,7 @@ begin
|
||||
InitSetting(asGridExportSeparator, 'GridExportSeparator', 0, False, ';');
|
||||
InitSetting(asGridExportEncloser, 'GridExportEncloser', 0, False, '');
|
||||
InitSetting(asGridExportTerminator, 'GridExportTerminator', 0, False, '\r\n');
|
||||
InitSetting(asGridExportNull, 'GridExportNull', 0, False, '\N');
|
||||
InitSetting(asCSVImportSeparator, 'CSVSeparatorV2', 0, False, ';');
|
||||
InitSetting(asCSVImportEncloser, 'CSVEncloserV2', 0, False, '"');
|
||||
InitSetting(asCSVImportTerminator, 'CSVTerminator', 0, False, '\r\n');
|
||||
|
Reference in New Issue
Block a user