SmartExcelReader.java 945 B

1234567891011121314151617181920212223242526272829303132
  1. package net.lab1024.smartadmin.util.excel;
  2. /**
  3. * @author zhuoda
  4. * @Date 2020/8/10
  5. */
  6. import net.lab1024.smartadmin.util.SmartFileUtil;
  7. import java.io.*;
  8. public class SmartExcelReader {
  9. public static SmartExcel openExcel(String filePath) throws IOException {
  10. SmartFileUtil.isFileExistThrowException(filePath);
  11. return new SmartExcel(new File(filePath).getCanonicalPath());
  12. }
  13. public static SmartExcel openExcel(File file) throws IOException {
  14. return new SmartExcel(file.getCanonicalPath());
  15. }
  16. public static SmartExcel openExcel(InputStream ins, SmartExcelFileType fileType) throws IOException {
  17. return new SmartExcel(ins, fileType);
  18. }
  19. public static void main(String[] args) throws Exception {
  20. SmartExcel smartExcel = openExcel(new FileInputStream(new File("F:/privilege.xlsx")), SmartExcelFileType.XLSX);
  21. System.out.println(smartExcel.getSheetList());
  22. }
  23. }