首 页 ASP ASP.NET PHP JSP Ajax DIV+CSS JavaScript XML C#
MySQL MSSQL Access Oracle Linux Server 电脑技巧 网络安全 建站经验 其它

Java操作Excel的一种方法(JXL)

整理日期:2007年05月14日 【字体:


伊图教程网[www.etoow.com]
http://www.etoow.com/html/2007-05/1179109744.html

//生成excel的类
import java.io.*;
import jxl.*;
import jxl.write.*;

public class createxls
{
public static void main(string args[])
{
try
{
//打开文件
writableworkbook book=
workbook.createworkbook(new file(“测试.xls”));

//生成名为“第一页”的工作表,参数0表示这是第一页
writablesheet sheet=book.createsheet(“第一页”,0);

//在label对象的构造子中指名单元格位置是第一列第一行(0,0)
//以及单元格内容为test
label label=new label(0,0,”test”);

//将定义好的单元格添加到工作表中
sheet.addcell(label);

/*生成一个保存数字的单元格
必须使用number的完整包路径,否则有语法歧义
单元格位置是第二列,第一行,值为789.123*/
jxl.write.number number = new jxl.write.number(1,0,789.123);
sheet.addcell(number);

//写入数据并关闭文件
book.write();
book.close();

Tags:
Java操作Excel的一种方法(JXL)
'http://www.etoow.com/html/2007-05/1179109744.html
1
 
23
信息搜索
  
联系我们关于本站广告服务设为首页 收藏本站友情链接网站地图
Copyright © Etoow.com Inc. All Rights Reserved