26#include <dialogs/dialog_table_properties.h>
27#include <wx/filedlg.h>
65 else if( parentTable !=
table )
67 parentTable =
nullptr;
105 else if( parentTable !=
table )
107 parentTable =
nullptr;
119 wxFileDialog saveDialog(
m_frame,
_(
"Export Table to CSV" ),
120 wxEmptyString, wxEmptyString,
121 _(
"CSV files (*.csv)|*.csv" ),
122 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
124 if( saveDialog.ShowModal() == wxID_CANCEL )
131 wxString filePath = saveDialog.GetPath();
134 if( !filePath.Lower().EndsWith(
".csv" ) )
138 std::ofstream outFile( filePath.ToStdString() );
140 if( !outFile.is_open() )
142 wxMessageBox( wxString::Format(
_(
"Failed to open file:\n%s" ), filePath ),
143 _(
"Export Error" ), wxOK | wxICON_ERROR,
m_frame );
151 auto escapeCSV = [](
const wxString& field ) -> wxString
153 wxString escaped = field;
156 if( escaped.Contains(
',' ) || escaped.Contains(
'\"' ) || escaped.Contains(
'\n' ) )
158 escaped.Replace(
"\"",
"\"\"" );
159 escaped =
"\"" + escaped +
"\"";
166 for(
int row = 0; row < parentTable->
GetRowCount(); ++row )
168 for(
int col = 0; col < parentTable->
GetColCount(); ++col )
173 wxString cellText = cell->
GetShownText(
nullptr, ¤tSheet,
false, 0 );
176 outFile << escapeCSV( cellText ).ToStdString();
179 if( col < parentTable->GetColCount() - 1 )
205 cell->
SetText( wxEmptyString );
static TOOL_ACTION addRowAbove
static TOOL_ACTION addColBefore
static TOOL_ACTION deleteRows
static TOOL_ACTION addRowBelow
static TOOL_ACTION deleteColumns
static TOOL_ACTION unmergeCells
static TOOL_ACTION mergeCells
static TOOL_ACTION addColAfter
static TOOL_ACTION editTable
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION exportTableCSV
A base class for most all the KiCad significant classes used in schematics and boards.
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
void SetStart(const VECTOR2I &aStart)
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
void SetEnd(const VECTOR2I &aEnd)
virtual void SetText(const wxString &aText)
static const std::vector< KICAD_T > EditableItems
Schematic editor (Eeschema) main window.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
wxString GetShownText(const RENDER_SETTINGS *aSettings, const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const override
SCH_TABLECELL * GetCell(int aRow, int aCol) const
std::deque< EDA_ITEM * > & Items()
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.