Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Java²Ù×÷Excel Poi¼ò½é


 
Ò»£®POI¼ò½é
Jakarta POI ÊÇapacheµÄ×ÓÏîÄ¿£¬Ä¿±êÊÇ´¦Àíole2¶ÔÏó¡£ËüÌṩÁËÒ»×é²Ù×ÝWindowsÎĵµµÄJava API
Ä¿Ç°±È½Ï³ÉÊìµÄÊÇHSSF½Ó¿Ú£¬´¦ÀíMS Excel£¨97-2002£©¶ÔÏó¡£Ëü²»ÏóÎÒÃǽö½öÊÇÓÃcsvÉú³ÉµÄûÓиñʽµÄ¿ÉÒÔÓÉExcelת»»µÄ¶«Î÷£¬¶øÊÇÕæÕýµÄExcel¶ÔÏó£¬Äã¿ÉÒÔ¿ØÖÆһЩÊôÐÔÈçsheet,cellµÈµÈ¡£
¶þ£®HSSF¸Å¿ö
HSSF ÊÇHorrible SpreadSheet FormatµÄËõд£¬Ò²¼´“ÌÖÑáµÄµç×Ó±í¸ñ¸ñʽ”¡£Ò²ÐíHSSFµÄÃû×ÖÓе㻬»ü£¬¾Í±¾ÖʶøÑÔËüÊÇÒ»¸ö·Ç³£ÑÏËà¡¢Õý¹æµÄAPI¡£Í¨¹ýHSSF£¬Äã¿ÉÒÔÓô¿Java´úÂëÀ´¶ÁÈ¡¡¢Ð´Èë¡¢ÐÞ¸ÄExcelÎļþ¡£
HSSF Ϊ¶ÁÈ¡²Ù×÷ÌṩÁËÁ½ÀàAPI£ºusermodelºÍeventusermodel£¬¼´“Óû§Ä£ÐÍ”ºÍ“ʼþ-Óû§Ä£ÐÍ”¡£Ç°ÕߺܺÃÀí½â£¬ºóÕ߱ȽϳéÏ󣬵«²Ù×÷ЧÂÊÒª¸ßµÃ¶à¡£
Èý£®¿ªÊ¼±àÂë
1 £® ×¼±¸¹¤×÷
ÒªÇó:JDK 1.4+POI¿ª·¢°ü
2 £® EXCEL ½á¹¹
HSSFWorkbook excell Îĵµ¶ÔÏó½éÉÜ
HSSFSheet excellµÄ±íµ¥
HSSFRow excellµÄÐÐ
HSSFCell excellµÄ¸ñ×Óµ¥Ôª
HSSFFont excell×ÖÌå
HSSFName Ãû³Æ
HSSFDataFormat ÈÕÆÚ¸ñʽ
ÔÚpoi1.7ÖвÅÓÐÒÔÏÂ2Ï
HSSFHeader sheetÍ·
HSSFFooter sheetβ
ºÍÕâ¸öÑùʽ
HSSFCellStyle cellÑùʽ
¸¨Öú²Ù×÷°üÀ¨
HSSFDateUtil ÈÕÆÚ
HSSFPrintSetup ´òÓ¡
HSSFErrorConstants ´íÎóÐÅÏ¢±í
3 £®¾ßÌåÓ÷¨ÊµÀý £¨²ÉÓà usermodel £©
ÈçºÎ¶ÁExcel
¶ÁÈ¡ExcelÎļþʱ£¬Ê×ÏÈÉú³ÉÒ»¸öPOIFSFileSystem¶ÔÏó£¬ÓÉPOIFSFileSystem¶ÔÏó¹¹ÔìÒ»¸öHSSFWorkbook£¬¸ÃHSSFWorkbook¶ÔÏó¾Í´ú±íÁËExcelÎĵµ¡£ÏÂÃæ´úÂë¶ÁÈ¡ÉÏÃæÉú³ÉµÄExcelÎļþдÈëµÄÏûÏ¢×Ö´®£º
´úÂë
POIFSFileSystem fs=newPOIFSFileSystem(new FileInputStream("d:\test.xls"));    
HSSFWorkbook ¡¡wb = new HSSFWorkbook(fs);    
¡¡¡¡} catch (IOException e) {    
¡¡¡¡e.printStackTrace();    
¡¡¡¡}    
¡¡¡¡HSSFSheet sheet = wb.getSheetAt(0);    
¡¡¡¡HSSFRow row = sheet.getRow(0);    
¡¡¡¡HSSFCell cell = row.getCell((short) 0);    
¡¡¡¡String msg = cell.getStringCellValue();  
POIFSFileSystem fs=newPOIFSFileSystem(new FileInputStream("d:\test.xls"));    
HSSFWorkbook ¡


Ïà¹ØÎĵµ£º

javaÖеÄmainÄãÖªµÀÂð

   Èç¹ûÄãÈ¥ÃæÊÔµÄʱºò£¬ÃæÊÔ¹Ù¿¼Ä㣬ΪʲôҪÔÚjavaÖеÄmain·½·¨Ç°¼Ópublic static voidÕâЩÐÞÊηû£¬ÄãÖªµÀÈçºÎÈ¥»Ø´ðÂð£¿ÏÂÃæÎÒΪ´ó¼Ò½²½âһϰɣ¡Èç¹ûÓÐʲôȱ©µÄ»°£¡»¶Ó­´ó¼ÒµÄÖ¸µã£¡
   Ê×ÏÈ£¬ÎªÊ²Ã´ÒªÓÃpublic£º
   ÒòΪÔÚÔËÐгÌÐòʱ£¬jvmÒªµ÷ÓÃmain·½·¨£¬µ«ÎÒÃǶ¼Ó¦¸ÃÖªµÀjvm ......

java·´Éä»úÖÆ

ת×Ô http://www.bjtarena.com/html/2010/4/1058.htm
ºÜ¶àÅóÓÑÔÚÉîÈëµÄ½Ó´¥JavaÓïÑÔºó¾Í»á·¢ÏÖÕâÑùÁ½¸ö´Ê£º·´Éä(Reflection)ºÍÄÚÊ¡(Introspector)£¬¾­³£¸ã²»Çå³þÕâµ½µ×ÊÇÔõô»ØÊ£¬ÔÚʲô³¡ºÏÏÂÓ¦ÓÃÒÔ¼°ÈçºÎʹÓã¿
¡¡¡¡·´Éä
¡¡¡¡Ïà¶Ô¶øÑÔ£¬·´Éä±ÈÄÚÊ¡¸üÈÝÒ×Àí½âÒ»µã¡£ÓÃÒ»¾ä±È½Ï°×µÄ»°À´¸ÅÀ¨£¬·´Éä¾ÍÊÇÈÃÄã¿ÉÒÔͨ¹ýÃû³ÆÀ ......

JavaµÄmain·½·¨ÓëÀàµÄ¼ÓÔصÄÁªÏµ

¼øÓÚÐí¶àͬѧ¶ÔÕâ¸ömain·½·¨µÄÃÔ»ó£¡ÎÒÕâÀïÌṩһЩÒâ¼û£¬Ï£Íû¶Ô´ó¼ÒÓаïÖú£¡ºÇºÇ£¡
     ****ÎÒÃÇ˵¼ÓÔØÏÈ£º
      JavaµÄÀàÊÇÓõ½²Å¿ªÊ¼¼ÓÔصģ¬²¢ÇÒÔÚÿ¸öÀàµÄ¹¹ÔìÆ÷µ÷ÓÃ֮ǰ£¬ÀàµÄÿ¸öÓò£¨³ÉÔ±±äÁ¿£©¶¼ÒªÊ×Ïȱ»±àÒëÆ÷³õʼ»¯Ò»´Î£¬È»ºó²ÅÂÖµ½¹¹ÔìÆ÷À´¸É»î¶ù¡£µ«ÊÇ£¬Java ......

JavaÎļþ²Ù×÷ʵÀý


/*
³ÌÐò¹¦ÄÜ£º½«ecoli(1).txt·Ö¸î£¬ÆäÖзָîµÄ·Ö¸î·ûÊÇ>
·Ö¸îµÄÎļþÃûÊÇ>gi|????|,"???"±íʾһ¶ÎÊý×Ö£¬ÓÃÊý×Ö×ö×ÓÎļþÃû
ÎļþÒÔ×Ö·û"!"½áβ
³ÌÐòÔ±:xianglinyan
*/
import java.io.*;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
impo ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ