Java Excel API——JXLÈëÃÅ
JXL(Java Excel API)ÊÇÒ»¸öÓÃÀ´¶¯Ì¬¶ÁдExcelÎļþµÄ¿ªÔ´¿ò¼Ü£¬ÀûÓÃËü¿ÉÒÔÔÚÈκÎÖ§³ÖJavaµÄ²Ù×÷ϵͳÉ϶¯Ì¬¶ÁдExcelÎļþ¡£JXLµÄÖ÷Ò³ÊÇ£ºhttp://www.andykhan.com/jexcelapi/£¬¿ÉÒÔÔÚÕâÀïÏÂÔص½ËüµÄ×îеİ汾¡£
Äã¿ÉÒÔ·Ö±ðͨ¹ýÈçÏÂÃüÁî
java -jar jxl.jar -xml test.xls
java -jar jxl.jar -cvs test.xls
ÒÔxmlºÍcvs¸ñʽ²é¿´test.xls£¬ÕâÊÇÒòΪJXL×÷ÕßʵÏÖÁËÒ»¸öÓÃÀ´ÑÝʾµÄjxl.demo.DemoµÄÀà¡£
µ±È»ÎÒÃÇʹÓÃJXLÖ÷ÒªÊÇÓÃËüÀ´¶¯Ì¬¶ÁдExcelÎļþ¡£ÏÖÔÚ¾ÍÀ´¿´¿´JXLÔÚ¶ÔExcelµÄ¶ÁºÍдÉ϶¼ÌṩÁËÄÇЩ֧³Ö¡£
ÏÈÀ´¿´¿´ExcelÎļþÖж¼ÓÐдÉÏÃæ¶ÔÏó
1 Îļþ¶ÔÏó 2¹¤×÷²¾¶ÔÏó 3 µ¥Ôª¸ñ¶ÔÏó¡£
ÏàÓ¦µÄÔÚJXLÖоÍÓÐWorkbook£¬Sheet £¬Cell ¡£Í¨¹ýÕâÈý¸ö¶ÔÏóÎÒÃǾͿÉÒÔʵÏÖExcelÎļþµÄ¶ÁÈ¡¹¤×÷¡£
ÎÒÃÇÏÈÏëÏëһ϶ÁÈ¡²½Ö裬²»¹ÜÊÇʲôÑùµÄExcel²Ù×÷¿ò¼Ü±Ø¶¨¶¼Òª¾Àú
1Ñ¡È¡ExcelÎļþ£¬2Ñ¡Ôñ¹¤×÷²¾£¬3Ñ¡ÔñCell£¬4¶ÁÈ¡ÐÅÏ¢¡£
ÄÇôÏÖÔھͿÉÒÔ¿´¿´JXLÖÐÕâËIJ½ÖèÈçºÎÌåÏÖ£º
//ͨ¹ýWorkbookµÄ¾²Ì¬·½·¨getWorkbookÑ¡È¡ExcelÎļþ
Workbook workbook = Workbook.getWorkbook(new File("myfile.xls"));
//ͨ¹ýWorkbookµÄgetSheet·½·¨Ñ¡ÔñµÚÒ»¸ö¹¤×÷²¾£¨´Ó0¿ªÊ¼£©
Sheet sheet = workbook.getSheet(0);
//ͨ¹ýSheet·½·¨µÄgetCell·½·¨Ñ¡ÔñλÖÃΪC2µÄµ¥Ôª¸ñ£¨Á½¸ö²ÎÊý¶¼´Ó0¿ªÊ¼£©
Cell c2 = sheet.getCell(2,1);
//ͨ¹ýCellµÄgetContents·½·¨°Ñµ¥Ôª¸ñÖеÄÐÅÏ¢ÒÔ×Ö·ûµÄÐÎʽ¶ÁÈ¡³öÀ´
String stringc2 = c2.getContents();
¿ÉÒÔ¿´µ½ÕýÊǸղÅËù˵µÄËĸö²½Öè¡£
ÎÒÃǶ¼ÖªµÀExcelµ¥Ôª¸ñÊÇÓиñʽµÄ£¬ÄÇôÕâЩÐÅÏ¢ÈçºÎÈ¡µÃ¡£
CellÌṩÁËÒ»¸ögetType·½·¨Äܹ»·µ»Øµ¥Ôª¸ñµÄÀàÐÍÐÅÏ¢£¬Í¬Ê±JXLÌṩÁËÒ»¸öCellTypeÀàÓÃÀ´Ô¤ÉèExcelÖеÄÀàÐÍÐÅÏ¢£¬¶øÇÒJXLÌṩÁËһЩCellÀàµÄ×ÓÀàÓÃÀ´·Ö±ðÓÃÀ´±íʾ¸÷ÖÖÀàÐ͵ĵ¥Ôª¸ñ£¬ÈçLabelCell£¬NumberCell£¬DateCell·Ö±ð±íʾ×Ö·û¡¢ÊýÖµ¡¢ÈÕÆÚÀàÐ͵ĵ¥Ôª¸ñ¡£ËùÒÔÎÒÃÇ¿ÉÒÔÕâÑùд£º
if (c2.getType() == CellType.NUMBER)
{
NumberCell nc = (NumberCell) c2;
numberb2 = nc.getValue();
}
×îºó²»ÒªÍü¼Ç¹Ø±ÕworkbookÒÔÊÍ·Å×ÊÔ´£º
workbook.close();
ÏÖÔÚ×ܽáÒ»ÏÂ:Èý¸ö¶ÔÏó£¬Ëĸö²½Ö裬עÒâ¸ñʽ¡£¾Í¿ÉÒÔÇáËɵĴÓExcelÎļþÖжÁÈ¡Êý¾Ý¡£
Ïà¹ØÎĵµ£º
import javax.swing.JOptionPane;
public class San {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
&n ......
java²»½öÊDZà³ÌÓïÑÔ£¬»¹ÊÇÒ»¸ö¿ª·¢Æ½Ì¨£¬java¼¼Êõ¸ø³ÌÐòÔ±ÌṩÁËÐí¶à¹¤¾ß£º±àÒëÆ÷¡¢½âÊÍÆ÷¡¢ÎĵµÉú³ÉÆ÷ºÍÎļþ´ò°ü¹¤¾ßµÈµÈ¡£Í¬Ê±java»¹ÊÇÒ»¸ö³ÌÐò·¢²¼Æ½Ì¨£¬ÓÐÁ½ÖÖÖ÷ÒªµÄ"·¢²¼»·¾³"£¬Ê×ÏÈjavaÔËÐÐʱ»·¾³£¨java runtime environment£¬¼ò³ÆJRE£©°üº¬ÁËÍêÕûµÄÀàÎļþ°ü£¬Æä´ÎÐí¶àÖ÷ÒªµÄä¯ÀÀÆ÷¶¼ÌṩÁËjava½âÊÍÆ÷ºÍÔËÐÐʱ»·¾³¡£Ä ......
½üÆÚµÄÒ»¸öÏîÄ¿ÐèҪʵÏÖÉãÏñͷͼÏñ²É¼¯£¬¾¹ýһϵÁеÄÕÛÌÚÒÔºó£¬ÖÕÓÚʵÏÖÁËÕâ¸ö¹¦ÄÜ£¬ÏÖÕûÀíһϡ£
±¾Éí¾Íjava¼¼ÊõÀ´Ëµ£¬ÒªÊµÏÖÉãÏñÍ·¶þ´Î¿ª·¢£¬²É¼¯ÉãÏñͷͼƬ£¬ÐèҪʹÓõ½JMF£¬JMFÊʺÏʹÓÃÔÚj2se³ÌÐòµ±ÖУ¬ÎÒÐèÒªÔÚweb³ÌÐòÖе÷ÓÃÉãÏñÍ·£¬ºÜÃ÷ÏÔJMFÊǸ㲻¶¨ÁË£¬Ïë¹ýдһ¸öapplet³ÌÐò£¬Ö»ÊÇÄǶ«Î÷ÒªÇó¿Í»§¶Ë±ØÐëÒªÓÐjre»·¾ ......
1. ¼òµ¥¹¤³§:
(1). ´´½¨Êä³ö(Output)½Ó¿Ú
package stone;
public interface Output {
public int MAX_COUNT =10; // ×î¶à¿É´òÓ¡¶àÉÙÌõ¼Ç¼
public void show(); ......
// ¼òÒ×JAVA»ñÈ¡ÍøÒ³ÓÐЧÓÊÏäµØÖ· ---by 77
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.io.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class solo7 {
public static void main(String args[]){
  ......