save grid data Topic is solved

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.
Post Reply
rafae11
Experienced Solver
Experienced Solver
Posts: 85
Joined: Sat Jun 02, 2012 8:41 am

save grid data

Post by rafae11 »

1.png
1.png (14.85 KiB) Viewed 2993 times
I can populate data onto a grid
how do i save grid data to a text file.
help would be greatly appreciated.
Mojo
Super wx Problem Solver
Super wx Problem Solver
Posts: 401
Joined: Wed Sep 21, 2005 8:17 am
Location: Rostov-on-Don, Southern Russia

Re: save grid data

Post by Mojo »

I suppose the most suitable solution is XML-file.

wxWidgets has three classes for it:
1. wxXmlDocument
2. wxXmlNode
3. wxXmlProperty (wxXmlAttribute)
Win XP HE SP3, Vista
Xubuntu 12.04 LTS
wxWidgets-2.9.5
wxWidgets-3.0.0
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Re: save grid data

Post 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
"Keyboard not detected. Press F1 to continue"
-- Windows
rafae11
Experienced Solver
Experienced Solver
Posts: 85
Joined: Sat Jun 02, 2012 8:41 am

Re: save grid data

Post 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.
Manolo
Can't get richer than this
Can't get richer than this
Posts: 827
Joined: Mon Apr 30, 2012 11:07 pm

Re: save grid data

Post 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)
rafae11
Experienced Solver
Experienced Solver
Posts: 85
Joined: Sat Jun 02, 2012 8:41 am

Re: save grid data

Post 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
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Re: save grid data

Post 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();
"Keyboard not detected. Press F1 to continue"
-- Windows
Post Reply