We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Do not represent correct rotation of cell and line break


Please take a look at the attached sample xlsx.
Convert the sample xlsx to html and display them in the Browser works the same.
However, cells API seems not working right, could see
cell.getStyle().getRotationAngle() return opposite value,
ex: 45 deg returns -45 deg
-45 deg returnd 45 deg
Also the third column cell contains
, but cell.getHtmlString() does not contain any

We try to call cell java API to interpret the cell style to construct html string dynamically and display html in our product.

Thanks for help!

Ruhongtest_cell_rotation.zip (6.5 KB)

Please try our latest version/fix: Aspose.Cells for Java v20.1.9 (attached)

aspose-cells-20.1.9-java.zip (6.8 MB)

I have tested with below code.

Workbook workbook = new Workbook("test_cell_rotation.xlsx");        
Worksheet myWorksheet = workbook.getWorksheets().get("Sheet1");

Let us know your feedback with screenshots of output and excel if there is still any issue.


The latest version/fix: Aspose.Cells for Java v20.1.9 works the same.

my sample xlsx ===> html as follwoings

column 1:

First Name
Last Name
… Column 4: “Country” …
Column 1: cells API return rotation angle for “First Name” is 45 deg
Column 2: cells API return rotation angle for “Last Name” is -45 deg
Column 4: also cell.getHtmlString() does not contain any “
” test_rotation.zip (193.0 KB)

I have attached the original xlsx and the screenshot of converted image calling cells.API.
you could see all rotation angle are opposite, if I add “-” to them, some result will not work correctly.
so still need to report you to fix it.

Thanks for help!

Ruhongtest_rotation.zip (193.0 KB)

Thank you for providing more information. As per my under standing only the C1 cell rotation (255) can be analyzed again. Other than that all the rotation angles are correct. I have roughly drawn an axis showing the angles which are followed while depicting the rotation angle. Please analyze it along with the program output and share your feedback.

AnglesGrid.png (3.6 KB)

C1:getStyle().getRotationAngle() = 45 deg ,
please open original “test_cell_rotation.xlsx”, you could see C1 “First Name” should be “-45 deg”,
if you convert test_cell_rotation.xlsx to html(atttached) you could see C1 shows “-45deg” which is correct.
so that API return the opposite value.

Column 4: also cell.getHtmlString() does not contain any line break.
Other cells run the same issues.

Overall, attached html style are all correct, the same as original xlsx, but API does not return right value.test_cell_rotation.zip (2.3 KB)

MS Excel shows the rotation of A1 cell containing First Name as 45 degrees and not in negative. This rotation is also same with the angles grid image I have shared above. So the value returned by API looks fine to me. Please elaborate bit more with screenshots if you excel shows different value from API.

A1_45.png (13.4 KB)

For line break, could you please share complete lines of code (runnable) for our analysis.

(1)Source code for testing API :

Workbook workbook = new Workbook(“C://test_cell_rotation.xlsx”);
WorksheetCollection worksheetCollection= workbook.getWorksheets();
Worksheet worksheet = worksheetCollection.get(“Sheet1”);
Cells cells =worksheet.getCells();

Cell cellA = cells.get(1,0);
String cellAString = cellA.getStringValue(); // Return “First Name”
int rotationAngleCellA = cellA.getStyle().getRotationAngle(); // Return “45”

Cell cellB = cells.get(1,1);
String cellBString = cellB.getStringValue(); //Return “Last Name”
int rotationAngleCellB = cellB.getStyle().getRotationAngle(); // return “-45”

Cell cellC = cells.get(1,2);
String cellCString = cellC.getStringValue(); // Return “Country”
String cellCHtmlString = cellC.getHtmlString(); // does not contain any line break which is not correct

(2)Attached test_rotation.zip
a. test_cell_rotation.xlsx — Original xlsx
b. convertXlsx_html_Aspose.html ---- output for calling the following code

       Workbook workbook = new Workbook("C://test_cell_rotation.xlsx");
       //Create HtmlSaveOptions object
        HtmlSaveOptions options = new HtmlSaveOptions();
        //Set the Presenation preference option
        options.PresentationPreference = true;

        //Save the Excel file to HTML with specified option
        workbook.Save("C://convertXlsx_html_Aspose.html", options); 

c. convertXlsx_html_Aspose.docx
copy the source code from “convertXlsx_html_Aspose.html”,
highlight in “RED” to show you the rotation angle and line break string

d. html_calling_Aspose_API.docx
Our product calling API (see (1) sample code) to construct html, you could see the html
in this file, highlight in “RED” to show you the rotation angle.

e. Screenshot showing original file and Our product show the “d” aboved in WebUI.

If you see the “RED” in files, you will see “Aspose convert XLSX to html correctly , knowing
the rotation of A1 cell containing First Name as -45 degrees, and if open html, all
look exact the same as original xlsx”, However, “Aspose API” return differently, if
we call API directly, construct the html, we could not get the same result as original file.
test_rotation.zip (226.6 KB)

Thanks for help!


I have thoroughly reviewed this information and would like to share that MS Excel and HTML are using different angle representation. Aspose.Cells returns rotation angle information as per the MS Excel standards and there is no difference observed while comparing the results. You can also witness this by checking the orientation information shown by MS Excel.

On the other hand, the API also follows HTML rules of text orientation angle while converting workbook to HTML like angle is switched as per the rules followed by HTML standards. I am afraid that this behaviour cannot be changed and API will return the text rotation angle similar to MS Excel and not the HTML. Just for example, Aspose.Cells converts the workbook to some xyz format and that format uses entirely different scheme of angles orientation, then what should we expect from the API to return for these properties hence only MS Excel behaviour is followed. You may please device your own conversion mechanism to transform the angles from MS Excel standards to HTML standards.

Regarding the line breaks, again this is requirement of HTML and not the MS Excel. If you view the C1 cell content in the formula bar, it shows plain string country without any line breaks. However the rotation angle in MS Excel governs the display format of this string. So actual data does not contain line break and same is returned by Aspose.Cells. Just for example check the cell D1, it also contains text in vertical format, so it should also have line breaks when displayed in HTML but it does not.

You have to write a detailed converter similar to the one used by Aspose.Cells or MS Excel for converting workbook to HTML and write your own logics to create HTML strings based on different properties obtained from API like if rotation angle is 90, you may add line breaks yourself etc.

Hope it clarifies the scenario a bit and please feel free to share your thoughts.

Thanks for your detail explanation, where could find the source code for “Aspose convert excel to html”?
The logic how to handle it will be very helpful.


Well the API source code for the conversion cannot be provided but you may please follow the following link to have variety of sample codes for converting workbook to HTML using the API and open the output HTML file in some editor to observe the converted information for devising your own logic. Please feel free to contact us any time if you have any other query in this regard.