首先,请到 [url]http://www.andykhan.com/jexcelapi/index.html[/url]下载java excel api,主页上同时有比较详细的介绍。最新版本为2.4.3,同时也可以到: [url]http://www.andykhan.com/jexcelapi/jexcelapi_2_4_3.tar.gz[/url]下载到该最新版的API,由于该项目是开源的,所以下载的文件中已经包含了源代码,同样的,文件中也有javadoc,大家在开发中可以参考javadoc。
下载完毕后,我们需要把文件中的jxl.jar加入到你的开发classpath中。
下图是现在要生产的excel截图:
[url]http://blog.csdn.net/beming/gallery/p_w_picpath/3437.aspx[/url]
代码如下:
    File excel = new File("d:/aming.xls");
    if(!excel.exists()){
     excel.createNewFile();
    }   
    WritableWorkbook wwb = Workbook.createWorkbook(excel);
    WritableSheet ws = wwb.createSheet("testexcel",0);
    Label lable = null;
   
    //对中文的支持非常好
    lable = new Label(0,0,"我的中国心");
    ws.addCell(lable);
   
    //可以定义模板格式化你的cell
    WritableFont wf = new WritableFont(WritableFont.ARIAL,10,WritableFont.NO_BOLD,false,UnderlineStyle.NO_UNDERLINE, Colour.BLACK);
    WritableCellFormat wcf = new WritableCellFormat(wf);
    wcf.setBackground(Colour.WHITE);
    lable = new Label(0,1,"fdsl",wcf);
    ws.addCell(lable);
   
    wf = new WritableFont(WritableFont.TIMES,18,WritableFont.BOLD,true);
    wcf = new WritableCellFormat(wf);
    lable = new Label(0,2,"aming",wcf);
    ws.addCell(lable);
   
    //cell的类型同样可以定义为数字类型
    Number nb = new Number(0,3,21.4321321);
    ws.addCell(nb);
   
    //支持格式化你的数字串
    NumberFormat nf = new NumberFormat("#.###");
    wcf = new WritableCellFormat(nf);
    nb = new Number(0,4,21.43254354354354,wcf);
    ws.addCell(nb);
    //cell的类型可以为boolean类型
    Boolean bl = new Boolean(0,5,true);
    ws.addCell(bl);
    //cell的类型同样可以为日期,时间
    DateTime dt = new DateTime(0,6,new Date());
    ws.addCell(dt);
    //并且可以很好格式化你的日期格式
    DateFormat df = new DateFormat("MM dd yyyy hh:mm:ss");
    wcf = new WritableCellFormat(df);
    dt = new DateTime(0,7,new Date(),wcf);
    ws.addCell(dt);
   
    //开始写文件了
    wwb.write();
    wwb.close();

上面的下载地址无法打开.
下载请到:[url]http://prdownloads.sourceforge.net/jexcelapi[/url]