Java arraylist how to read DDE double values from an excel file and write into an array? -
i have excel file dde links external sources. trying read values java application.
i using apache poi library read excel. when trying, following error:
exception in thread "main" java.lang.illegalstateexception: cannot numeric value text cell @ org.apache.poi.hssf.usermodel.hssfcell.typemismatch(hssfcell.java:643) @ org.apache.poi.hssf.usermodel.hssfcell.getnumericcellvalue(hssfcell.java:668) @ basketexcelread.run(basketexcelread.java:40) @ tester.main(tester.java:7)
my code is
import java.io.file; import java.io.fileinputstream; import java.io.ioexception; import java.util.arraylist; import java.util.list; import org.apache.poi.hssf.usermodel.hssfcell; import org.apache.poi.hssf.usermodel.hssfrow; import org.apache.poi.hssf.usermodel.hssfsheet; import org.apache.poi.hssf.usermodel.hssfworkbook; public class basketexcelread implements runnable { public void run() { string inputfile = "someexcel.xls"; list<string> code = new arraylist<string>(); list<double> bid = new arraylist<double>(); list<double> share = new arraylist<double>(); try { fileinputstream file = new fileinputstream(new file(inputfile)); hssfworkbook workbook = new hssfworkbook(file); hssfsheet sheet = workbook.getsheetat(0); int ss = sheet.getphysicalnumberofrows(); (int = 0; < ss; i++) { hssfrow row = sheet.getrow(i); hssfcell cellcode = row.getcell(0); hssfcell cellbid = row.getcell(7); hssfcell cellshare = row.getcell(9); code.add(cellcode.getstringcellvalue()); bid.add(cellbid.getnumericcellvalue()); share.add(cellshare.getnumericcellvalue()); } } catch (ioexception e) { e.printstacktrace(); } { system.out.println("done reading"); } (int = 0; < 30; i++) { system.out.println(code.get(i)+" "+bid.get(i)+" "+share.get(i)); } } }
the cell text/numeric value conflict happens @ bid.add(cellbid.getnumericcellvalue()); cellbid dde link within excel file shows numeric values
Comments
Post a Comment