Page 1 of 1

save grid data

Posted: Fri Jun 08, 2012 1:09 pm
by rafae11
1.png
1.png (14.85 KiB) Viewed 1986 times
I can populate data onto a grid
how do i save grid data to a text file.
help would be greatly appreciated.

Re: save grid data

Posted: Fri Jun 08, 2012 2:17 pm
by Mojo
I suppose the most suitable solution is XML-file.

wxWidgets has three classes for it:
1. wxXmlDocument
2. wxXmlNode
3. wxXmlProperty (wxXmlAttribute)

Re: save grid data

Posted: Fri Jun 08, 2012 4:49 pm
by Auria
In addition to what Mojo said, please tell us if there is any specific format that you need, csv is also regularly used for grids

Re: save grid data

Posted: Fri Jun 08, 2012 9:26 pm
by rafae11
i would input float values on each cell and need to output the bit values of each float consecutively to a text file.

Re: save grid data

Posted: Mon Jun 11, 2012 6:42 pm
by Manolo
i would input float values on each cell
wxGrid::GetCellValue() or use your own wxGridTable and myGridTable::GetValueasDouble()
and need to output the bit values of each float consecutively to a text file.
Are you thinking of writting the bytes used for internal representation of the float?
If so:
wxFile::Write(buffer, count)

Re: save grid data

Posted: Mon Jun 11, 2012 9:56 pm
by rafae11
Hi guys,

im a newbie would be able to give a simple example on how to use the syntax for wxgridtable thanks. :D

Re: save grid data

Posted: Tue Jun 12, 2012 11:43 pm
by Auria
Well when using wxWidgets you're supposed to know how to call methods, so I'm not sure what you are having problems with

something like (this saves only a few cells, you will need to write that as a loop, and also decide which file format you want)

Code: Select all

wxTextFile file( wxT("/path/to/my_file.txt") );
file.Open();
 
file.AddLine( grid->GetCellValue(0,0) + wxT(", ") + grid->GetCellValue(0,1) + wxT(", ") + grid->GetCellValue(0,2) );
file.AddLine( grid->GetCellValue(1,0) + wxT(", ") + grid->GetCellValue(1,1) + wxT(", ") + grid->GetCellValue(1,2) );
file.AddLine( grid->GetCellValue(2,0) + wxT(", ") + grid->GetCellValue(2,1) + wxT(", ") + grid->GetCellValue(2,2) );
 
file.Write();
file.Close();