I can only assume that is correct since I have never actually opened the XML to see how Excel writes it. It makes sense, though, for the XML file to start with row 1 since Excel displays it as row 1, plus your example shows XML row 2 as the displayed row 2 in Excel. So your conclusion is correct. Excel (displayed and the XML) start with 1, while POI starts with 0.
Scott On May 17, 2014, at 2:07 AM, Renjith R <[email protected]> wrote: Thanks a lot for the response, David & Scott. This is how my excel looks like. [image: Inline image 2] Following is that data read by SAX parser. I am storing the row numbers 2 and 3. <sheetData><row *r="2"* spans="1:2" x14ac:dyDescent="0.25"><c r="A2" s="8" t="s"><v>16</v></c><c r="B2" s="19"><v>41760</v></c></row><row *r="3"*spans="1:2" x14ac:dyDescent="0.25"><c r="A3" s="8" t="s"><v>17</v></c><c r="B3" s="9"><v>80</v></c></row></sheetData> So can i conclude that, XML file which represents the sheet will start the row number from 1(as seen in excel) and apache poi will start at '0' ? On Thu, May 15, 2014 at 5:26 PM, Renjith R <[email protected]> wrote: > Hi, > > I am reading an excel file using SAX+XSSF method. While reading I am > saving the row numbers of each row from 'attributes.getValue("r")' of 'Row' > tag. > After validating data of each row in the application, i want to write > error at the last column of each row. > For writing the error ro excel I am using XSSFWorkbook alone. > > *Issue:* > > My sheet is having date at second row(first row is not used).On reading > the excel sheet, i will record the row number as 2.while validating i will > check if the date is a past date or not. If the date is a past date, i have > to write 'INVAlID DATE' at the last column of second row. > For that i am using the following code. > > XSSFWorkbook workBook = new XSSFWorkbbok(filePath); > Sheet mySheet = workBook.getSheetAt(0); > Row errorRow = mySheet.getRow(errorRowNumber); //errorRowNumber = 2 > > But row returned is not the second row, but the 3rd row which has some > other data. > > My Assumption: XSSFWorkbook will not consider the first empty row. It will > consider the second row(which has data) as the first row. So on getting row > with row number '2', it will return 3rd row. > > > Please let me know if my assumption is correct or not, if yes, how can i > resolve it? > > -- > *RENJITH R* > 9446011990 > -- *RENJITH R* 9446011990
