hi, i have a spreadsheet that is updated daily. this can be done manually or by a java thread. if it is done manually then the user can filter specific data elements to create specific reports. Example below:
http://www.nabble.com/file/p18565398/example1.jpg >From the spreadsheet you can see i have a record called BGT and its information for 04-05-2008. Say i create a report for 05-05-2008 for Head Cases i would expect it to be placed under the BGT record with no information for 04-05-2008 but information for 05-05-2008. However, this does not happen. When the spread sheet is updated the BGT record is overwritten and the new Head Cases record is placed over it with its information for 05-05-2008. 04-05-2008 Report: http://www.nabble.com/file/p18565398/example1.jpg 05-05-2008 Report: http://www.nabble.com/file/p18565398/example2.jpg This is the code i use to search for the next row to update and insert data: int limit = 0; Iterator<?> it = sheet.rowIterator(); while (it.hasNext()) { HSSFRow row = (HSSFRow)it.next(); if (row.getRowNum() < y) { continue; } HSSFCell cell = row.getCell((short)1); if (cell != null && cell.getCellType() == HSSFCell.CELL_TYPE_STRING && cell.getRichStringCellValue() != null && cell.getRichStringCellValue().getString().equals(name)) { limit = row.getRowNum(); break; } } return limit; ....... HSSFRow row = sheet.getRow(y); int templaterow = RowUtility.getNextNamedRow(sheet, y, TEMPLATE); for(ReportVo ad : records) { // Get the row that this advert belongs to String name = ad.getKeyword(); if (name == null || name.length() == 0) { name = "Unslotted"; ad.setKeyword(name); } int rownum = RowUtility.getNextNamedRow(sheet, y, name); if (rownum == 0) { int totalsrow = RowUtility.moveTotalsRow(sheet, y, ROW_SHIFT); // create a new row for our advert HSSFRow newAdRow = sheet.createRow(totalsrow - DATA_START_OFFSET); RowUtility.copyRow(sheet, row, newAdRow, true); // insert the new advert row updateAdvert(x, ad, newAdRow); } else { // Update the totals HSSFRow adRow = sheet.getRow(rownum); updateAdvert(x, ad, adRow); } If anyone has any ideas about the problem i am having please let me know. many thanks mark -- View this message in context: http://www.nabble.com/HSSFRow-trouble.--Data-being-over-written-tp18565398p18565398.html Sent from the POI - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
