https://bz.apache.org/bugzilla/show_bug.cgi?id=58043
Bug ID: 58043
Summary: POI will not allow negative rotation of text using
XSSF but does work for HSSF
Product: POI
Version: 3.12-FINAL
Hardware: PC
Status: NEW
Severity: major
Priority: P2
Component: XSSF
Assignee: [email protected]
Reporter: [email protected]
Created attachment 32828
--> https://bz.apache.org/bugzilla/attachment.cgi?id=32828&action=edit
Demonstrates inability to rotate text -90 degrees using XSSF
I need to rotate text within a cell by -90 degrees. This feature works for a
HSSF xls spreadsheet with POI. But it does not work for a XSSF xlsx
spreadsheet with POI. The text remains at 0 degrees rotation.
Attached is sample code that demonstrates the successful rotation using HSSF
and the unsuccessful rotation using XSSF.
Please correct this.
Marty
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.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class TestExcel
{
private void createXls()
{
try
{
Workbook workbook = new HSSFWorkbook();
FileOutputStream fileOut = new FileOutputStream("c:/rotated.xls");
Sheet sheet1 = workbook.createSheet();
Row row1 = sheet1.createRow((short) 0);
Cell cell1 = row1.createCell(0);
cell1.setCellValue("Successful rotated text.");
CellStyle style = workbook.createCellStyle();
style.setRotation((short) -90);
cell1.setCellStyle(style);
workbook.write(fileOut);
fileOut.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
private void createXlsx()
{
try
{
Workbook workbook = new XSSFWorkbook();
FileOutputStream fileOut = new FileOutputStream("c:/rotated.xlsx");
Sheet sheet1 = workbook.createSheet();
Row row1 = sheet1.createRow((short) 0);
Cell cell1 = row1.createCell(0);
cell1.setCellValue("Unsuccessful rotated text.");
CellStyle style = workbook.createCellStyle();
style.setRotation((short) -90);
cell1.setCellStyle(style);
workbook.write(fileOut);
fileOut.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args) throws Exception
{
TestExcel testExcel = new TestExcel();
testExcel.createXls();
testExcel.createXlsx();
}
}
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]