我想读取一个excel文件,并将各个单元格的内容存入一个二维数组中,但是老是无法存入数组中,Eclipse的console提示为:[[Ljava.lang.String;@1d6f122
以下是我的代码:
import java.io.*;
import jxl.*;public class JavaExcelApi {
public String xlsImport(String path) {
Workbook book = null;
Sheet sheet = null;
try {
book = Workbook.getWorkbook(new File(path));
sheet = book.getSheet(0);
int rows = sheet.getRows();
int columns = sheet.getColumns();
String[][] strTemp = new String[rows][columns];
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
Cell ctemp = sheet.getCell(j, i);
strTemp[i][j] = ctemp.getContents();
}
}
System.out.print(strTemp); } catch (Exception e) {
e.printStackTrace();
}
return path; }}
高手帮忙看看,明天就要交了,我已经百度谷歌很多天了,希望可以尽快解决,谢谢

解决方案 »

  1.   

    建议存LinkedHashMap<String,Map<Integer,List<String>>>
    第一个 String  表名
    Map里面  Integer 行    List 列
      

  2.   

    或者 最后一个list 再存Map  key:列
      

  3.   

    建议用对象数组 Object [][] obj = new Object[x][y];
      

  4.   

    7楼的说对了,可以打印了,但是我现在要把这个数组转换为double类型传给另外一个方法计算,用parseDouble转不了不知道为什么,代码如下:
    rows = sheet.getRows();
    columns = sheet.getColumns();
    stringData = new String[rows][columns];
    for (int i = 0; i < rows; i++) {
    for (int j = 0; j < columns; j++) {
    Cell ctemp = sheet.getCell(j, i);
    stringData[i][j] = ctemp.getContents();
    }
    }
    for (int i = 0; i < stringData[i].length; i++) {
    for (int j = 0; j < stringData[j].length; j++) {
    data[i][j] = Double.parseDouble(stringData[i][j]);
    System.out.print(data[i][j]);
    }
    }