ʹÓÃJAVAͨ¹ýJXL(JExcel)¶¯Ì¬Éú³ÉExcelÎļþ
ÉÏ´Î談過ÁËʹÓÃiText產ÉúPDF檔£¬這´Î換³É來談談ʹÓÃJExcel來產ÉúEXCEL檔µÄ·½·¨¡£
Ê×ÏÈ£¬Ïȵ½ËûµÄSourceForgeÖ÷頁ÃædownloadÏà關µÄAPI檔°¸¡£
http://sourceforge.net/projects/jexcelapi/
»ò
http://www.andykhan.com/jexcelapi/download.html
當È»£¬ËûÒ²ÊÇOpenSourceµÄÔª¼þ¡£
ÏÂÁÐ為ÆäTutorial½Ì學£º
http://www.andykhan.com/jexcelapi/tutorial.html
Ò»ÇоÍ緒áᣬÄǾÍ準備ÉÏ·ÁË¡£
ÏÂ載ÏÂ來µÄ壓縮檔½â開áᣬ¿ÉÒÔÕÒµ½jxl.jar£¬ÏÈ將´Ë檔°¸¼ÓÈëÄãµÄClasspathÖаɣ¡
1. ÏȽ¨Á¢Workbook
Ò²¾ÍÊÇÕû·ÝµÄExcel檔°¸£¬¿ÉÖ¸¶¨檔Ãû¡£
Workbook workbook = Workbook.getWorkbook(new File("test.xls"));
2. ½¨Á¢Sheet
Ò²¾ÍÊÇÿ個Excel檔°¸ÏÂÃæ¿ÉÒÔÌøtagµÄsheet±í¡£
Sheet sheet = workbook.createSheet("ÎÒµÄExcel±í", 0);
µÚÒ»個參數ÊÇsheet name£¬µÚ¶þ個參數ÊǵÚ幾張sheet£¬當È»indexÊÇÓÉ0開ʼËã¡£
3. ½¨Á¢×ÖÐÍ
WritableFont chFont11w = new WritableFont(WritableFont.TIMES, 11);
chFont11w.setColour(Colour.WHITE);
ÏȽ¨Á¢Ò»個WritableFontµÄinstance£¬ÆäconstructorµÄµÚÒ»個參數ÊÇÖ¸¶¨×ÖÐÍ£¬µÚ¶þ個ÊÇ×ÖÐÍ´óС¡£
ÆäÖÐ×ÖÐ͵IJ¿·Ý£¬¿ÉÒÔʹÓÃWritableFontËùÌṩ預設µÄÒ»¶Ñstatic³£數來Ö¸¶¨£¬
Ò²¿ÉÒÔÖ±½Ó輸Èëstring£¬±ÈÈç´ò"標¿¬體"£¬µ½時產ÉúµÄ×ÖÐ;Í會ÒÀÕÕÄãËùÖ¸¶¨µÄ來顯ʾ¡£
¶øsetColourÊÇÖ¸¶¨´Ë×ÖÐ͵Ä顏É«£¬這個²¿·Ý¾ÍÂé煩¡£
(ÓÉcolour這個×Ö來¿´£¬ºÜ顯È»µÄJExcel應ÊÇÓ¢國Ïà關µÄÈË開發µÄ:P ·´Õý總Ö®²»會ÊÇÃÀ國)
顏É«為ʲ麼Âé煩ÄØ£¿ÔÚJExcel裡Ã棬Colour class並²»Ìṩpublic constructor讓user×Ô¼ºÖ¸¶¨RGBµÄ顏É«£¬
ËùÒÔÄãÖ»ÄÜ從ColourÖÐÒ»¶ÑµÄstatic³£數顏É«來Ö¸¶¨£¬Ö®Ç°為ÁË這個問題還Ñо¿ÁËÒ»ÏÂËûµÄÔʼ
Ïà¹ØÎĵµ£º
1.Ç°ÑÔ£º
ÄãµÄ³ÌÐò×ÜÓÐÒ»Ìì»á±ÀÀ£µô£¬ÔÚ±ÀÀ£µôµÄʱºòÎÒÃÇÒªÖªµÀËüÔÚÄÄ£¬ÎªÁËʲô¶ø±ÀÀ£µô£¬Êý¾ÝµÄ±£´æ»òÕ߶ªÊ§Çé¿öÈçºÎµÈÎÊÌâ¡£ÎÒÃÇ¿ÉÒÔͨ¹ý¼Ì³ÐÀàjava.lang.ThrowableµÄ×ÓÀࣺExceptionÀ´Éè¼ÆÎÒÃÇ×Ô¼ºµÄJavaÒì³£¡£ExceptionÀàÓÃÓÚÃèÊö³ÌÐòÄܹ»²¶»ñµÄÒì³££¬ÈçClassNotFoundException¡£Òª×¢ÒâµÄÊÇ×Ô¶¨ÒåÒì³£ÀàÖ®¼äÒ²¿ÉÒÔÓм ......
¼øÓÚÅÀ³æ¿ª·¢ÐèÒªÒ»¸öͼƬ½âÎö¹¦Äܵĺ¯Êý£¬µ½ÍøÂçÉϲéÕÒÁËһЩjni·½ÃæµÄÄÚÈÝ£¬²¢×öÁË×Ô¼ºµÄһЩÐ޸ģ¬¾ßÌåÈçÏ£º
Ä¿Ç°javaÓëdll½»»¥µÄ¼¼ÊõÖ÷ÒªÓÐ3ÖÖ£ºjni£¬jawinºÍjacob¡£Jni£¨Java Native Interface£©ÊÇsunÌṩµÄjavaÓëϵͳÖеÄÔÉú·½·¨½»»¥µÄ¼¼Êõ£¨ÔÚwindows\linuxϵͳÖУ¬ÊµÏÖjavaÓënative method»¥µ÷£©¡£ ......
Observer
Intent
Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.
How to
Subject
knows its observers. Any number of Observer objects may observe a subject.
provides an in ......
¹¤×÷ÒѾÓаëÄêÁË£¬Í»È»Ïëдµã¶«Î÷£¬´óѧµÄʱºò¾ÍÓÐдÈռǵÄÏ°¹ß£¬µ«ÊÇ×Ô´ÓÈ¥Java06°àѧϰһֱµ½ÏÖÔÚ¹¤×÷£¬ÂýÂýµÄҲûÓÐʱ¼äȥдÈռǣ¬Ï£Íûͨ¹ýÕâƪÎÄÕÂÄÜÈÃJava˽ÛÓµÄѧµÜѧÃÃÃÇ¿´ÁËÓÐËù°ïÖú¡£
ÏàÐźܶàͬѧºÜÎÒÒ»Ñù´óËĵÄʱºò¶¼±È½ÏÃÔ㣬ÓÈÆäÊÇÎÒ¶ÁµÄ¼ÆËã»úרҵ£¬ËµÊµ»°´óѧÀïѧµÄºÍÉç»áʵ¼ÊÐèÒªµÄ» ......
JXLµÄ´òÓ¡ÉèÖÃÔÚjxl.SheetSettingsÕâ¸öÀàÖУ¬ÎÒÃÇ¿ÉÒÔͨ¹ý·½·¨Sheet£¨»òÕßWritableSheet£©#getSettings()»ñÈ¡¡£
1.Ò³Ãæ
1.1·½Ïò
SheetSetting#setOrientation(PageOrientation po)£»
²ÎÊý£º PageOrientation#LANDSCAPE ºáÏò´òÓ¡
PageOrientation# PO ......