Java Éú³É EXCEL POIÎĵµËµÃ÷
Java Éú³É EXCEL POIÎĵµËµÃ÷
POI°æ±¾:3.0.2-FINAL
ÏÂÔصØÖ·: http://poi.apache.org/index.html
Ò»°ãÔÚÏîÄ¿ÖÐÕæÕýҪʵÏÖÕâÑùÒ»¸ö±í¸ñµÄʱºò£¬ÀýÈçÏîÄ¿ÐèÒªÖÆ×÷±¨±íµÈµÈ£¬Í¨³£µÄ×ö·¨¶¼ÊÇÊÂÏȰѸñʽһÇеĶ«Î÷¶¼ÊÖ¶¯ÖÆ×÷ºÃ£¨Õâ¸ö×öºÃÁ˵ÄÎļþÔÚʵ¼ÊµÄÏîÄ¿ÀïÎÒÃdzÆ֮Ϊ“Êý¾ÝÄ£°å”£¬¼ò³Æ“Ä£°å”£©£¬È»ºóÔÚJavaÓ¦ÓÃÖÐÊʵ±µÄʱ»ú°ÑÕâ¸öÎļþ¶Á½øÀ´Ð޸ģ¬×îºóÔÙÁí´æµ½Ö¸¶¨µÄλÖûòÕß´«µÝ¸øÏÂÒ»¸ö´¦ÀíÕߣ¨ÀýÈçÒÔÁ÷µÄ·½Ê½Ë͸øServletµÈµÈ£©£¬ÕâÑùÆäʵPOI¾ßÌå×öµÄÊÂÇé¾ÍÊÇÏòÄ£°åÀïдҵÎñµÄÊý¾Ý£¬»¹ÊǺܷ½±ã¿ì½ÝµÄ¡£
Ò»POI ¶ÁÈ¡Excel »ù±¾¹¤×÷
1. // Ö¸¶¨Òª¶ÁÈ¡µÄÎļþ£¬±¾ÀýʹÓÃÉÏÃæÉú³ÉµÄhelloworld.xls
FileInputStream readFile = new FileInputStream("c:/ceshi.xls");
// ´´½¨Ò»¸öWorkBook£¬´ÓÖ¸¶¨µÄÎļþÁ÷Öд´½¨£¬¼´ÉÏÃæÖ¸¶¨Á˵ÄÎļþÁ÷
HSSFWorkbook wb = new HSSFWorkbook(readFile);
// »ñÈ¡Ãû³ÆΪ“²âÊÔÒ³”µÄsheet
// ×¢Ò⣬Èç¹û²»ÄÜÈ·¶¨¾ßÌåµÄÃû³Æ£¬¿ÉÒÔÓÃgetSheetAt(int)·½·¨È¡µÃSheet
//HSSFSheet st = wb.getSheet("²âÊÔÒ³");
HSSFSheet st = wb.getSheetAt(0);
//´´½¨Ñùʽ±í£¬Ñùʽ±í¿ÉÒÔÉèÖõ¥Ôª¸ñµÄһЩÊôÐÔ ±ÈÈç±³¾°É«,Ëø¶¨×´Ì¬,ÐÐÁпí¸ßµÈ
HSSFCellStyle normalStyle = wb.createCellStyle();
//ÒÔÏÂÁз½Ê½´æ´¢µ±Ç°µ¥Ôª¸ñÑùʽ
µ¥Ôª¸ñ¶ÔÏó.setCellStyle(normalStyle);
¶þÉèÖÃÄ£°åÓ뽨Á¢ÐкÍÁÐ
1. Èç¹ûÔ¤ÏȵÄÄ£°åÓÐÄÚÈݵĻ°,ÔÚ²Ù×÷µÄʱºòÔòÖ»ÐèÒª¶ÁÈ¥µ±Ç°µ¥Ôª¸ñµÄÄÚÈÝÒÔ¼°Ñùʽ£¬»òÕß¿ÉÒÔÖØж¨Òå¡£(Èç¹ûûÓÐÄÚÈÝ,ÓÖÏëÒÔ¶ÁÈ¥µÄ·½Ê½À´»ñÈ¡ExcelµÄ»°£¬ÐèÒªÊÖ¶¯³õʼ»¯Ä£°å£¬Èç¸øÄ£°åÖÐÐèÒªÓõ½µÄµ¥Ôª¸ñÉèÖñ߿ò»òÕß±³¾°É«µÈ)
ÀýÈç
HSSFRow row = st.getRow(0); //¶ÁÈ¡µÚÒ»ÐÐ
HSSFCell cell = row.getCell((short)0); //¶ÁÈ¡µÚÒ»ÐеÚÒ»¸ö×Ö¶Î
2. Èç¹ûÄ£°åÖÐÎ
Ïà¹ØÎĵµ£º
JavaỊ̈߳ºÏ̵߳ĵ÷¶È-ÓÅÏȼ¶
ÓëÏß³ÌÐÝÃßÀàËÆ£¬Ï̵߳ÄÓÅÏȼ¶ÈÔÈ»ÎÞ·¨±£ÕÏÏ̵߳ÄÖ´ÐдÎÐò¡£Ö»²»¹ý£¬ÓÅÏȼ¶¸ßµÄÏ̻߳ñÈ¡CPU×ÊÔ´µÄ¸ÅÂʽϴó£¬ÓÅÏȼ¶µÍµÄ²¢·Çû»ú»áÖ´ÐС£
Ï̵߳ÄÓÅÏȼ¶ÓÃ1-10Ö®¼äµÄÕûÊý±íʾ£¬ÊýÖµÔ½´óÓÅÏȼ¶Ô½¸ß£¬Ä¬ÈϵÄÓÅÏȼ¶Îª5¡£
ÔÚÒ»¸öÏß³ÌÖпªÆôÁíÍâÒ»¸öÐÂỊ̈߳¬ÔòпªÏ̳߳ÆÎ ......
JavaỊ̈߳ºÏ̵߳ĵ÷¶È-ºÏ²¢
Ï̵߳ĺϲ¢µÄº¬Òå¾ÍÊǽ«¼¸¸ö²¢ÐÐÏ̵߳ÄÏ̺߳ϲ¢ÎªÒ»¸öµ¥Ïß³ÌÖ´ÐУ¬Ó¦Óó¡¾°Êǵ±Ò»¸öÏ̱߳ØÐëµÈ´ýÁíÒ»¸öÏß³ÌÖ´ÐÐÍê±Ï²ÅÄÜÖ´ÐÐʱ¿ÉÒÔʹÓÃjoin·½·¨¡£
joinΪ·Ç¾²Ì¬·½·¨£¬¶¨ÒåÈçÏ£º
void join()
µÈ´ý¸ÃÏß³ÌÖÕÖ¹¡£ ......
JavaỊ̈߳º²¢·¢Ð×÷-ËÀËø
Ï̷߳¢ÉúËÀËø¿ÉÄÜÐÔºÜС£¬¼´Ê¹¿´ËÆ¿ÉÄÜ·¢ÉúËÀËøµÄ´úÂ룬ÔÚÔËÐÐʱ·¢ÉúËÀËøµÄ¿ÉÄÜÐÔÒ²ÊÇС֮ÓÖС¡£
·¢ÉúËÀËøµÄÔÒòÒ»°ãÊÇÁ½¸ö¶ÔÏóµÄËøÏ໥µÈ´ýÔì³ÉµÄ¡£
ÔÚ¡¶JavaỊ̈߳ºÏ̵߳Äͬ²½ÓëËø¡·Ò»ÎÄÖУ¬¼òÊöËÀËøµÄ¸ÅÄîÓë¼òµ¥Àý×Ó£¬µ«ÊÇËù¸øµÄÀý×ÓÊDz»ÍêÕûµÄ£¬ÕâÀï¸ø³öÒ»¸öÍêÕûµÄÀ ......
JavaỊ̈߳ºvolatile¹Ø¼ü×Ö
Java™ ÓïÑÔ°üº¬Á½ÖÖÄÚÔÚµÄͬ²½»úÖÆ£ºÍ¬²½¿é£¨»ò·½·¨£©ºÍ volatile ±äÁ¿¡£ÕâÁ½ÖÖ»úÖƵÄÌá³ö¶¼ÊÇΪÁËʵÏÖ´úÂëÏ̵߳ݲȫÐÔ¡£ÆäÖÐ Volatile ±äÁ¿µÄͬ²½ÐԽϲµ«ÓÐʱËü¸ü¼òµ¥²¢ÇÒ¿ªÏú¸üµÍ£©£¬¶øÇÒÆäʹÓÃÒ²¸üÈÝÒ׳ö´í¡£
̸¼°µ½volatile¹Ø¼ü×Ö£¬²»µÃ²»ÌáµÄһƪÎÄÕÂÊÇ£º¡¶Java ......
ÉèÖÃ×¢ÊÍÄ£°åµÄÈë¿Ú£º Window->Preference->Java->Code Style->Code Template È»ºóÕ¹¿ªComments½Úµã¾ÍÊÇËùÓÐÐèÉèÖÃ×¢Ê͵ÄÔªËØÀ²¡£ÏÖ¾Íÿһ¸öÔªËØÖðÒ»½éÉÜ£º
Îļþ(Files)×¢ÊͱêÇ©£º
/**
* @Title: ${file_name}
* @Package ${package_name}
* @Description: ${todo}(ÓÃÒ»¾ä»°ÃèÊö¸ÃÎļ ......