Name: easyexcel
Owner: Alibaba
Description: ???????OOM?java??Excel??
Created: 2018-02-06 03:14:08.0
Updated: 2018-05-24 16:33:19.0
Pushed: 2018-05-08 04:00:46.0
Homepage: null
Size: 4588
Language: Java
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Java?????Excel????????Apache poi?jxl???????????????????????poi???SAX???API????????????????????POI??????????07?Excel?????????????????????????????easyexcel???poi?07?Excel??????????3M?excel?POI sax????100M???????KB????????excel?????????03???POI?sax??????????????????????????
endency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>{latestVersion}</version>
pendency>
???????
ic void noModelMultipleSheet() {
InputStream inputStream = getInputStream("2007NoModelMultipleSheet.xlsx");
try {
ExcelReader reader = new ExcelReader(inputStream, ExcelTypeEnum.XLSX, null,
new AnalysisEventListener<List<String>>() {
@Override
public void invoke(List<String> object, AnalysisContext context) {
System.out.println(
"??sheet:" + context.getCurrentSheet().getSheetNo() + " ????" + context.getCurrentRowNum()
+ " data:" + object);
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
}
});
reader.read();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
t
ic void test1() throws FileNotFoundException {
OutputStream out = new FileOutputStream("/Users/jipengfei/78.xlsx");
try {
ExcelWriter writer = new ExcelWriter(out, ExcelTypeEnum.XLSX);
//????sheet, sheet1 ????List<String> ???????
Sheet sheet1 = new Sheet(1, 0,ExcelPropertyIndexModel.class);
writer.write(getData(), sheet1);
writer.finish();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
package com.alibaba.china.pte.web.seller.dingtalk.rpc;
import java.io.IOException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List;
import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;
import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.metadata.Sheet; import com.alibaba.excel.support.ExcelTypeEnum;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;
/**
@author jipengfei
@date 2018/05/25 */ @RequestMapping(“/api/dingtalk”) @RestController public class Down {
@GetMapping(“/a.htm”) public void cooperation(HttpServletRequest request, HttpServletResponse response) {
ServletOutputStream out = null;
try {
out = response.getOutputStream();
} catch (IOException e) {
e.printStackTrace();
}
ExcelWriter writer = new ExcelWriter(out, ExcelTypeEnum.XLSX, true);
try {
String fileName = new String(("UserInfo " + new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
.getBytes(), "UTF-8");
Sheet sheet1 = new Sheet(1, 0);
sheet1.setSheetName("???sheet");
writer.write0(getListString(), sheet1);
response.setContentType("multipart/form-data");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-disposition", "attachment;filename="+fileName+".xlsx");
out.flush();
} catch (Exception e) {
e.printStackTrace();
}finally {
writer.finish();
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
private List> getListString() {
List<String> list = new ArrayList<String>();
list.add("ooo1");
list.add("ooo2");
list.add("ooo3");
list.add("ooo4");
List<String> list1 = new ArrayList<String>();
list1.add("ooo1");
list1.add("ooo2");
list1.add("ooo3");
list1.add("ooo4");
List<List<String>> ll = new ArrayList<List<String>>();
ll.add(list);
ll.add(list1);
return ll;
}
}
??????????????????????????git?????????????????????
??????????–??JAVA????????????????????????????jipengfei.jpf@alibaba-inc.com ???????