If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
luker
Knows some wx things
Posts: 40 Joined: Wed Oct 25, 2006 10:23 am
Post
by luker » Thu Feb 01, 2007 6:13 pm
Hi experts,
here is some code snippet I wrote, found working and almost bytewise copied to another method, where it fails:
Code: Select all
void MyCdpProjectsNParts::OnExport(){
// Finde einen Speicherort
wxString strDirectory;
wxString strFilename;
wxString strFullFilename;
// setzen auf %homedir%/passendesUnterverzeichnis
strDirectory= wxString( "%USERPROFILE%\\Desktop");
// generieren aus zu speichernden Daten
strFilename.sprintf(
"Arbeitszeit je Baugruppe %s-%s"
, m_dtFrom.Format( "%m/%Y").GetData()
, m_dtTo.Format( "%m/%Y").GetData()
);
wxFileDialog* dlgFileExport= new wxFileDialog(
this
, "Tabelle exportieren"
, strDirectory
, strFilename
, "Excel-Datei (csv)|*.txt"
, wxSAVE
);
// wxMessageBox( strDirectory);
if( dlgFileExport->ShowModal() == wxID_OK){
// Lass die Tabelle sich dorthin exportieren
strFullFilename= dlgFileExport->GetDirectory();
strFullFilename.Append( "\\");
strFullFilename.Append( dlgFileExport->GetFilename());
wxFile filExport;
if( !filExport.Open( strFullFilename, wxFile::write)){
wxMessageBox(
"Kann Datei nicht
Xangis
Earned some good credits
Posts: 122 Joined: Fri Apr 14, 2006 9:49 pm
Location: Beaverton, OR
Contact:
Post
by Xangis » Thu Feb 01, 2007 7:40 pm
There's a problem with this statement:
Code: Select all
strFilename.sprintf(
"Arbeitszeit je Baugruppe %s-%s"
, m_dtFrom.Format( "%m/%Y").GetData()
, m_dtTo.Format( "%m/%Y").GetData()
);
When I use
Code: Select all
strFilename.sprintf(
"Arbeitszeit je Baugruppe %s-%s"
, "1"
, "2"
);
The code works great. You'll have to find a different way to format your dates without using the slashes, which cause a lot of havok with directory names.
Here's what I did to make it work:
Code: Select all
strFilename.sprintf(
"Arbeitszeit je Baugruppe %s-%s"
, m_dtFrom.Format( "%m_%Y").GetData()
, m_dtTo.Format( "%m_%Y").GetData()
);
WinVista/7: VC++ .Net 2010 / Ubuntu 11.04: gcc4.4.3 [2.8.12 on all]
luker
Knows some wx things
Posts: 40 Joined: Wed Oct 25, 2006 10:23 am
Post
by luker » Fri Feb 02, 2007 11:19 am
Thank you a lot,
that was exactly the problem.