hi,
Does it have to be in C++?
This one for C++ looks pretty good:
http://www.libxl.com/
http://sourceforge.net/projects/xlw/
I used this lib for java:
http://jexcelapi.sourceforge.net/resources/javadocs/current/docs/
For the CVS part:
http://www.cplusplus.com/reference/string/string/getline/
Some sample code to give you an idea:
- Code: Select all
ifstream file ( "yourdata.csv" );
string value;
while ( !file.eof )
{
getline ( file, value, ',' );
cout << string( value, 1, value.length() );
}
or something like the following
- Code: Select all
std::ifstream data("yourdata.csv");
std::string line;
while(std::getline(data,line))
{
std::stringstream lineStream(line);
std::string cell;
while(std::getline(lineStream,cell,','))
{
// store your CVS data into a container or just work with the excel lib directly to process it
}
}
You should end up with a for loop after putting the CVS data into some storage container, like a vector. Your body should be easy to write, something like this:
sheet->writeNum(position_x,position_y,value);
The whole solution isn't here, but I guess you'll get the idea. If you want todo this in a one button click with C++, you may be better off with a simple command driven program? Otherwise I would recommend netbeans for building a small GUI and doing it in java. As its a bit faster for taking care of the fileselector and binding the commands you'll be needing to several buttons and fields (setting input and output file names etc).
- Colman