Java arraylist如何从Excel文件中读取DDE的双精度值并写入数组?

我有一个Excel文件与DDE链接到外部来源。 我正在尝试将这些值读入我的Java应用程序。

我正在使用Apache POI库来读取excel。 尝试时,我得到以下错误:

Exception in thread "main" java.lang.IllegalStateException: Cannot get a numeric value from a text cell at org.apache.poi.hssf.usermodel.HSSFCell.typeMismatch(HSSFCell.java:643) at org.apache.poi.hssf.usermodel.HSSFCell.getNumericCellValue(HSSFCell.java:668) at BasketExcelRead.run(BasketExcelRead.java:40) at Tester.main(Tester.java:7) 

我的代码是

 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(); for (int i = 0; i < 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(); } finally { System.out.println("done reading"); } for (int i = 0; i < 30; i++) { System.out.println(code.get(i)+" "+bid.get(i)+" "+share.get(i)); } } } 

文本/数值冲突的单元格出现在bid.add(cellBid.getNumericCellValue()); 这个cellBid是Excel文件中的DDE链接,它显示了一些数字值