Click here to Skip to main content
15,943,103 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey guys,
im trying to fill an array with excel cells using the ExcelFormat Library[^]
    cout << "read " << from << endl;
BasicExcel xls(from);
XLSFormatManager fmt_mgr(xls);
BasicExcelWorksheet* sheet = xls.GetWorksheet(0);
CellFormat fmt_general(fmt_mgr);
const int fil = sheet->GetTotalCols();// n fil
const int col = sheet->GetTotalRows();//m col
for (int y = 0; y < col; ++y) {
    for (int x = 0; x < fil; ++x) {
        BasicExcelCell* cell = sheet->Cell(y, x);
        //cout << *store << "\t";
for (int i = 0; i < col; i++)
    for (int j = 0; j < fil; j++)
        if (sheet->Cell(i, j)->Type() == 2)
             store[i*n + j] = sheet->Cell(i, j)->GetDouble();
        else {
            store[i*n + j] = 0;
        cout <<  i  << "/" << j <<"/" <<store[i*n + j] << "\t";
    cout << "\n";

this code fills the array with the excel data and when i look on console what is storing the result is what i'm expecting. but when I try to reload the array later on my code the data is all messed up showing anything but what it was stored in the first place.

even if I call a simple loop to see in console what is stored the data is all messed up

thanks in advance

What I have tried:

I've tried veryfing after the loop in the code above finish the contents of the array but the data is nothing similar, except for two columns that are as they should be.then it starts storing the same data of the two columns instead of everything else.
Updated 8-Apr-16 12:54pm

1 solution

Obviously, your own code is like a blackbox to you. It don't do what you expect, and you don't understand why.
What follow is not directly a solution to your problem, but a key that will help you to understand by yourself what is wrong.
The debugger is your friend. It will show you what your code is really doing.
Follow the execution, inspect variables and you will see that there is a point where it stop doing what you expect.
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
Debugger - Wikipedia, the free encyclopedia[^]

Where do you define store and what is the value of n
Share this answer
xxSernetxx 11-Apr-16 11:50am    
thank you for your response, i was doing it all wrong. the array was storing only the 2 first columns becuase n=2 and not the size I needed it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900