Read excel data into 2d Array

Hi all,

I am trying to read data from excel file into my c++ code. I have 2d array and excel file has something like {1,2,3};{1,3,5};{2,3,4};etc. in each row. I have one column and 50 rows. I tried the following code but don't know how to identify the cells:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int main()
{
    ifstream file("C:/Users/text.xlsx");
    
    int p[i][j];
    
       for(int i = 0; i < m; ++i)
           for(int j = 0; j < n; ++j)
          {
       {
        file >> p[i][j];
        
        cout << p[i][j] << ' ';
        }
    }


What can I do to get it worked? Thanks
I though xlsx was a zipped up set of XML files, so I'm not sure how ifstream alone will be a lot of use?

(You will need a zip library and an XML parser, if you want to go it alone, rather than using a library to help you, like LibXL
http://www.libxl.com/ )

Andy

Office Open XML
http://en.wikipedia.org/wiki/Office_Open_XML

Office Open XML (also informally known as OOXML or OpenXML) is a zipped, XML-based file format developed by Microsoft for representing spreadsheets, charts, presentations and word processing documents.

Last edited on
I created these rows in excel but I can copy it to txt file. Can c++ read this kind of data? Fore example, my first vector is the set of elements {1,2,3}. Can it understand this? Doesn't my code work for this purpose?
Topic archived. No new replies allowed.