import java.io.File;
import java.io.FileInputStream;
import java.util.HashMap;
import java.util.Map;
import jxl.Sheet;
import jxl.Workbook;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
public class TestExcelRead
{
public static void main(String[] args) throws Exception
{
TestExcelRead t = new TestExcelRead();
System.out.println(t.poiRead());
System.out.println(t.jxlRead());
}
public long jxlRead() throws Exception
{
long base = System.currentTimeMillis();
Workbook wb = Workbook.getWorkbook(new File("test.xls"));
Sheet sheet = wb.getSheet(0);
String[] values = new String[26];
Map<Integer, String[]> result = new HashMap<Integer, String[]>();
for (int j = 0; j < 65536; j++)
{
for (int i = 0; i < 10; i++)
values[i] = sheet.getCell(i, j).getContents();
result.put(j, values);
}
wb.close();
return System.currentTimeMillis() - base;
}
public long poiRead() throws Exception
{
long base = System.currentTimeMillis();
org.apache.poi.ss.usermodel.Workbook wb = new HSSFWorkbook(new FileInputStream("test.xls"));
org.apache.poi.ss.usermodel.Sheet sheet = wb.getSheetAt(0);
String[] values = new String[26];
Map<Integer, String[]> result = new HashMap<Integer, String[]>();
for (int j = 0; j < 65536; j++)
{
Row row = sheet.getRow(j);
for (int i = 0; i < 10; i++)
values[i] = row.getCell(i).getStringCellValue();
result.put(j, values);
}
return System.currentTimeMillis() - base;
}
}