28#include <dialogs/dialog_table_properties.h>
30#include <wx/filedlg.h>
79 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
82 aCollector.
Remove( aCollector[i] );
111 else if( parentTable !=
table )
113 parentTable =
nullptr;
150 else if( parentTable !=
table )
152 parentTable =
nullptr;
161 wxFileDialog saveDialog(
frame(),
_(
"Export Table to CSV" ),
162 wxEmptyString, wxEmptyString,
163 _(
"CSV files (*.csv)|*.csv" ),
164 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
168 if( saveDialog.ShowModal() == wxID_CANCEL )
175 wxString filePath = saveDialog.GetPath();
178 if( !filePath.Lower().EndsWith(
".csv" ) )
182 std::ofstream outFile( filePath.ToStdString() );
184 if( !outFile.is_open() )
186 wxMessageBox( wxString::Format(
_(
"Failed to open file:\n%s" ), filePath ),
187 _(
"Export Error" ), wxOK | wxICON_ERROR,
frame() );
195 auto escapeCSV = [](
const wxString& field ) -> wxString
197 wxString escaped = field;
200 if( escaped.Contains(
',' ) || escaped.Contains(
'\"' ) || escaped.Contains(
'\n' ) )
202 escaped.Replace(
"\"",
"\"\"" );
203 escaped =
"\"" + escaped +
"\"";
210 for(
int row = 0; row < parentTable->
GetRowCount(); ++row )
212 for(
int col = 0; col < parentTable->
GetColCount(); ++col )
220 outFile << escapeCSV( cellText ).ToStdString();
223 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