|
@@ -2,6 +2,7 @@ package cn.com.qmth.examcloud.commons.helpers.poi;
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.io.FileInputStream;
|
|
|
|
+import java.io.InputStream;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
import org.apache.commons.io.IOUtils;
|
|
import org.apache.commons.io.IOUtils;
|
|
@@ -161,5 +162,24 @@ public class ExcelReader {
|
|
|
|
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public static List<String[]> readSheetBySax(InputStream is, int sheetId, int columnSize) {
|
|
|
|
+ List<String[]> list = Lists.newArrayList();
|
|
|
|
+
|
|
|
|
+ XlsxHandler xlsxHandler = new XlsxHandler(columnSize) {
|
|
|
|
+ @Override
|
|
|
|
+ public void optRows(int sheetIndex, int curRow, String[] row) {
|
|
|
|
+ list.add(row);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ xlsxHandler.processOneSheet(is, sheetId);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|