mirror of
https://gitee.com/jzsw-it/yexuejc-base.git
synced 2025-09-28 08:23:20 +08:00
1.4.0 优化Execl 和 Jwt 工具
This commit is contained in:
@@ -1,5 +1,15 @@
|
||||
package com.yexuejc.base.util;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* excel 格式验证工具
|
||||
*
|
||||
@@ -48,5 +58,20 @@ public class ExcelImportUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void readExcel(String path) throws IOException {
|
||||
Workbook wb = null;
|
||||
if (isExcel2007(path)) {
|
||||
wb = new XSSFWorkbook(new FileInputStream(new File(path)));
|
||||
} else if (isExcel2003(path)) {
|
||||
wb = new HSSFWorkbook(new FileInputStream(new File(path)));
|
||||
} else {
|
||||
throw new NullPointerException("请上传excel文件");
|
||||
}
|
||||
Sheet sheet = wb.getSheetAt(0);
|
||||
for (int i = 2; i < sheet.getLastRowNum() + 1; i++) {
|
||||
Row row = sheet.getRow(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -124,4 +124,19 @@ public class JwtUtil {
|
||||
return JsonUtil.json2Obj(subject, cls);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密token为字符串
|
||||
*
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
public String parseStr(String token) {
|
||||
String subject = null;
|
||||
try {
|
||||
subject = Jwts.parser().setSigningKey(JWT_SIGNATURE_KEY).parseClaimsJws(token).getBody().getSubject();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return subject;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user