java - How to write out results of a program to Excel? -


i'm trying capture of links website, print them out, , store them in excel file. program correctly displaying results isn't storing them in excel file.

package frameworks;  public class arrayconversion {     public static void main(string[] args) throws exception {         webdriver driver = new firefoxdriver();         driver.get("http://only-testing-blog.blogspot.in/2013/09/test.html");         list<webelement> li = driver.findelements(by.tagname("a"));         iterator<webelement> itr = li.iterator();         while (itr.hasnext()) {             string link = itr.next().gettext();             arraylist<string> stringlist = new arraylist<string>();             stringlist.add(link);              string array[] = stringlist.toarray(new string[stringlist.size()]);             (string str : array) {                 system.out.println(str);                 xlwrite(array);             }         }     }     public static void xlwrite(string[] array) throws exception {         system.out.println("inside xl write");         file fil = new file("c:\\users\\kshitij\\desktop\\linkstest.xls");         hssfworkbook wb = new hssfworkbook();         hssfsheet sht = wb.createsheet("results");         (int = 0; < array.length; i++) {             hssfrow row = sht.createrow(i);             (int j = 0; j < 1; j++) {                 hssfcell cell = row.createcell(j);                 cell.setcelltype(hssfcell.cell_type_string);                 cell.setcellvalue(array[i]);             }             fileoutputstream fout = new fileoutputstream(fil);             wb.write(fout);             fout.flush();             fout.close();             wb.close();         }     } } 


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -