发布时间:2024-09-07 14:01
@IgnoreAuth
@RequestMapping(\"/test3\")
@ResponseBody
public Map<String,Object> test3() throws IOException, InterruptedException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
ExcelWriter writer = new ExcelWriter(out, ExcelTypeEnum.XLSX);
// 设置SHEET
Sheet sheet = new Sheet(1, 0);
sheet.setSheetName(\"sheet1\");
// 设置标题
Table table = new Table(1);
List<List<String>> titles = new ArrayList<>();
titles.add(Arrays.asList(\"用户ID\"));
titles.add(Arrays.asList(\"名称\"));
titles.add(Arrays.asList(\"年龄\"));
titles.add(Arrays.asList(\"生日\"));
table.setHead(titles);
// 查询数据导出即可 比如说一次性总共查询出100条数据
List<List<String>> userList = new ArrayList<>();
for (int i = 0; i < 100; i++) {
userList.add(Arrays.asList(\"ID_\" + i, \"小明\" + i, String.valueOf(i), new Date().toString()));
}
writer.write0(userList, sheet, table);
writer.finish();
String url = OSSFactory.build().upload(new ByteArrayInputStream(out.toByteArray()),\"orderData/5.xlsx\");
return toResponsOK(url);
}
@IgnoreAuth
@RequestMapping(\"/test3\")
@ResponseBody
public Map<String,Object> test3() throws IOException, InterruptedException {
//OutputStream out = new FileOutputStream(\"E:\\\\user.xlsx\");
OutputStream out = new FileOutputStream(request.getServletContext().getRealPath(\"/\")+\"user.xlsx\");
ExcelWriter writer = new ExcelWriter(out, ExcelTypeEnum.XLSX);
// 设置SHEET
Sheet sheet = new Sheet(1, 0);
sheet.setSheetName(\"sheet1\");
// 设置标题
Table table = new Table(1);
List<List<String>> titles = new ArrayList<>();
titles.add(Arrays.asList(\"用户ID\"));
titles.add(Arrays.asList(\"名称\"));
titles.add(Arrays.asList(\"年龄\"));
titles.add(Arrays.asList(\"生日\"));
table.setHead(titles);
// 查询数据导出即可 比如说一次性总共查询出100条数据
List<List<String>> userList = new ArrayList<>();
for (int i = 0; i < 100; i++) {
userList.add(Arrays.asList(\"ID_\" + i, \"小明\" + i, String.valueOf(i), new Date().toString()));
}
writer.write0(userList, sheet, table);
writer.finish();
return toResponsOK(\"OK\");
}
@IgnoreAuth
@RequestMapping(\"/test3\")
@ResponseBody
public Map<String,Object> test3(HttpServletResponse response) throws IOException, InterruptedException {
ExcelWriter writer = new ExcelWriter(response.getOutputStream(), ExcelTypeEnum.XLSX);
// 设置SHEET
Sheet sheet = new Sheet(1, 0);
sheet.setSheetName(\"sheet1\");
// 设置标题
Table table = new Table(1);
List<List<String>> titles = new ArrayList<>();
titles.add(Arrays.asList(\"用户ID\"));
titles.add(Arrays.asList(\"名称\"));
titles.add(Arrays.asList(\"年龄\"));
titles.add(Arrays.asList(\"生日\"));
table.setHead(titles);
// 查询数据导出即可 比如说一次性总共查询出100条数据
List<List<String>> userList = new ArrayList<>();
for (int i = 0; i < 100; i++) {
userList.add(Arrays.asList(\"ID_\" + i, \"小明\" + i, String.valueOf(i), new Date().toString()));
}
writer.write0(userList, sheet, table);
writer.finish();
return toResponsOK(\"OK\");
}
罗永浩宣布退网创业;谷歌研究员“走火入魔”事件曝光:认为AI已具备人格,被罚带薪休假;Wasmer 2.3 发布|极客头条
展锐S 上微距模式不识别问题跟进 --- sensor_config的解析
python内置变量__name___一文搞懂python内置变量__name__ __doc__ 正确理解if __name__ == '__main__' 看这篇就够了...
交换机与路由器技术:远程管理交换机和路由器工作原理、路由器转发数据包的封装过程
Python pandas DataFrame基础运算及空值填充详解
c语言大作业是什么意思,高分悬赏C语言作业!!!!!急!!!!!