Skip to content

Commit 39ab3b1

Browse files
committed
Feature: SQL result and table export to CSV files:
New info button behind the CSV radio button informs about the way the export handles values containing the separator character, line breaks, double quotes.
1 parent 91c32bb commit 39ab3b1

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

sql12/core/doc/changes.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ Not yet released, available in our GIT repository, snapshots and future releases
66

77
Enhancements:
88

9+
SQL result and table export to CSV files:
10+
New info button behind the CSV radio button informs about the way the export handles
11+
values containing the separator character, line breaks, double quotes.
12+
913
#433 | Pull request: https://github.com/squirrel-sql-client/squirrel-sql-code/pull/51
1014
To change the statement separator during SQL execution, use the following command on a separate line:
1115
--#SET TERMINATOR <separator>

sql12/core/src/net/sourceforge/squirrel_sql/fw/gui/action/fileexport/DataExportCSVWriter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
public class DataExportCSVWriter extends AbstractDataExportFileWriter
4040
{
4141

42-
private List<String> headerCells = new ArrayList<String>();
43-
private List<String> aRow = new ArrayList<String>();
42+
private List<String> headerCells = new ArrayList<>();
43+
private List<String> aRow = new ArrayList<>();
4444
private BufferedWriter bw;
4545

4646

sql12/core/src/net/sourceforge/squirrel_sql/fw/gui/action/fileexport/ExportDlg.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ private JPanel getExportFormatPanel(boolean enableColoring)
144144
GridBagConstraints gbc;
145145

146146
gbc = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0);
147-
radFormatCSV = new JRadioButton(s_stringMgr.getString("TableExportCsvDlg.formatCSV"));
148-
ret.add(radFormatCSV, gbc);
147+
ret.add(createCSVFormatPanel(), gbc);
149148

150149

151150
gbc = new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0);
@@ -177,6 +176,22 @@ private JPanel getExportFormatPanel(boolean enableColoring)
177176
return ret;
178177
}
179178

179+
private JPanel createCSVFormatPanel()
180+
{
181+
JPanel ret = new JPanel(new GridBagLayout());
182+
183+
GridBagConstraints gbc;
184+
185+
gbc = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
186+
radFormatCSV = new JRadioButton(s_stringMgr.getString("TableExportCsvDlg.formatCSV"));
187+
ret.add(radFormatCSV, gbc);
188+
189+
gbc = new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0);
190+
ret.add(new SmallToolTipInfoButton(s_stringMgr.getString("TableExportCsvDlg.formatCSV.info")).getButton(), gbc);
191+
192+
return ret;
193+
}
194+
180195
private JPanel createExcelPanel(boolean enableColoring)
181196
{
182197
JPanel ret = new JPanel(new GridBagLayout());

sql12/core/src/net/sourceforge/squirrel_sql/fw/gui/action/fileexport/I18NStrings.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ TableExportCsvDlg.formatXLS=Export MS Excel (XLS) file
7272
TableExportCsvDlg.formatXML=Export XML file
7373
TableExportCsvDlg.formatJSON=Export JSON file
7474
75+
TableExportCsvDlg.formatCSV.info=<html>If an export value contains\
76+
<dl>\
77+
<dd>- the separator character,</dd>\
78+
<dd>- line breaks,</dd>\
79+
<dd>- double quotes, (")</dd>\
80+
</dl>\
81+
then the value will be enclosed in double quotes, and any double quotes within the value will be duplicated.</html>
82+
7583
TableExportCsvDlg.useGlobalPrefsFormatingExcel=Use formatting as configured in Global Prefs (recommended for MS Excel)
7684
7785
ResultSetExportCommand.errorExecuteStatement=An error was encountered while attempting to build the data set for export. See logs for details.

0 commit comments

Comments
 (0)