注意:

  导出的后缀是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/xvZalt9SH19mlLxLy5eAHgyFtoFACANpAdPB6QHTwekB08HpAdPB6QHT8eY0p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R+783l4cjqBtIrg/qJVEt/3DWPBcPtAml0MSr9cddE38JCegugfiIV0md6PKS3AOonUnXmVLLHQ3oLoH4iVOnvh5As09enIL0uqJ8ItiE4II0ukF4BSKMLpFcA0ugiJz1CJODZQKd3nNApVRGrH9I7II0ukF4BSKOLDemDbQjus/r4VSpIrwvqJ0IOkfhXZOM7iyG9MqifSMVJJN2fBySnzIH6iQwJkWA/vU1QP5HK/fTXbDjW9BZB/USGJKewprcJ6icySHqs6U2C+olAegek0cWe9P6S5rhr8EbWHqifSG1cMHODM0ivDOongm0IDkijC6RXANLoAukVgDS6yEmPEAl4NtDpHSd0SlXE6of0DkijC6RXANLoYkP64SeGTxJIo4sF6YOTSPxHIb1FUD+RyhDJfrNsGnR6m6B+IlUhkuOu2eyxvLEK6idSt/em2R2xpjcL6idCl36/ueyshPRWQf1EKm7Vff0TpLcK6idClL5/e3rcn94cqJ8IPqd3QBpdIL0CkEYXG9JXAul1Qf1EIL0D0ugC6RWANLrISY8QCXg20OkdJ3RKVcTqh/QOSKMLpFcA0uhiQ/rgI3nvbk+4VbdBUD+RmhCJ23+DTm8R1E+kIkQSv2srpDcD6idCD5Ek7toK6c2A+onU7KdfNk2D0wXtgvqJkKXvHDQVX91Del1QPxEcyuCANLpAegUgjS5i9f8fNN1cdv5pI6UAAAAASUVORK5CYII=" alt="" />

JXL导出Excel(只支持xls版本)——(一)的更多相关文章

  1. JXL读取Excel(只支持xls版本)——(二)

    注意:jxl是不支持xlsx后缀的excel的.因此建议用POI读取excel. Jar包 同一一样 Java代码 package JXL; import java.io.File; import j ...

  2. JXL导出Excel工具类

    将Excel中的数据读取到List<Map<String, Object>>集合中   package com.mvc.util;   import java.io.File; ...

  3. Java web项目JXl导出excel,(从eclipse上移动到tomact服务器上,之路径更改)

    我用的是jxl导出excel,比较简单,最开始我是固定路径不能选择,很局限,后来改了,而且固定路径当把项目放在服务器上时,路径不可行. 在网上各位大神的帮助成功设置响应头,并且可选保存路径. 1.前端 ...

  4. jxl导出Excel中需要跳过的的坑

    正如上篇文章(JXL封装不能使用static关键字问题)所说,在jxl导出Excel时候如果频繁使用到WritableCellFormat去设置单元格的样式,这个时候经常会出现两种情况: 1.报警告: ...

  5. jxl导出excel的问题

    jxl导出excel,通常浏览器会提示excel导出完成情况及默认保存路径,或让用户自定义选择保存路径,要达到这种效果,有些要做下修改,如:response是jsp的内置对象,在jsp中使用时不用声明 ...

  6. Java程序实现导出Excel,支持IE低版本

    来博客园两年多了,最近才开通了微博,因为懒所以也一直没有写东西,今天想整理一下自己前段时间遇到的一个导出的问题. 因为项目的需求,要做一部分导出功能.开始的时候用的公司的导出,但是很奇怪有部分模块导出 ...

  7. poi 和jxl导出excel(2)

    controller: /** * 导出报表 * @return */ @RequestMapping(value = "/export") @ResponseBody publi ...

  8. jxl导出Excel

    首先先在自己工程中导入jxl的jar包: 疯狂google后找到一段别人的导出excel方法,先备份于下面: import java.io.File; import java.io.FileOutpu ...

  9. JAVA利用JXL导出 EXCEL (在原有的excel模板上把数据导到excel上)

    添加依赖 <dependency> <groupId>net.sourceforge.jexcelapi</groupId> <artifactId>j ...

随机推荐

  1. Codeforces976E Well played! 【贪心】

    题目分析: 由于乘二的收获很大,所以我们可以证明乘的数一定是同一个,接着排序后依次选取,判断一下即可. 题目代码: #include<bits/stdc++.h> using namesp ...

  2. MT【17】利用柯西不等式求三角的最大值

    评:此题也可以设$1+cos\theta=t$,平方后变成$t$的单变量利用均值去做. 柯西平衡系数法其实就是待定系数法,利用等号取到的条件.

  3. 学习Spring Boot:(二十七)Spring Boot 2.0 中使用 Actuator

    前言 主要是完成微服务的监控,完成监控治理.可以查看微服务间的数据处理和调用,当它们之间出现了异常,就可以快速定位到出现问题的地方. springboot - version: 2.0 正文 依赖 m ...

  4. 洛谷 P1381 单词背诵 解题报告

    P1381 单词背诵 题目描述 灵梦有\(n\)个单词想要背,但她想通过一篇文章中的一段来记住这些单词. 文章由\(m\)个单词构成,她想在文章中找出连续的一段,其中包含最多的她想要背的单词(重复的只 ...

  5. 安装 Minio服务

    #MINIO SERVER Minio是在Apache License v2.0下发布的对象存储服务器.它与Amazon S3云存储服务兼容. 它最适合存储非结构化数据,如照片,视频,日志文件,备份和 ...

  6. luogu4187 [USACO18JAN]Stamp Painting (dp)

    可以发现,只要存在连续k个相同的,这个情况就一定是合法情况 然而这个不太好算,我们算不存在k个相同的,然后用$m^n$把它减掉 设f[i]为前i个,没有连续k个的 显然$f[i]=m^i ,i< ...

  7. A1036. Boys vs Girls

    This time you are asked to tell the difference between the lowest grade of all the male students and ...

  8. 使用iostat来对linux硬盘IO性能进行检测

    -x显示扩展统计数据 # 每隔1s显示6个统计数据 $ iostat -x 1 6 # 每隔1s显示磁盘sda的6个统计数据 $ iostat -x sda 1 6 # 每隔1s显示设备sda及其分区 ...

  9. #define 多行多语句

    #define DEBUG_ENABLE 1 #if DEBUG_ENABLE > 0 #define DEBUG_PORT UART_PORT2 #define DBG_BUF_LEN 512 ...

  10. MUI 拍照或选取照片上传作为头像

    1.第一种方法是用H5来实现的 HTML: <label> <input style="opacity: 0;" type="file" ac ...