| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 
 |  
 
//creation du workbook
private static HSSFWorkbook wb;
private static HSSFSheet templateSheet;
 
wb = new HSSFWorkbook();
templateSheet = wb.createSheet("template.xls");
 
 
	createRowLib(1,(short)0,2,(short)2,(short)1,IndigoProperties.getValue("libelle.rapportHM.header1"));
		try {
			fileout = new FileOutputStream( "workbook.xls");
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
 
		try {
			wb.write(fileout);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		 try {
			fileout.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
 
	private void createRowLib(int x1Area,short y1Area,int x2Area,short y2Area,short position,String Libelle){
		//création de la region : fusion des cellules
		templateSheet.addMergedRegion(new Region(x1Area,y1Area,x2Area,y2Area));
		//création de la ligne et de la cellule dans la region
		HSSFRow rowLib = templateSheet.createRow((short)1);
		HSSFCell cellLib  = rowLib.createCell((short)1);
		//mise à jour du contenu de la cellule et du style(Font,couleur, etc.)
		cellLib.setCellValue(Libelle);
		HSSFCellStyle headerStyle = wb.createCellStyle();
		headerStyle.setAlignment(HSSFCellStyle.VERTICAL_CENTER);
		cellLib.setCellStyle(headerStyle);
 
	} | 
Partager