java导入导出excel操作(jxl)
关键字: java excel jxl.jar
jxl.jar 包
下载地址:
真实下载地址:
网站上对它的特征有如下描述:
● 支持Excel 95-2000的所有版本
● 生成Excel 2000标准格式
● 支持字体、数字、日期操作
● 能够修饰单元格属性
● 支持图像和图表
应该说以上功能已经能够大致满足我们的需要。最关键的是这套API是纯Java的,并不依赖Windows系统,即使运行在Linux下,它同样能够正确的处理Excel文件。另外需要说明的是,这套API对图形和图表的支持很有限,而且仅仅识别PNG格式。
搭建环境
将下载后的文件解包,得到jxl.jar,放入classpath,安装就完成了。
基本操作
一、创建文件
拟生成一个名为“测试数据.xls”的Excel文件,其中第一个工作表被命名为“第一页”,大致效果如下:
Java代码
/*
* Created on Dec 30, 2007
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package JExcelTest.standard;
import java.io.*;
import jxl.*;
import jxl.write.*;
/**
* @author Ken
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class CreateXLS {
public static void main(String[] args) {
try {
//open file.
WritableWorkbook book = Workbook.createWorkbook(new File("d:/Test.xls"));
//create Sheet named "Sheet_1". 0 means this is 1st page.
WritableSheet sheet = book.createSheet("Sheet_1", 0);
//define cell column and row in Label Constructor, and cell content write "test".
//cell is 1st-Column,1st-Row. value is "test".
Label label = new Label(0, 0, "test");
//add defined cell above to sheet instance.
sheet.addCell(label);
//create cell using add numeric. WARN:necessarily use integrated package-path, otherwise will be throws path-error.
//cell is 2nd-Column, 1st-Row. value is 789.123.
jxl.write.Number number = new jxl.write.Number(1, 0, 789.123);
//add defined cell above to sheet instance.
sheet.addCell(number);
//add defined all cell above to case.
book.write()
相关文档:
1、http://java.sun.com/
(英文)
Sun的Java网站,是一个应该经常去看的地方。不用多说。
2、http://www-900.ibm.com/developerWorks/cn/
IBM的developerWorks网站,英语好的直接去英文主站点看。这里不但是一个极好的面向对象的分析设计网站,也是WebServices,Java,Linux极好的网站。强烈推荐!!!
3、http://www.j ......
从JAVA直接读取EXCEL、WORD并生成PDF文件
1。操作EXCEL和WORD文件
使用JAVA从EXCEL、WORD文件中读写数据,可以使用http://jexcelapi.sourceforge.net/
提供的JAVA API-Java Excel API,这里有其指南http://www.andykhan.com/jexcelapi/tutorial.html
,可由此下载JAR文件http://www.andykhan.com/jexcelapi/download.h ......
Java集群之session共享解决方案
来源:http://blog.csdn.net/crskyp/archive/2009/11/19/4836685.aspx
随着互联网的日益壮大,网站的pv和uv成线性或者指数倍的增加.单服务器单数据库早已经不能满足实际需求.比如像盛大,淘宝这样的大型网络公司,更是如此.
集群,也就是让一组计算机服务器协同工作 ......
Java文件下载的几种方式
< type="text/javascript">
document.body.oncopy = function() {
if (window.clipboardData) {
setTimeout(function() {
var text = cli ......
import java.text.Format;
import java.text.SimpleDateFormat;
File file = new File("a.txt");
long time = file.lastModified();
Date d = new Date(time);
Format simpleFormat = new SimpleDateFormat("E dd MMM yyyy hh:mm:ss a");
String dateString = simpleFormat.format(d);
System.err.println(file.getN ......