tête de colonne rotative à l'aide HSSFCellStyle en utilisant la méthode setRotation fonctionne bien comme ci-dessous le programme ---XSSF Apache POI XSSFCellStyle
public static void main(String[] args)throws Exception
{
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet spreadsheet = workbook.createSheet(
"Text direction");
HSSFRow row = spreadsheet.createRow(2);
HSSFCellStyle myStyle = workbook.createCellStyle();
myStyle.setRotation((short) 0);
HSSFCell cell = row.createCell(1);
cell.setCellValue("0D angle");
cell.setCellStyle(myStyle);
myStyle=workbook.createCellStyle();
myStyle.setRotation((short) 90);
cell = row.createCell(3);
cell.setCellValue("30D angle");
cell.setCellStyle(myStyle);
myStyle=workbook.createCellStyle();
myStyle.setRotation((short) -90);
cell = row.createCell(5);
cell.setCellValue("90D angle");
cell.setCellStyle(myStyle);
FileOutputStream out = new FileOutputStream(
new File("textdirection.xlsx"));
workbook.write(out);
out.close();
System.out.println(
"textdirection.xlsx written successfully");
}
mais même code en utilisant writen tête de colonne de fichier de sortie XSSF ne tourne pas. ci-dessous en utilisant le code XSSF--
public static void main(String[] args)throws Exception
{
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet spreadsheet = workbook.createSheet(
"Text direction");
XSSFRow row = spreadsheet.createRow(2);
XSSFCellStyle myStyle = workbook.createCellStyle();
myStyle.setRotation((short) 0);
XSSFCell cell = row.createCell(1);
cell.setCellValue("0D angle");
cell.setCellStyle(myStyle);
myStyle=workbook.createCellStyle();
myStyle.setRotation((short) 180);
cell = row.createCell(3);
cell.setCellValue("30D angle");
cell.setCellStyle(myStyle);
myStyle=workbook.createCellStyle();
myStyle.setRotation((short) -180);
cell = row.createCell(5);
cell.setCellValue("90D angle");
cell.setCellStyle(myStyle);
FileOutputStream out = new FileOutputStream(
new File("textdirection.xlsx"));
workbook.write(out);
out.close();
System.out.println(
"textdirection.xlsx written successfully");
}
si quelqu'un peut me donner soupçon à ce sujet.
Merci.
@Basavaraj, si ma réponse est correcte - s'il vous plaît marquer comme le meilleur, donc que d'autres membres de la communauté pourraient le trouver utile aussi. – xSAVIKx