Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to read/write next row or column? #23

Closed
feugen opened this issue Feb 11, 2014 · 3 comments
Closed

How to read/write next row or column? #23

feugen opened this issue Feb 11, 2014 · 3 comments

Comments

@feugen
Copy link

feugen commented Feb 11, 2014

Hello,

how can I read the next row or column, it there a function for this? Probably you can give me an example? The problem is... I have to search for a patern where I dont know the position of the cell, so I have to search for the cell. As you understand, I cant do it manualy for a sheet with 100 rows and 100 columns. So I cant use xlsx.read("A1"); xlsx.read("A2"); 10000 times etc :-). Is there a way do do it? I tried to increase the position from A->B->C.....AA->AB etc and the same for columns 1->2 ->3 etc and put all together - but I failed do do it for characters so I cant put it together. I am able to work around this, but its still would be great to have something like nextrow and nextcolumn. thanks.

@luckyhacky
Copy link

You are using read("A1"), which is quite ok. But there is also an overloaded function ->

QVariant read(int row, int col);

you can do it his way:

for(int i=0; i < MAX_ROW; i++)
{
  for(int j=0; j < MAX_COL; j++)
  {
    if(xlsx.read(i, j).toString == "test") 
     // got it
  }
}

@dbzhang800
Copy link
Owner

Hi, as luckyhacky said, you can use

QVariant read(int row, int col);

Just note that, the index row and col starts from 1 instead of 0, so

read("A1") <==> read(1,1)
read("A2") <==> read(2,1)
read("B1") <==> read(1,2)

@feugen
Copy link
Author

feugen commented Feb 12, 2014

Hello,

thanks a lot guys thats exactly what I need. Case closed :-)

@feugen feugen closed this as completed Feb 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants