Use org.apache.poi.hssf.util.CellReference. Simply create a new instance passing the string in the constructor then call getRow(), getCol().
> -----Original Message----- > From: Sebastian Frehmel [mailto:[EMAIL PROTECTED] > Sent: Monday, May 21, 2007 3:09 PM > To: [email protected] > Subject: Re: get cell number > > Hi > I once wrote a class to do the exact opposite: It converts a cell range > given by numbers into Excel-like "A1:C10". > Maybe it is a good start for you to solve your problem. Here is the > code (everything is possible from "A1" to "ZZ65536", but Excel only > supports columns up to "IV"): > ======================================== > > import org.apache.poi.hssf.util.Region; > > > > public class Range extends Region { > > > > public Range(int rowFrom, short colFrom, int rowTo, short colTo){ > > super(rowFrom, colFrom, rowTo, colTo); > > } > > > > private String toCol(int col){ > > if (col<26){ > > return String.valueOf((char)(65+col)); > > } > > int mainCount = col/26; > > int minorCount = col-26*mainCount; > > char mainLetter = (char)(64+mainCount); > > char minorLetter = (char)(65+minorCount); > > return String.valueOf(mainLetter) + > String.valueOf(minorLetter); > > } > > > > public String getAddress(){ > > return > toCol(getColumnFrom())+(getRowFrom()+1)+":"+toCol(getColumnTo())+(getRowTo > ()+1); > > } > > } > > > Zitat von Raghav <[EMAIL PROTECTED]>: > > > Hi, > > > > If get the input for a cell in the form of say 'G8', this means > > column 'G' and > > row number 8. I want a utility to convert this column name to the > respective > > column number. > > > > Thanks > > Raghav > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > Mailing List: http://jakarta.apache.org/site/mail2.html#poi > > The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/ > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > Mailing List: http://jakarta.apache.org/site/mail2.html#poi > The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] Mailing List: http://jakarta.apache.org/site/mail2.html#poi The Apache Jakarta Poi Project: http://jakarta.apache.org/poi/
