提交 514b41dd authored 作者: taojinlong's avatar taojinlong

fix: 默认抽取 excel 第一个 sheet 页

上级 91929a76
...@@ -29,6 +29,10 @@ import org.apache.http.HttpResponse; ...@@ -29,6 +29,10 @@ import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.pentaho.di.cluster.SlaveServer; import org.pentaho.di.cluster.SlaveServer;
import org.pentaho.di.core.database.DatabaseMeta; import org.pentaho.di.core.database.DatabaseMeta;
import org.pentaho.di.core.row.ValueMetaInterface; import org.pentaho.di.core.row.ValueMetaInterface;
...@@ -64,6 +68,8 @@ import org.springframework.stereotype.Service; ...@@ -64,6 +68,8 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.naming.AuthenticationException; import javax.naming.AuthenticationException;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -512,9 +518,23 @@ public class ExtractDataService { ...@@ -512,9 +518,23 @@ public class ExtractDataService {
ExcelInputMeta excelInputMeta = new ExcelInputMeta(); ExcelInputMeta excelInputMeta = new ExcelInputMeta();
if (StringUtils.equalsIgnoreCase(suffix, "xlsx")) { if (StringUtils.equalsIgnoreCase(suffix, "xlsx")) {
excelInputMeta.setSpreadSheetType(SpreadSheetType.SAX_POI); excelInputMeta.setSpreadSheetType(SpreadSheetType.SAX_POI);
try{
InputStream inputStream = new FileInputStream(filePath);
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(inputStream);
XSSFSheet sheet0 = xssfWorkbook.getSheetAt(0);
excelInputMeta.setSheetName(new String[]{sheet0.getSheetName()});
}catch (Exception e){
e.printStackTrace();
}
} }
if (StringUtils.equalsIgnoreCase(suffix, "xls")) { if (StringUtils.equalsIgnoreCase(suffix, "xls")) {
excelInputMeta.setSpreadSheetType(SpreadSheetType.JXL); excelInputMeta.setSpreadSheetType(SpreadSheetType.JXL);
try{
InputStream inputStream = new FileInputStream(filePath);
HSSFWorkbook workbook = new HSSFWorkbook(inputStream);
HSSFSheet sheet0 = workbook.getSheetAt(0);
excelInputMeta.setSheetName(new String[]{sheet0.getSheetName()});
}catch (Exception e){e.printStackTrace();}
} }
excelInputMeta.setPassword("Encrypted"); excelInputMeta.setPassword("Encrypted");
excelInputMeta.setFileName(new String[]{filePath}); excelInputMeta.setFileName(new String[]{filePath});
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论