我想读取一个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; }}
高手帮忙看看,明天就要交了,我已经百度谷歌很多天了,希望可以尽快解决,谢谢
以下是我的代码:
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; }}
高手帮忙看看,明天就要交了,我已经百度谷歌很多天了,希望可以尽快解决,谢谢
第一个 String 表名
Map里面 Integer 行 List 列
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]);
}
}