Spaltenüberschrift Rotierende Verwendung HSSFCellStyle Verwendung Arbeitsmethode setRotation fein wie unten Programm ---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");
}
aber denselben Code verwenden WRITEN XSSF Ausgabedatei Spaltenkopf nicht dreht. Code unten 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");
}
verwendet, kann so jemand mir auf diesen Hinweis geben.
Danke.
@Basavaraj, wenn meine Antwort richtig ist - bitte es als das beste markieren, so dass andere Community-Mitglieder es auch nützlich finden könnten. – xSAVIKx