Thursday 15 September 2011

java - Delete Rows containing the String Excel Apache POI API -


My problem is that I want to delete all the lines containing a string junior. I am doing this only in one line in which this string is my code that I am using:

  Private zero process Excel file (file f_path) throws an exception {file path = f_path; {FileInputStream = Try New FileInputStream (Path); HSSFWorkbook wb = New HSSFWorkbook (is); HSSFSheet Sheet = wb.getSheetAt (0); Int rowcount_post = 0; Int rowcount_304 = 0; (Line row: sheet) {for (cell cell: line) {if (cell.getCellType () == cell.cell_TYPE_STRING) {if (cell.getRichStringCellValue (). GetString () .tim (.) Equal ("JUNI" )) {Rowcount_post = row.getRowNum (); HSSFRow removal = right = sheet.lite (Panditikota_post); If (by removing! = Zero) {sheet.removeRow (for deletion); } Try (FileOutputStream fileOut = New FileOutputStream ("C: /juni.xls")) {wb.write (fileOut); }} And {System.out.print ("not found"); }}}}} Hold (exception e) {JOptionPane.showMessageDialog (this, e.getMessage (), "error", JOptionPane.ERROR_MESSAGE); }}   

I need to delete all the rows in my axil file, in which this string is juniose. Please help me, how can I do this, I have been trying my best since the last three days thanks in advance.

Try this It will remove all the rows in the sheet, in which any cell in the form of "subdivision" "Juni" is.

  Public static zero testing (XSSF sheet sheet) {XSSFRow line = faucet; XSSFCell cell = null; Int LastRowNum = sheet.getLastRowNum (); (Row = Sheet.Tet (Ronam); (Int Selnnom = 0; Selnnom; Row.getLastCellNum (); CellName ++) for (Roof = 0; Ron & Lt; Lesterov-1; (Cell = ra.get cell (salonam); string text incel = cell.Tosting (if;) (textincale contains ("june")} {sheet.shiftRows (RONNAM + 1, LSTROV, -1); LastRowNum -; RowNum--; breakdown;}}}}    

No comments:

Post a Comment