JXL导出Excel(只支持xls版本)——(一)
注意:
导出的后缀是xls可以直接打开,如果导出的后缀是xlsx打开报错,需要手动将名字改为xls才可以打开。也就是JXL不可以导出xlsx的excel。
Jar包
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAANsAAAAbCAIAAAB6CW2jAAADaElEQVR4nO2bz0/TUBzA+wd48+bBk+GE8eBFm3g3XLwtEJ0mSioH4gHRZOAILsicYaQJEw4LGEgUYpCNxDVmZCEjgHLDwEyhbKxsrHS8QZOuGucMHmZn1/FDXjbSdN9PvtleXvvte4dP3tte3yMOTs/i4+vlsVbK9va2IAgcx91qfa7P52iSoBiMhv+fM2gCqA4ERk6Yqv/W16CNMFX/yP1OG+l0GiG0ubl5k3qmS+dokiBprhK9P4ozaAKoEjhGzjReLA+hjHQ6/d4fsLQ79U1WdfRiKIIgqtsEUE1wjPSHFprt7ht32k6MZrvbH1qoeKcBE4NjJABUDzASMBZgJGAswEjAWOAYyfLi9PzKm8CXE2N6foXlxYp3GjAxOEb6wsuR9ZiiKD/KyGazxbKiKJH1mC+8XPFOAyYGx8jBydlMJpPP539ryOfz2WxWWpvP5XLFmkwmMzg5q88/bv2aoXRLibDYXWPgGEmPBxFCvzTkcjlZljMzfaj/mqIoxXqEED0e1OeDkcDR4BjpGg2IovhTgyRJ6U+u3Rd1+/v7u1+DiqIU6kVRdI0GTvPsMiOBGgPHSIfXJwjCdxVZlndCHrHrgiAIOx8d6Z46WZYLlwRBcHh9p3k2GFnr4BjZ6ZlIJpOyiiRJYsf5wmehIElS4VIymez0TOjz1Y05HE0WX0AzVKF46Kyt1nA0SfxFW0UxDEUQMLebAxwj291jPM9LKggh8dVVnud3npxDCCGEEolEKpXa29vjeb7dPabP10jGUARJc+rXwbFGcjSlOqf6q0oKw6p5wDGyoeeDNqLRaCwWSzouxf3dsVgskUg8pd+6Rqa2trY2NjZanV59fsnmxcJeHVLj2tFj5CGjJGyENBs4Rl5+4NGG1T7U0jt8u/N1U4enpXfYOxlMpVJNHZ6XIz6WZZu7Pfp8PCM5mizepx04wUhzgWOk1dZvHb+vDWZuiZlb8ocW/aHPLBdlWfZe15BrxBeJRKy2fn1+2aytWeFRjSxWFW/+N7Nrf4CCkWYDx0hLm/PKoEUbjbaBJttAo23gYY83Ho/ftQ86h6fi8fjq6qqlTb9jt2gRQ5UMeiX/bMqN1MzYJEXBGGlWcIw803M2oFyNYfRzNvDKptYw8DkbODFTk8A5G8BYwI5dwFiAkYCxACMBY/EHizXdEbyb9vIAAAAASUVORK5CYII=" alt="" />
Java代码
package JXL;
import java.io.File;
import java.io.IOException; import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook; /**
* JXL导出excel
* @author: qlq
* @date : 2017年7月14日下午9:08:40
* @description:
*/
public class JXLExcel { public static void main(String[] args) throws Exception {
// 数组用于存放标题
String[] title = {"id","name","sex"};
File file = new File("E:/JXL_TEST.xls");
try {
file.createNewFile();
// 创建工作簿
WritableWorkbook workbook = Workbook.createWorkbook(file);
// 创建sheet页,0代表索引
WritableSheet sheet = workbook.createSheet("sheet 1", 0);
// 在第一行列入列的名称
Label label=null;
for(int i=0;i<title.length;i++){
// i代表第几列,0代表第一行。后面是插入的数据
label = new Label(i,0,title[i]);
sheet.addCell(label);
}
// 插入数据
for(int i=1;i<10;i++){
// 第一个参数是列号。第二个是行号
label = new Label(0,i,"a"+i);
sheet.addCell(label);
label = new Label(1,i,"user"+i);
sheet.addCell(label);
label = new Label(2,i,"男");
sheet.addCell(label);
}
// 写入数据
workbook.write();
workbook.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
结果:
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPwAAAERCAIAAADQZF3YAAASZUlEQVR4nO2dS44btxaGtZU70SK0gDurbWgBuhsRoGV4KECJkcRIYjgxHBhOIiWBoyDwFnoFdQd6kMXi47BU51Gl/xvZalt9SH19mlLxLy5eAHgyFtoFACANpAdPB6QH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VB/UQqQiTBLwFIbw3UT6R+783l4cjqBtIrg/qJVEt/3DWPBcPtAml0MSr9cddE38JCegugfiIV0md6PKS3AOonUnXmVLLHQ3oLoH4iVOnvh5As09enIL0uqJ8ItiE4II0ukF4BSKMLpFcA0ugiJz1CJODZQKd3nNApVRGrH9I7II0ukF4BSKOLDemDbQjus/r4VSpIrwvqJ0IOkfhXZOM7iyG9MqifSMVJJN2fBySnzIH6iQwJkWA/vU1QP5HK/fTXbDjW9BZB/USGJKewprcJ6icySHqs6U2C+olAegek0cWe9P6S5rhr8EbWHqifSG1cMHODM0ivDOongm0IDkijC6RXANLoAukVgDS6yEmPEAl4NtDpHSd0SlXE6of0DkijC6RXANLoYkP64SeGTxJIo4sF6YOTSPxHIb1FUD+RyhDJfrNsGnR6m6B+IlUhkuOu2eyxvLEK6idSt/em2R2xpjcL6idCl36/ueyshPRWQf1EKm7Vff0TpLcK6idClL5/e3rcn94cqJ8IPqd3QBpdIL0CkEYXG9JXAul1Qf1EIL0D0ugC6RWANLrISY8QCXg20OkdJ3RKVcTqh/QOSKMLpFcA0uhiQ/rgI3nvbk+4VbdBUD+RmhCJ23+DTm8R1E+kIkQSv2srpDcD6idCD5Ek7toK6c2A+onU7KdfNk2D0wXtgvqJkKXvHDQVX91Del1QPxEcyuCANLpAegUgjS5i9f8fNN1cdv5pI6UAAAAASUVORK5CYII=" alt="" />
JXL导出Excel(只支持xls版本)——(一)的更多相关文章
- JXL读取Excel(只支持xls版本)——(二)
注意:jxl是不支持xlsx后缀的excel的.因此建议用POI读取excel. Jar包 同一一样 Java代码 package JXL; import java.io.File; import j ...
- JXL导出Excel工具类
将Excel中的数据读取到List<Map<String, Object>>集合中 package com.mvc.util; import java.io.File; ...
- Java web项目JXl导出excel,(从eclipse上移动到tomact服务器上,之路径更改)
我用的是jxl导出excel,比较简单,最开始我是固定路径不能选择,很局限,后来改了,而且固定路径当把项目放在服务器上时,路径不可行. 在网上各位大神的帮助成功设置响应头,并且可选保存路径. 1.前端 ...
- jxl导出Excel中需要跳过的的坑
正如上篇文章(JXL封装不能使用static关键字问题)所说,在jxl导出Excel时候如果频繁使用到WritableCellFormat去设置单元格的样式,这个时候经常会出现两种情况: 1.报警告: ...
- jxl导出excel的问题
jxl导出excel,通常浏览器会提示excel导出完成情况及默认保存路径,或让用户自定义选择保存路径,要达到这种效果,有些要做下修改,如:response是jsp的内置对象,在jsp中使用时不用声明 ...
- Java程序实现导出Excel,支持IE低版本
来博客园两年多了,最近才开通了微博,因为懒所以也一直没有写东西,今天想整理一下自己前段时间遇到的一个导出的问题. 因为项目的需求,要做一部分导出功能.开始的时候用的公司的导出,但是很奇怪有部分模块导出 ...
- poi 和jxl导出excel(2)
controller: /** * 导出报表 * @return */ @RequestMapping(value = "/export") @ResponseBody publi ...
- jxl导出Excel
首先先在自己工程中导入jxl的jar包: 疯狂google后找到一段别人的导出excel方法,先备份于下面: import java.io.File; import java.io.FileOutpu ...
- JAVA利用JXL导出 EXCEL (在原有的excel模板上把数据导到excel上)
添加依赖 <dependency> <groupId>net.sourceforge.jexcelapi</groupId> <artifactId>j ...
随机推荐
- 【BZOJ2434】【NOI2011】阿狸的打字机(AC自动机,树状数组)
[BZOJ2434]阿狸的打字机(AC自动机,树状数组) 先写个暴力: 每次打印出字符串后,就插入到\(Trie\)树中 搞完后直接搭\(AC\)自动机 看一看匹配是怎么样的: 每次沿着\(AC\)自 ...
- 一个简单的mock server
在前后端分离的项目中, 前端无需等后端接口提供了才调试, 后端无需等第三方接口提供了才调试, 基于“契约”,可以通过mock server实现调试, 下面是一个简单的mock server,通过pyt ...
- [Cqoi2014]数三角形——组合数
Description: 给定一个nxm的网格,请计算三点都在格点上的三角形共有多少个.下图为4x4的网格上的一个三角形. 注意三角形的三点不能共线. Hint: 1<=m,n<=1000 ...
- 【POJ3585】Accumulation Degree 二次扫描与换根法
简单来说,这是一道树形结构上的最大流问题. 朴素的解法是可以以每个节点为源点,单独进行一次dp,时间复杂度是\(O(n^2)\) 但是在朴素求解的过程中,相当于每次都求解了一次整棵树的信息,会做了不少 ...
- html5的data-*属性,我们一起认识下
html5的data-自定义属性出来很久了,我们一起认识一下. 比如如下一个代码,我们怎么取到对应的name,对应的age? 既然data-*自定义属性是它的一个属性,这个时候就可以用getAttri ...
- Windows下安装Python扩展模块提示“Unable to find vcvarsall.bat”的问题
本文内容 Unable to find vcvarsall.bat的问题描述 问题分析 总结 提示: 如果你只是想知道自己需要安装哪个版本的Visual Studio请直接查看本文最后一个小节的内容. ...
- Codeforces Round #419 (Div. 2)(B)差分数组
传送门:Problem B https://www.cnblogs.com/violet-acmer/p/9721160.html 题意: Karen有n个关于煮咖啡的食谱,每个食谱都有个煮咖啡的最适 ...
- HTTP Status 405 - HTTP method POST is not supported by this URL
出现这个问题, 1.在servlet中没有调用post()方法引起的 2.在serlvet中跳转没有用外跳(response.sendRedirect()) 我的是因为第一种,是没有写dopost() ...
- oracle使用using关键字
oracle使用using关键字sql/92标准可以使用using关键字来简化连接查询,但是只是在查询满足下面两个条件时,才能使 用using关键字进行简化.1.查询必须是等值连接.2.等值连接中的列 ...
- go 练习
1.判断 101-200 之间有多少个素数,并输出所有素数 定义:为在大于1的自然数中,除了1和它本身以外不再有其他因数的数称为质数. package main import ( "fmt& ...