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ÓïÑԵijöÏÖÒ²ÑéÖ¤ÁËÕâÒ»µã¡£1991Ä꣬ÃÀ¹úSun Microsystems¹«Ë¾µÄij¸öÑо¿Ð¡×éΪÁËÄܹ»ÔÚÏû·Ñµç×Ó²úÆ·ÉÏ¿ª·¢Ó¦ÓóÌÐò£¬»ý¼«Ñ°ÕÒºÏÊʵıà³ÌÓïÑÔ¡£Ïû·Ñµç×Ó²úÆ·ÖÖÀà·±¶à£¬°üÀ¨PDA¡¢»ú¶¥ºÐ¡¢ÊÖ»úµÈµÈ£¬¼´Ê¹ÊÇͬһÀàÏû·Ñµç×Ó²úÆ·Ëù²ÉÓõĴ¦ÀíоƬºÍ²Ù×÷ϵͳҲ²»Ïàͬ£¬Ò²´æÔÚ×Å¿ ......
4£® ¸ßÐÔÄÜ
¡¡¡¡ËäÈ»javaÊǽâÊÍÖ´Ðеģ¬µ«ËüÈÔÈ»¾ßÓзdz£¸ßµÄÐÔÄÜ£¬ÔÚһЩÌض¨µÄCPUÉÏ£¬java×Ö½ÚÂë¿ÉÒÔ¿ìËÙµÄת»»³ÉΪ»úÆ÷Âë½øÐÐÖ´ÐС£¶øÇÒjava×Ö½ÚÂë¸ñʽµÄÉè¼Æ¾ÍÊÇÕë¶Ô»úÆ÷ÂëµÄת»»£¬Êµ¼Êת»»Ê±Ï൱¼ò±ã£¬×Ô¶¯µÄ¼Ä´æÆ÷·ÖÅäÓë±àÒëÆ÷¶Ô×Ö½ÚÂëµÄһЩÓÅ»¯¿Éʹ֮Éú³É¸ßÖÊÁ¿µÄ´úÂë¡£Ëæ×ÅjavaÐéÄâ»úµÄ¸Ä½øºÍ"¼´Ê±±àÒë"£¨just in ......
1. ¼òµ¥¹¤³§:
(1). ´´½¨Êä³ö(Output)½Ó¿Ú
package stone;
public interface Output {
public int MAX_COUNT =10; // ×î¶à¿É´òÓ¡¶àÉÙÌõ¼Ç¼
public void show(); ......
²»¹ÜÄãÐŲ»ÐÅ£¬¼´Ê¹¶àôÊìÁ·±à³ÌµÄÈËÔ±ÔÚcodingµÄʱºò¶¼»á³öÏÖÒâÏë²»µ½µÄbug¡£ÔÚÉÏƪÎÄÕÂÖÐÎÒÔøÌáµ½£¬bugµÄÔì³ÉÊǶà¸ö·½ÃæµÄ×ۺϽá¹û£¬ÓÐЩbugÊÇ¿ÉÒÔÐÞ¸´µÄ£¬µ«ÊÇÓÐЩÂß¼ÉϵÄbugÒªÐÞ¸´¿É²»ÊÇÄÇôÈÝÒ×µÄÊÂÇ飬¾ÍÏñÎÒÃÇ×ö´íÁËÒ»¼þÊÂÇ飬Èç¹û²»È¥´Ó¸ù±¾ÉϸÄÕý¾Í»á·¸¸ü´óµÄ´íÎóÒ»Ñù£¬ÓÐʱºòbugÒ²ÊÇÒ»¸ö»ýÀ ......