Commit 318235bf authored by liboyang's avatar liboyang

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	src/main/java/com/yxproject/start/service/PersonPostService.java
#	src/main/java/com/yxproject/start/service/impl/PersonPostServiceImpl.java
parents 75c46a87 f2a2d5f3
......@@ -91,6 +91,11 @@
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.3</version>
</dependency>
</dependencies>
......
package com.yxproject.start.api;
import com.yxproject.start.service.PreproPersonService;
import org.apache.commons.lang.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Date;
/**
* @auther zhangyusheng
* 2019/3/1 11:18
*/
@RestController
@RequestMapping("exportXML")
public class ExportXMLApi {
@Autowired
private PreproPersonService preproPersonService;
/**
* 导出邮寄制证数据包
*/
@RequestMapping("printPostXmlData")
// @RequiresPermissions("userInfo.add")//权限管理;
public byte[] printXmlData(@RequestParam("date") String date, HttpServletResponse response){
response.setContentType("application/x-download");
response.setCharacterEncoding("UTF-8");
String dateTime = DateFormatUtils.format(new Date(), "yyyyMMddHH");
// //使用Servlet实现文件下载的时候,避免浏览器自动打开文件
String fout = null;
//TODO
// List<PersonPostAbnormalEntity> postAbnormalEntity = personPostService.getAllPersonPostAbnormalEntity(date);
// fout = ExportExcel.exportPersonPostAbnormalExcel(postAbnormalEntity);
String outFile = dateTime + "制证数据包";
try {
FileInputStream fis = new FileInputStream(new File(fout));
byte[] b = new byte[fis.available()];
fis.read(b);
fis.close();
response.addHeader("Content-Disposition", "attachment;filename=" + outFile + ".xml");
return b;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
package com.yxproject.start.api;
import com.yxproject.start.entity.*;
import com.yxproject.start.service.*;
import com.yxproject.start.entity.FileNameDicEntity;
import com.yxproject.start.entity.PersonPostEntity;
import com.yxproject.start.service.FileNameDicService;
import com.yxproject.start.service.PersonPostService;
import com.yxproject.start.utils.ReadExcel;
import com.yxproject.start.utils.YXJSONResponse;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.Context;
import java.io.*;
import java.sql.Time;
import java.util.ArrayList;
import java.util.List;
import java.io.File;
import java.util.*;
/**
*
......@@ -23,51 +33,124 @@ public class ReadExcelApi {
@Autowired
PersonPostService personPostService;
@Autowired
FileNameDicService fileNameDicService;
Boolean result = null;
/**
* 导入个人信息表
* 导入个人邮寄信息表
*/
@RequestMapping("ReadPersonPost")
public boolean ReadPersonPost(){
ReadExcel obj = new ReadExcel();
PersonPostEntity personPost = new PersonPostEntity();
List<PersonPostEntity> entityList = new ArrayList<PersonPostEntity>();
File file = new File("E:/北京制证项目/Person_Post.xls");
List excelList = obj.readExcel(file);
for (int i=0;i<excelList.size();i++){
List list = (List) excelList.get(i);
//跳过空行和第一行
if (list == null||i==0){
continue;
@Transactional(rollbackFor = Exception.class)
public String ReadPersonPost(@Context HttpServletResponse resp, @Context HttpServletRequest requ){
YXJSONResponse yxresp = new YXJSONResponse();
resp.setCharacterEncoding("UTF-8");
String filename = "";
DiskFileItemFactory factory = new DiskFileItemFactory();
// 设置缓冲区的大小为100KB,如果不指定,那么缓冲区的大小默认是10KB
factory.setSizeThreshold(1024 * 100);
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setHeaderEncoding("UTF-8");
// 设置上传单个文件的大小的最大值,目前是设置为1024*1024*10字节,也就是10MB
upload.setFileSizeMax(1024 * 1024 * 10);
// 设置上传文件总量的最大值,最大值=同时上传的多个文件的大小的最大值的和,目前设置为4000MB
upload.setSizeMax(1024 * 1024 * 4000);
// 将普通属性存入map中,之后调用
Map<String, String> map = new HashMap<String, String>();
List<FileItem> list = null;
try {
list = upload.parseRequest(requ);
for (FileItem item : list) {
File file =null;
try {
// 如果fileitem中封装的是普通输入项的数据
if (item.isFormField()) {
String name = item.getFieldName();
// 解决普通输入项的数据的中文乱码问题
String value = item.getString("UTF-8");
map.put(name, value);
} else {
// 如果fileitem中封装的是上传文件
// 得到上传的文件名称,
filename = item.getName();
if (filename == null || filename.trim().equals("")) {
continue;
}
InputStream in = item.getInputStream();
OutputStream os = new FileOutputStream(file);
int bytesRead = 0;
byte[] buffer = new byte[8192];
while ((bytesRead = in.read(buffer, 0, 8192)) != -1) {
os.write(buffer, 0, bytesRead);
}
os.close();
in.close();
}
ReadExcel readExcel = new ReadExcel();
List list1 = readExcel.readExcel(file);
//保存EXCEL文件信息
FileNameDicEntity fileNameDicEntity = new FileNameDicEntity();
fileNameDicEntity.setFileName(filename);
fileNameDicEntity.setUploadDate(new Date());
//保存个人邮寄信息
long fileID = fileNameDicService.saveFileNameDic(fileNameDicEntity);
List<PersonPostEntity> entityList= new ArrayList<PersonPostEntity>();
for (int i = 0; i < list1.size(); i++){
PersonPostEntity personPostEntity = new PersonPostEntity();
List list2 = (List) list1.get(i);
//跳过空行和第一行
if (list2 == null||i==0){
continue;
}
personPostEntity.setBackWaybillNumber((String) list2.get(0));
personPostEntity.setOrderNumber((String) list2.get(1));
personPostEntity.setCreateDate((Time) list2.get(2));
personPostEntity.setOpenid((String) list2.get(3));
personPostEntity.setWcPlayOrderNumber((String) list2.get(4));
personPostEntity.setPlayState((String) list2.get(5));
personPostEntity.setOrderState((String) list2.get(6));
personPostEntity.setApplicantName((String) list2.get(7));
personPostEntity.setSenderName((String) list2.get(8));
personPostEntity.setSenderPhone((String) list2.get(9));
personPostEntity.setSenderAddress((String) list2.get(10));
personPostEntity.setRecipientName((String) list2.get(11));
personPostEntity.setRecipientPhone((String) list2.get(12));
personPostEntity.setRecipientAddress((String) list2.get(13));
personPostEntity.setOrderBlankNumber((String) list2.get(14));
personPostEntity.setGetToProvince((String) list2.get(15));
personPostEntity.setGetToCity((String) list2.get(16));
personPostEntity.setGetToCounty((String) list2.get(17));
personPostEntity.setBusinessType((String) list2.get(18));
personPostEntity.setLatticeMouthInformation((String) list2.get(19));
personPostEntity.setNatureOfTheInternal((String) list2.get(20));
personPostEntity.setNatureOfTheInformation((String) list2.get(21));
personPostEntity.setFirstWhite((String) list2.get(22));
personPostEntity.setFileId(fileID);
entityList.add(personPostEntity);
}
boolean b = personPostService.savePersonPost(entityList);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
yxresp.outPutError("UnsupportedEncodingException", "上传文件时发现文件编码错误:" + e.getMessage());
continue;
} catch (IOException e) {
e.printStackTrace();
yxresp.outPutError("IOException", "上传文件时发生IO错误:" + e.getMessage());
continue;
} catch (Exception e) {
e.printStackTrace();
yxresp.outPutError("Exception", "上传文件时发生错误,非法XML文件:" + filename);
continue;
}
}
personPost.setBackWaybillNumber((String) list.get(0));
personPost.setOrderNumber((String) list.get(1));
personPost.setCreateDate((Time) list.get(2));
personPost.setOpenid((String) list.get(3));
personPost.setWcPlayOrderNumber((String) list.get(4));
personPost.setPlayState((String) list.get(5));
personPost.setOrderState((String) list.get(6));
personPost.setApplicantName((String) list.get(7));
personPost.setSenderName((String) list.get(8));
personPost.setSenderPhone((String) list.get(9));
personPost.setSenderAddress((String) list.get(10));
personPost.setRecipientName((String) list.get(11));
personPost.setRecipientPhone((String) list.get(12));
personPost.setRecipientAddress((String) list.get(13));
personPost.setOrderBlankNumber((String) list.get(14));
personPost.setGetToProvince((String) list.get(15));
personPost.setGetToCity((String) list.get(16));
personPost.setGetToCounty((String) list.get(17));
personPost.setBusinessType((String) list.get(18));
personPost.setLatticeMouthInformation((String) list.get(19));
personPost.setNatureOfTheInternal((String) list.get(20));
personPost.setLatticeMouthInformation((String) list.get(21));
personPost.setFirstWhite((String) list.get(22));
entityList.add(personPost);
} catch (FileUploadException e) {
e.printStackTrace();
yxresp.outPutError("FileUploadException", "文件上载发生异常:" + e.getMessage());
} finally {
return yxresp.toJSONString();
}
result = personPostService.updatePersonPost(entityList);
return result;
}
}
......@@ -52,4 +52,5 @@ public class UserApi {
subject.logout();
}
}
}
package com.yxproject.start.entity;
import javax.persistence.*;
import java.sql.Time;
import java.util.Date;
import java.util.Objects;
/**
* @auther zhangyusheng
* 2019/3/1 10:39
*/
@Entity
@Table(name = "FILE_NAME_DIC", schema = "YX", catalog = "")
public class FileNameDicEntity {
private long fileId;
private String fileName;
private Date uploadDate;
private Date analysisDate;
private Date printDate;
private String formStartTime;
private String formDeadline;
@Id
@Column(name = "FILE_ID")
public long getFileId() {
return fileId;
}
public void setFileId(long fileId) {
this.fileId = fileId;
}
@Basic
@Column(name = "FILE_NAME")
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
@Basic
@Column(name = "UPLOAD_DATE")
public Date getUploadDate() {
return uploadDate;
}
public void setUploadDate(Date uploadDate) {
this.uploadDate = uploadDate;
}
@Basic
@Column(name = "ANALYSIS_DATE")
public Date getAnalysisDate() {
return analysisDate;
}
public void setAnalysisDate(Date analysisDate) {
this.analysisDate = analysisDate;
}
@Basic
@Column(name = "PRINT_DATE")
public Date getPrintDate() {
return printDate;
}
public void setPrintDate(Date printDate) {
this.printDate = printDate;
}
@Basic
@Column(name = "FORM_START_TIME")
public String getFormStartTime() {
return formStartTime;
}
public void setFormStartTime(String formStartTime) {
this.formStartTime = formStartTime;
}
@Basic
@Column(name = "FORM_DEADLINE")
public String getFormDeadline() {
return formDeadline;
}
public void setFormDeadline(String formDeadline) {
this.formDeadline = formDeadline;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
FileNameDicEntity that = (FileNameDicEntity) o;
return fileId == that.fileId &&
Objects.equals(fileName, that.fileName) &&
Objects.equals(uploadDate, that.uploadDate) &&
Objects.equals(analysisDate, that.analysisDate) &&
Objects.equals(printDate, that.printDate) &&
Objects.equals(formStartTime, that.formStartTime) &&
Objects.equals(formDeadline, that.formDeadline);
}
@Override
public int hashCode() {
return Objects.hash(fileId, fileName, uploadDate, analysisDate, printDate, formStartTime, formDeadline);
}
}
......@@ -37,12 +37,7 @@ public class PersonPostEntity {
private Time validPeriodEnd;
private String note;
private Long state;
private Time uploadDate;
private Long fileId;
private Time analysisDate;
private Time printDate;
private Time formStartTime;
private Time formDeadline;
@Id
@Column(name = "WAYBILL_NUMBER")
......@@ -344,15 +339,6 @@ public class PersonPostEntity {
this.state = state;
}
@Basic
@Column(name = "UPLOAD_DATE")
public Time getUploadDate() {
return uploadDate;
}
public void setUploadDate(Time uploadDate) {
this.uploadDate = uploadDate;
}
@Basic
@Column(name = "FILE_ID")
......@@ -364,45 +350,6 @@ public class PersonPostEntity {
this.fileId = fileId;
}
@Basic
@Column(name = "ANALYSIS_DATE")
public Time getAnalysisDate() {
return analysisDate;
}
public void setAnalysisDate(Time analysisDate) {
this.analysisDate = analysisDate;
}
@Basic
@Column(name = "PRINT_DATE")
public Time getPrintDate() {
return printDate;
}
public void setPrintDate(Time printDate) {
this.printDate = printDate;
}
@Basic
@Column(name = "FORM_START_TIME")
public Time getFormStartTime() {
return formStartTime;
}
public void setFormStartTime(Time formStartTime) {
this.formStartTime = formStartTime;
}
@Basic
@Column(name = "FORM_DEADLINE")
public Time getFormDeadline() {
return formDeadline;
}
public void setFormDeadline(Time formDeadline) {
this.formDeadline = formDeadline;
}
@Override
public boolean equals(Object o) {
......@@ -439,16 +386,11 @@ public class PersonPostEntity {
Objects.equals(validPeriodEnd, that.validPeriodEnd) &&
Objects.equals(note, that.note) &&
Objects.equals(state, that.state) &&
Objects.equals(uploadDate, that.uploadDate) &&
Objects.equals(fileId, that.fileId) &&
Objects.equals(analysisDate, that.analysisDate) &&
Objects.equals(printDate, that.printDate) &&
Objects.equals(formStartTime, that.formStartTime) &&
Objects.equals(formDeadline, that.formDeadline);
Objects.equals(fileId, that.fileId) ;
}
@Override
public int hashCode() {
return Objects.hash(waybillNumber, backWaybillNumber, orderNumber, createDate, openid, wcPlayOrderNumber, playState, orderState, applicantName, senderName, senderPhone, senderAddress, recipientName, recipientPhone, recipientAddress, orderBlankNumber, getToProvince, getToCity, getToCounty, businessType, latticeMouthInformation, natureOfTheInternal, natureOfTheInformation, firstWhite, idCard, acceptTheMatter, beginUsefulLife, validPeriodEnd, note, state, uploadDate, fileId, analysisDate, printDate, formStartTime, formDeadline);
return Objects.hash(waybillNumber, backWaybillNumber, orderNumber, createDate, openid, wcPlayOrderNumber, playState, orderState, applicantName, senderName, senderPhone, senderAddress, recipientName, recipientPhone, recipientAddress, orderBlankNumber, getToProvince, getToCity, getToCounty, businessType, latticeMouthInformation, natureOfTheInternal, natureOfTheInformation, firstWhite, idCard, acceptTheMatter, beginUsefulLife, validPeriodEnd, note, state, fileId);
}
}
package com.yxproject.start.mapper;
import com.yxproject.start.entity.FileNameDicEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
/**
* @auther zhangyusheng
* 2019/3/1 10:41
*/
@Mapper
public interface FileNameDicMapper {
@Insert("INSERT INTO FILE_NAME_DIC (FILE_NAME,UPLOAD_DATE) VALUES (#{fileName},#{uploadDate})")
@Options(useGeneratedKeys=true, keyProperty="fileId", keyColumn="fileId")
public long saveFileNameDic(FileNameDicEntity fileNameDicEntity);
}
......@@ -13,8 +13,8 @@ import java.util.List;
*/
@Mapper
public interface PersonPostMapper {
@Update("update PERSON_POST set WAYBILL_NUMBER=#{waybillNumber},BACK_WAYBILL_NUMBER=#{backWaybillNumber},ORDER_NUMBER=#{orderNumber},CREATE_DATE=#{createDate},OPENID=#{openid},WC_PLAY_ORDER_NUMBER=#{wcPlayOrderNumber},PLAY_STATE=#{playState},ORDER_STATE=#{orderState},,APPLICANT_NAME=#{applicantName},SENDER_NAME=#{senderName},SENDER_PHONE=#{senderPhone},SENDER_ADDRESS=#{senderAddress},RECIPIENT_NAME=#{recipientName},RECIPIENT_PHONE=#{recipientPhone},RECIPIENT_ADDRESS=#{recipientAddress},ORDER_BLANK_NUMBER=#{orderBlankNumber},GET_TO_PROVINCE=#{getToProvince},GET_TO_CITY=#{getToCity},GET_TO_COUNTY=#{getToCounty},BUSINESS_TYPE=#{businessType},LATTICE_MOUTH_INFORMATION=#{latticeMouthInformation},NATURE_OF_THE_INTERNAL=#{natureOfTheInternal},NATURE_OF_THE_INFORMATION=#{natureOfTheInformation},FIRST_WHITE=#{firstWhite}")
public boolean updatePersonPost(PersonPostEntity personPostEntity);
@Update("insert into PERSON_POST ( WAYBILL_NUMBER,BACK_WAYBILL_NUMBER,ORDER_NUMBER,CREATE_DATE,OPENID,WC_PLAY_ORDER_NUMBER,PLAY_STATE,ORDER_STATE,APPLICANT_NAME,SENDER_NAME,SENDER_PHONE,SENDER_ADDRESS,RECIPIENT_NAME,RECIPIENT_PHONE,RECIPIENT_ADDRESS,ORDER_BLANK_NUMBER,GET_TO_PROVINCE,GET_TO_CITY,GET_TO_COUNTY,BUSINESS_TYPE,LATTICE_MOUTH_INFORMATION,NATURE_OF_THE_INTERNAL,NATURE_OF_THE_INFORMATION,FIRST_WHITE,UPLOAD_DATE) values (#{waybillNumber},#{backWaybillNumber},#{orderNumber},#{createDate},#{openid},#{wcPlayOrderNumber},#{playState},#{orderState},#{applicantName},#{senderName},#{senderPhone},#{senderAddress},#{recipientName},#{recipientPhone},#{recipientAddress},#{orderBlankNumber},#{getToProvince},#{getToCity},#{getToCounty},#{businessType},#{latticeMouthInformation},#{natureOfTheInternal},#{natureOfTheInformation},#{firstWhite},#(uploadDate))")
public boolean savePersonPost(PersonPostEntity personPostEntity);
@Select("SELECT * FROM PERSON_POST WHERE ID_CARD=idCard AND BEGIN_USEFUL_LIFE=to_date(#{startDate},'yyyyMMdd') AND VALID_PERIOD_END=to_date(#{endDate},'yyyyMMdd')")
public List<PersonPostEntity> findAllByIdCardAndStartDateAndEndDate(String idCard, String startDate, String endDate);
......
......@@ -3,8 +3,11 @@ package com.yxproject.start.mapper;
import com.yxproject.start.entity.PreproPersonEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;
/**
* Created by Administrator on 2019/2/15.
*/
......@@ -21,4 +24,13 @@ public interface PreproPersonMapper {
/*更新制证数据是否邮寄*/
@Update("UPDATE PREPRO_PERSON SET IS_POST=#{isPost} where JMSFZSLH=#{jmsfzslh}")
public boolean updatePreproPersonEntity(PreproPersonEntity personEntity);
/*按条件查询制证数据*/
@Select("select * from PREPRO_PERSON \n" +
"left join files on PREPRO_PERSON.FILE_ID = files.ID\n" +
"left join NEW_FILES on PREPRO_PERSON.FILE_ID = NEW_FILES.ID " +
"where PREPRO_PERSON.JMSFZSLH = #{uploadNo} and GMSFHM = #{IDCard}" +
//TODO
"and files.SOURCE_FILE_NAME =#{oldFile} and ")
public List<PreproPersonEntity> selectPreproPerson(String uploadNo,String IDCard,String oldFile,String newFile,String SSXQDM,String cardType,String state,String uploadDate);
}
package com.yxproject.start.service;
import com.yxproject.start.entity.FileNameDicEntity;
/**
* @auther zhangyusheng
* 2019/3/1 10:42
*/
public interface FileNameDicService {
public long saveFileNameDic(FileNameDicEntity fileNameDicEntity);
}
......@@ -14,7 +14,7 @@ public interface PersonPostService {
/**
* 导入个人邮寄异常信息
*/
public boolean updatePersonPost(List<PersonPostEntity> personPostEntities);
public boolean savePersonPost(List<PersonPostEntity> personPostEntities);
public List<PersonPostEntity> getPostInfo(ReadCardDto card);
......
package com.yxproject.start.service;
/**
* @auther zhangyusheng
* 2019/3/1 11:24
*/
public interface PreproPersonService {
}
package com.yxproject.start.service.impl;
import com.yxproject.start.entity.FileNameDicEntity;
import com.yxproject.start.mapper.FileNameDicMapper;
import com.yxproject.start.service.FileNameDicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @auther zhangyusheng
* 2019/3/1 10:43
*/
@Service
public class FileNameDicServiceImpl implements FileNameDicService {
@Autowired
private FileNameDicMapper fileNameDicMapper;
@Override
public long saveFileNameDic(FileNameDicEntity fileNameDicEntity) {
long fileId = fileNameDicMapper.saveFileNameDic(fileNameDicEntity);
return fileId;
}
}
......@@ -10,6 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
......@@ -27,13 +29,10 @@ public class PersonPostServiceImpl implements PersonPostService {
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updatePersonPost(List<PersonPostEntity> personPostEntities) {
public boolean savePersonPost(List<PersonPostEntity> personPostEntities) {
for (PersonPostEntity personPostEntity: personPostEntities) {
boolean b = personPostMapper.updatePersonPost(personPostEntity);
PreproPersonEntity preproPersonEntity = new PreproPersonEntity();
preproPersonEntity.setJmsfzslh(personPostEntity.getFirstWhite());
preproPersonEntity.setIsPost((long)1);
preproPersonMapper.updatePreproPersonEntity(preproPersonEntity);
personPostEntity.setCreateDate(new java.sql.Time(new Date().getTime()));
boolean b = personPostMapper.savePersonPost(personPostEntity);
}
return true;
}
......
package com.yxproject.start.service.impl;
import com.yxproject.start.mapper.PreproPersonMapper;
import com.yxproject.start.service.PreproPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @auther zhangyusheng
* 2019/3/1 11:25
*/
@Service
public class PreproPersonServiceImpl implements PreproPersonService {
@Autowired
private PreproPersonMapper preproPersonMapper;
}
package com.yxproject.start.utils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
/**
* Created by zhangyusheng on 2019/1/30 14:39
*/
public class ReadExcel {
public static void main(String[] args) {
ReadExcel obj = new ReadExcel();
// 此处为我创建Excel路径:E:/zhanhj/studysrc/jxl下
File file = new File("E:/北京制证项目/personal_progress_status.xls");
List excelList = obj.readExcel(file);
System.out.println("list中的数据打印出来");
for (int i = 0; i < excelList.size(); i++) {
System.out.println("第"+i+"行:"+excelList.get(i));
List list = (List) excelList.get(i);
for (int j = 0; j < list.size(); j++) {
// System.out.print(list.get(j));+
}
}
}
// 去读Excel的方法readExcel,该方法的入口参数为一个File对象
public List readExcel(File file) {
public List readExcel(File file) {
try {
// 创建输入流,读取Excel
InputStream is = new FileInputStream(file.getAbsolutePath());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment