28#include <dialogs/dialog_table_properties.h>
30#include <wx/filedlg.h>
78 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
81 aCollector.
Remove( aCollector[i] );
110 else if( parentTable !=
table )
112 parentTable =
nullptr;
149 else if( parentTable !=
table )
151 parentTable =
nullptr;
160 wxFileDialog saveDialog(
frame(),
_(
"Export Table to CSV" ),
161 wxEmptyString, wxEmptyString,
162 _(
"CSV files (*.csv)|*.csv" ),
163 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
165 if( saveDialog.ShowModal() == wxID_CANCEL )
172 wxString filePath = saveDialog.GetPath();
175 if( !filePath.Lower().EndsWith(
".csv" ) )
179 std::ofstream outFile( filePath.ToStdString() );
181 if( !outFile.is_open() )
183 wxMessageBox( wxString::Format(
_(
"Failed to open file:\n%s" ), filePath ),
184 _(
"Export Error" ), wxOK | wxICON_ERROR,
frame() );
192 auto escapeCSV = [](
const wxString& field ) -> wxString
194 wxString escaped = field;
197 if( escaped.Contains(
',' ) || escaped.Contains(
'\"' ) || escaped.Contains(
'\n' ) )
199 escaped.Replace(
"\"",
"\"\"" );
200 escaped =
"\"" + escaped +
"\"";
207 for(
int row = 0; row < parentTable->
GetRowCount(); ++row )
209 for(
int col = 0; col < parentTable->
GetColCount(); ++col )
217 outFile << escapeCSV( cellText ).ToStdString();
220 if( col < parentTable->GetColCount() - 1 )
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
int GetCount() const
Return the number of objects in the list.
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
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)
Used when the right click button is pressed, or when the select tool is in effect.
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
PCB_TABLECELL * GetCell(int aRow, int aCol) const
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
VECTOR2< int32_t > VECTOR2I