"Web development" ☆★ Using POI Operations Excel Table Series tutorial "9" cell border processing
Package Csg.xiaoye.poidemo;import Java.io.fileoutputstream;import Org.apache.poi.hssf.usermodel.HSSFWorkbook; Import Org.apache.poi.ss.usermodel.cell;import Org.apache.poi.ss.usermodel.cellstyle;import Org.apache.poi.ss.usermodel.indexedcolors;import Org.apache.poi.ss.usermodel.row;import Org.apache.poi.ss.usermodel.sheet;import org.apache.poi.ss.usermodel.workbook;/** * Processing cell borders * @author Administrator * */public class Poiframe {public static void main (string[] args) throws exception{Workbook wb=new Hssfworkbook ( ); Define a new workbook Sheet sheet=wb.createsheet ("First Sheet page"); Create the first sheet page of Row row=sheet.createrow (1); Create a row of Cell Cell=row.createcell (1); Create a cell cell.setcellvalue (4); CellStyle Cellstyle=wb.createcellstyle (); Cellstyle.setborderbottom (Cellstyle.border_thin); Bottom Border Cellstyle.setbottombordercolor (IndexedColors.BLACK.getIndex ()); Bottom Border color cellstyle.setborderleft (cellstyle.bordEr_thin); Left Border Cellstyle.setleftbordercolor (IndexedColors.RED.getIndex ()); Left border color cellstyle.setborderright (CELLSTYLE.BORDER_DASH_DOT_DOT); Right Border Cellstyle.setrightbordercolor (IndexedColors.BLUE.getIndex ()); Right border color cellstyle.setbordertop (cellstyle.border_medium_dashed); Top Border Cellstyle.settopbordercolor (IndexedColors.ORANGE.getIndex ()); Top Border Color Cell.setcellstyle (cellstyle); FileOutputStream fileout=new fileoutputstream ("d:\\ saya. xls"); Wb.write (fileout); Fileout.close (); }}
The effect is as follows:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/26/90/wKioL1Nrfx3gxIqAAAAnCNCWYBY546.jpg "title=" 1.png " alt= "Wkiol1nrfx3gxiqaaaancncwyby546.jpg"/>
This article from "Promise always attached to the small wood 、、、" blog, please be sure to keep this source http://1936625305.blog.51cto.com/6410597/1408594