Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Laubin729
easyexcel
提交
e1231bf8
E
easyexcel
项目概览
Laubin729
/
easyexcel
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
easyexcel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
e1231bf8
编写于
5月 25, 2018
作者:
J
jipengfei-jpf
提交者:
GitHub
5月 25, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加web示例
上级
c0d01563
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
82 addition
and
0 deletion
+82
-0
README.md
README.md
+82
-0
未找到文件。
README.md
浏览文件 @
e1231bf8
...
...
@@ -84,6 +84,88 @@ public void test1() throws FileNotFoundException {
}
}
```
# web下载实例写法
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<List<String>> 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留言。其他技术非技术相关的也欢迎一起探讨。
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录