You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by "Kalkunda, Venkat" <Ka...@principal.com> on 2005/08/01 20:14:27 UTC

Row/Column number!!!

Hi,

My name is Venkat. I am working on a project which is using the=20
http://jakarta.apache.org/poi/apidocs  API? I would appreciate any help tha=
t I can get.


Can somebody tell me, if there is a method or a way to find out the number =
of rows and the number of columns that have been populated with values(like=
 text, integer or formula, etc.) in the Excel workbook?
Thank You

Thank You
Kalkunda Venkat
GFRIS - Principal Financial Group



-----Message Disclaimer-----

This e-mail message is intended only for the use of the individual or
entity to which it is addressed, and may contain information that is
privileged, confidential and exempt from disclosure under applicable law.
If you are not the intended recipient, any dissemination, distribution or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify us immediately by
reply email to Connect@principal.com and delete or destroy all copies of
the original message and attachments thereto. Email sent to or from the
Principal Financial Group or any of its member companies may be retained
as required by law or regulation.

Nothing in this message is intended to constitute an Electronic signature
for purposes of the Uniform Electronic Transactions Act (UETA) or the
Electronic Signatures in Global and National Commerce Act ("E-Sign")
unless a specific statement to the contrary is included in this message.

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


RE: Row/Column number!!!

Posted by xio <da...@hotmail.com>.
hi

maybe it s what u want:


	/**
	 * 
	 * @param sheet
	 * @return
	 */
	public static int endOfRow(HSSFSheet sheet) {

		int lastRowNum = sheet.getLastRowNum();

		if (lastRowNum> 0) {
			return (lastRowNum + 1);
		}
		else {
			return sheet.getPhysicalNumberOfRows()> 0 ? 1 : 0;
		}

	}

	/**
	 * 
	 * @param sheet
	 * @return
	 */
	public static int endOfColumn(HSSFSheet sheet) {
		int rowCount = endOfRow(sheet);
		int maxCellNum = 0;
		for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) {
			HSSFRow row = sheet.getRow(rowIndex);
			if (row != null) {
				maxCellNum = Math.max(maxCellNum, row.getLastCellNum());
			}

		}

		return maxCellNum;
	}


> Date: Tue, 14 Oct 2008 09:37:48 +0200
> From: pierre.lavignotte@gmail.com
> To: user@poi.apache.org
> Subject: Re: Row/Column number!!!
>
> I use the following code :
>
> int lastRowNum = sheet.getLastRowNum();
> // Browse rows
> for (int rowIndex=0; rowIndex<=lastRowNum; rowIndex++) {
>
> HSSFRow row = sheet.getRow(rowIndex);
>
> int lastCellNum = row.getLastCellNum();
>
> // Browse cells
> for (int cellIndex=0; cellIndex<=lastCellNum; cellIndex++) {
>
> HSSFCell cell = row.getCell(cellIndex);
> }
> }
>
>
> On Tue, Oct 14, 2008 at 9:09 AM, Hardie82 wrote:
>
>>
>> Hi. Iam also interessted for a simple way to get the number of the columns
>> without iterating rows. Is there a solution for this? I searched the
>> sheet-class in the api but didn't found a method for it.
>>
>> Hardie
>>
>>
>> Kalkunda, Venkat wrote:
>>>
>>> Hi,
>>>
>>> My name is Venkat. I am working on a project which is using the=20
>>> http://jakarta.apache.org/poi/apidocs API? I would appreciate any help
>>> tha=
>>> t I can get.
>>>
>>>
>>> Can somebody tell me, if there is a method or a way to find out the
>> number
>>> =
>>> of rows and the number of columns that have been populated with
>>> values(like=
>>> text, integer or formula, etc.) in the Excel workbook?
>>> Thank You
>>>
>>> Thank You
>>> Kalkunda Venkat
>>> GFRIS - Principal Financial Group
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Row-Column-number%21%21%21-tp530660p19968118.html
>> Sent from the POI - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>> For additional commands, e-mail: user-help@poi.apache.org
>>
>>
>
>
> --
> Cordialement,
> Pierre Lavignotte
> Ingénieur Conception & Développement
> http://pierre.lavignotte.googlepages.com

_________________________________________________________________
Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Row/Column number!!!

Posted by Pierre Lavignotte <pi...@gmail.com>.
Ok I understand.

I don't think there is a direct way to iterate over the cells of a column
because of the object model of POI (inherited from MS Excel ?)
There is no column concept in POI so you'll have to iterate over rows and
pick the cell of the column you want.

The problem I think is that you can have rows with different number of
cells.

Pierre

On Tue, Oct 14, 2008 at 9:48 AM, Hardie82 <th...@yahoo.de>wrote:

>
> Thanks, but with your code you iterate over each cell in a row and than
> goto
> next row an so on. But i want to iterate over a column meaining get each
> cell of a column and than goto next column and so on. I gooled for the
> problem and find only solutions like yours. So it seem there is no other
> way
> as doing so :(. If anyone else has the solution for the problem please post
> it to us.
>
> Hardie
>
>
>
> Pierre Lavignotte wrote:
> >
> > I use the following code :
> >
> > int lastRowNum = sheet.getLastRowNum();
> > // Browse rows
> > for (int rowIndex=0; rowIndex<=lastRowNum; rowIndex++) {
> >
> > HSSFRow row = sheet.getRow(rowIndex);
> >
> > int lastCellNum = row.getLastCellNum();
> >
> > // Browse cells
> > for (int cellIndex=0; cellIndex<=lastCellNum; cellIndex++) {
> >
> > HSSFCell cell = row.getCell(cellIndex);
> > }
> > }
> >
> >
> > On Tue, Oct 14, 2008 at 9:09 AM, Hardie82
> > <th...@yahoo.de>wrote:
> >
> >>
> >> Hi. Iam also interessted for a simple way to get the number of the
> >> columns
> >> without iterating rows. Is there a solution for this? I searched the
> >> sheet-class in the api but didn't found a method for it.
> >>
> >> Hardie
> >>
> >>
> >> Kalkunda, Venkat wrote:
> >> >
> >> > Hi,
> >> >
> >> > My name is Venkat. I am working on a project which is using the=20
> >> > http://jakarta.apache.org/poi/apidocs  API? I would appreciate any
> help
> >> > tha=
> >> > t I can get.
> >> >
> >> >
> >> > Can somebody tell me, if there is a method or a way to find out the
> >> number
> >> > =
> >> > of rows and the number of columns that have been populated with
> >> > values(like=
> >> >  text, integer or formula, etc.) in the Excel workbook?
> >> > Thank You
> >> >
> >> > Thank You
> >> > Kalkunda Venkat
> >> > GFRIS - Principal Financial Group
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Row-Column-number%21%21%21-tp530660p19968118.html
> >> Sent from the POI - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> >> For additional commands, e-mail: user-help@poi.apache.org
> >>
> >>
> >
> >
> > --
> > Cordialement,
> > Pierre Lavignotte
> > Ingénieur Conception & Développement
> > http://pierre.lavignotte.googlepages.com
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Row-Column-number%21%21%21-tp530660p19968610.html
> Sent from the POI - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>


-- 
Cordialement,
Pierre Lavignotte
Ingénieur Conception & Développement
http://pierre.lavignotte.googlepages.com

Re: Row/Column number!!!

Posted by Hardie82 <th...@yahoo.de>.
Thanks, but with your code you iterate over each cell in a row and than goto
next row an so on. But i want to iterate over a column meaining get each
cell of a column and than goto next column and so on. I gooled for the
problem and find only solutions like yours. So it seem there is no other way
as doing so :(. If anyone else has the solution for the problem please post
it to us.

Hardie



Pierre Lavignotte wrote:
> 
> I use the following code :
> 
> int lastRowNum = sheet.getLastRowNum();
> // Browse rows
> for (int rowIndex=0; rowIndex<=lastRowNum; rowIndex++) {
> 
> HSSFRow row = sheet.getRow(rowIndex);
> 
> int lastCellNum = row.getLastCellNum();
> 
> // Browse cells
> for (int cellIndex=0; cellIndex<=lastCellNum; cellIndex++) {
> 
> HSSFCell cell = row.getCell(cellIndex);
> }
> }
> 
> 
> On Tue, Oct 14, 2008 at 9:09 AM, Hardie82
> <th...@yahoo.de>wrote:
> 
>>
>> Hi. Iam also interessted for a simple way to get the number of the
>> columns
>> without iterating rows. Is there a solution for this? I searched the
>> sheet-class in the api but didn't found a method for it.
>>
>> Hardie
>>
>>
>> Kalkunda, Venkat wrote:
>> >
>> > Hi,
>> >
>> > My name is Venkat. I am working on a project which is using the=20
>> > http://jakarta.apache.org/poi/apidocs  API? I would appreciate any help
>> > tha=
>> > t I can get.
>> >
>> >
>> > Can somebody tell me, if there is a method or a way to find out the
>> number
>> > =
>> > of rows and the number of columns that have been populated with
>> > values(like=
>> >  text, integer or formula, etc.) in the Excel workbook?
>> > Thank You
>> >
>> > Thank You
>> > Kalkunda Venkat
>> > GFRIS - Principal Financial Group
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Row-Column-number%21%21%21-tp530660p19968118.html
>> Sent from the POI - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>> For additional commands, e-mail: user-help@poi.apache.org
>>
>>
> 
> 
> -- 
> Cordialement,
> Pierre Lavignotte
> Ingénieur Conception & Développement
> http://pierre.lavignotte.googlepages.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Row-Column-number%21%21%21-tp530660p19968610.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Row/Column number!!!

Posted by Pierre Lavignotte <pi...@gmail.com>.
I use the following code :

int lastRowNum = sheet.getLastRowNum();
// Browse rows
for (int rowIndex=0; rowIndex<=lastRowNum; rowIndex++) {

HSSFRow row = sheet.getRow(rowIndex);

int lastCellNum = row.getLastCellNum();

// Browse cells
for (int cellIndex=0; cellIndex<=lastCellNum; cellIndex++) {

HSSFCell cell = row.getCell(cellIndex);
}
}


On Tue, Oct 14, 2008 at 9:09 AM, Hardie82 <th...@yahoo.de>wrote:

>
> Hi. Iam also interessted for a simple way to get the number of the columns
> without iterating rows. Is there a solution for this? I searched the
> sheet-class in the api but didn't found a method for it.
>
> Hardie
>
>
> Kalkunda, Venkat wrote:
> >
> > Hi,
> >
> > My name is Venkat. I am working on a project which is using the=20
> > http://jakarta.apache.org/poi/apidocs  API? I would appreciate any help
> > tha=
> > t I can get.
> >
> >
> > Can somebody tell me, if there is a method or a way to find out the
> number
> > =
> > of rows and the number of columns that have been populated with
> > values(like=
> >  text, integer or formula, etc.) in the Excel workbook?
> > Thank You
> >
> > Thank You
> > Kalkunda Venkat
> > GFRIS - Principal Financial Group
> >
>
> --
> View this message in context:
> http://www.nabble.com/Row-Column-number%21%21%21-tp530660p19968118.html
> Sent from the POI - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>


-- 
Cordialement,
Pierre Lavignotte
Ingénieur Conception & Développement
http://pierre.lavignotte.googlepages.com

Re: Row/Column number!!!

Posted by Hardie82 <th...@yahoo.de>.
Hi. Iam also interessted for a simple way to get the number of the columns
without iterating rows. Is there a solution for this? I searched the
sheet-class in the api but didn't found a method for it.

Hardie


Kalkunda, Venkat wrote:
> 
> Hi,
> 
> My name is Venkat. I am working on a project which is using the=20
> http://jakarta.apache.org/poi/apidocs  API? I would appreciate any help
> tha=
> t I can get.
> 
> 
> Can somebody tell me, if there is a method or a way to find out the number
> =
> of rows and the number of columns that have been populated with
> values(like=
>  text, integer or formula, etc.) in the Excel workbook?
> Thank You
> 
> Thank You
> Kalkunda Venkat
> GFRIS - Principal Financial Group
> 

-- 
View this message in context: http://www.nabble.com/Row-Column-number%21%21%21-tp530660p19968118.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org