Dec 19, 2011 at 11:15pm UTC
Hi,
i can read and store numbers read from excell cells in 2-dimension matrix but
how can i store strings which i can read?
The concept is: user changes the content of the cells and the program changes the output of the calculations.
For example the location of the unit, from "north" to 'south" (or the output power).
And i want that data saved in order to be used afterwards by the following code.
Part of the code is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
int ia=0;
int ib=0;
int ic=0;
double a[40][2];
char chr[40];
BasicExcel xls;
if (xls.Load("DAS_input_output_file_v1.0.xls" ))
{
BasicExcelWorksheet *sheet1=xls.GetWorksheet("ThermalUnitsData" );
double *cellTUD ;
cellTUD = (double *)malloc(80*sizeof (double ));
if (sheet1)
{
for (ib=0 ; ib<2 ; ib++)
{
for (ia=0 ; ia<40 ; ia++)
{
cellTUD[ia] = sheet1->Cell((ia+1),(ib+4))->GetDouble();
a[ia][ib] = cellTUD[ia];
cout << a[ia][ib] << " " ;
}
cout << endl << "next column" ;
}
cout << endl << "****String****" << endl;
const char *cellTUDstr;
for (ia=0 ; ia<40 ; ia++)
{
cellTUDstr = sheet1->Cell((ia+1),3)->GetString();
chr[ia] = cellTUDstr[ia];
//cout << chr[ia] << " ";
cout << cellTUDstr << " " ;
//cellstr++;
}
cout << "Test" << chr[0];
}
else
{
cout << "Error loading sheet." ;
}
xls.Save();
cout << endl << endl << "Data loaded succesfully." << endl <<endl << endl;
}
Last edited on Dec 19, 2011 at 11:24pm UTC
Dec 20, 2011 at 1:30am UTC
BasicExcel xls;
May I know which library you are using that has a BasicExcel class provided?
Dec 21, 2011 at 3:35pm UTC
Thank you very very much!!!
Anything you need tell me!