22#include <dialogs/dialog_table_properties.h>
23#include <wx/filedlg.h>
62 else if( parentTable !=
table )
64 parentTable =
nullptr;
102 else if( parentTable !=
table )
104 parentTable =
nullptr;
116 wxFileDialog saveDialog(
m_frame,
_(
"Export Table to CSV" ),
117 wxEmptyString, wxEmptyString,
118 _(
"CSV files (*.csv)|*.csv" ),
119 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
123 if( saveDialog.ShowModal() == wxID_CANCEL )
130 wxString filePath = saveDialog.GetPath();
133 if( !filePath.Lower().EndsWith(
".csv" ) )
137 std::ofstream outFile( filePath.ToStdString() );
139 if( !outFile.is_open() )
141 wxMessageBox( wxString::Format(
_(
"Failed to open file:\n%s" ), filePath ),
142 _(
"Export Error" ), wxOK | wxICON_ERROR,
m_frame );
150 auto escapeCSV = [](
const wxString& field ) -> wxString
152 wxString escaped = field;
155 if( escaped.Contains(
',' ) || escaped.Contains(
'\"' ) || escaped.Contains(
'\n' ) )
157 escaped.Replace(
"\"",
"\"\"" );
158 escaped =
"\"" + escaped +
"\"";
165 for(
int row = 0; row < parentTable->
GetRowCount(); ++row )
167 for(
int col = 0; col < parentTable->
GetColCount(); ++col )
172 wxString cellText = cell->
GetShownText(
nullptr, ¤tSheet,
false, 0 );
175 outFile << escapeCSV( cellText ).ToStdString();
178 if( col < parentTable->GetColCount() - 1 )
204 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.
virtual void SetEnd(const VECTOR2I &aEnd)
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
virtual void SetStart(const VECTOR2I &aStart)
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.
std::vector< std::vector< std::string > > table