Browse Source

修改readme文档

pull/2915/head
Jiaju Zhuang 2 years ago
parent
commit
af6f5f78e8
  1. 36
      README.md

36
README.md

@ -37,9 +37,9 @@ easyexcel重写了poi对07版Excel的解析,一个3M的excel用POI sax解析
# 帮忙点个⭐Star
开源不易,如果觉得EasyExcel对您的工作还是有帮助的话,请帮忙在<a target="_blank" href='https://github.com/alibaba/easyexcel'><img src="https://img.shields.io/github/stars/alibaba/easyexcel.svg?style=flat-square&label=Stars&logo=github" alt="github star"/></a>
的右上角点个⭐Star,您的支持是使EasyExcel变得更好最大的动力
的右上角点个⭐Star,您的支持是使EasyExcel变得更好最大的动力
# 如获取帮助
# 如获取帮助
## 优先建议自己通过文档来解决问题
@ -87,7 +87,8 @@ easyexcel重写了poi对07版Excel的解析,一个3M的excel用POI sax解析
## 读Excel
DEMO代码地址:[https://github.com/alibaba/easyexcel/blob/master/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/read/ReadTest.java](https://github.com/alibaba/easyexcel/blob/master/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/read/ReadTest.java)
demo代码地址:[https://github.com/alibaba/easyexcel/blob/master/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/read/ReadTest.java](https://github.com/alibaba/easyexcel/blob/master/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/read/ReadTest.java)
详细文档地址:[https://easyexcel.opensource.alibaba.com/docs/current/quickstart/read](https://easyexcel.opensource.alibaba.com/docs/current/quickstart/read)
```java
/**
@ -96,17 +97,18 @@ DEMO代码地址:[https://github.com/alibaba/easyexcel/blob/master/easyexcel-t
* <p>2. 由于默认一行行的读取excel,所以需要创建excel一行一行的回调监听器,参照{@link DemoDataListener}
* <p>3. 直接读即可
*/
@Test
public void simpleRead(){
String fileName=TestFileUtil.getPath()+"demo"+File.separator+"demo.xlsx";
@Test
public void simpleRead() {
String fileName = TestFileUtil.getPath() + "demo" + File.separator + "demo.xlsx";
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
EasyExcel.read(fileName,DemoData.class,new DemoDataListener()).sheet().doRead();
EasyExcel.read(fileName, DemoData.class, new DemoDataListener()).sheet().doRead();
}
```
## 写Excel
DEMO代码地址:[https://github.com/alibaba/easyexcel/blob/master/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java](https://github.com/alibaba/easyexcel/blob/master/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java)
demo代码地址:[https://github.com/alibaba/easyexcel/blob/master/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java](https://github.com/alibaba/easyexcel/blob/master/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/write/WriteTest.java)
详细文档地址:[https://easyexcel.opensource.alibaba.com/docs/current/quickstart/write](https://easyexcel.opensource.alibaba.com/docs/current/quickstart/write)
```java
/**
@ -114,8 +116,8 @@ DEMO代码地址:[https://github.com/alibaba/easyexcel/blob/master/easyexcel-t
* <p>1. 创建excel对应的实体对象 参照{@link com.alibaba.easyexcel.test.demo.write.DemoData}
* <p>2. 直接写即可
*/
@Test
public void simpleWrite(){
@Test
public void simpleWrite() {
String fileName=TestFileUtil.getPath()+"write"+System.currentTimeMillis()+".xlsx";
// 这里 需要指定写用哪个class去读,然后写到第一个sheet,名字为模板 然后文件流会自动关闭
// 如果这里想使用03 则 传入excelType参数即可
@ -125,7 +127,7 @@ public void simpleWrite(){
## web上传、下载
DEMO代码地址:[https://github.com/alibaba/easyexcel/blob/master/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/web/WebTest.java](https://github.com/alibaba/easyexcel/blob/master/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/web/WebTest.java)
demo代码地址:[https://github.com/alibaba/easyexcel/blob/master/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/web/WebTest.java](https://github.com/alibaba/easyexcel/blob/master/easyexcel-test/src/test/java/com/alibaba/easyexcel/test/demo/web/WebTest.java)
```java
/**
@ -137,8 +139,8 @@ DEMO代码地址:[https://github.com/alibaba/easyexcel/blob/master/easyexcel-t
* <p>
* 3. 直接写,这里注意,finish的时候会自动关闭OutputStream,当然你外面再关闭流问题不大
*/
@GetMapping("download")
public void download(HttpServletResponse response)throws IOException{
@GetMapping("download")
public void download(HttpServletResponse response) throws IOException {
// 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
@ -148,15 +150,15 @@ public void download(HttpServletResponse response)throws IOException{
EasyExcel.write(response.getOutputStream(),DownloadData.class).sheet("模板").doWrite(data());
}
/**
/**
* 文件上传
* <p>1. 创建excel对应的实体对象 参照{@link UploadData}
* <p>2. 由于默认一行行的读取excel,所以需要创建excel一行一行的回调监听器,参照{@link UploadDataListener}
* <p>3. 直接读即可
*/
@PostMapping("upload")
@ResponseBody
public String upload(MultipartFile file)throws IOException{
@PostMapping("upload")
@ResponseBody
public String upload(MultipartFile file)throws IOException{
EasyExcel.read(file.getInputStream(),UploadData.class,new UploadDataListener(uploadDAO)).sheet().doRead();
return"success";
}

Loading…
Cancel
Save