How to detect the cell text is vertical?

Hi,

The attached file shows that there is vertical string in the cell, how to detect it? Sample code will be help!
Many thanks!image-2018-09-06-14-59-06-367.png (66.6 KB)

@ruhongcai,
You may check the rotation angle to check if vertical text is there or not. Please make your own logic to decide which text is to be considered vertical.

Workbook wb = new Workbook("Sample.xlsx");
Cell cell = wb.Worksheets[0].Cells["A1"];
Aspose.Cells.Style style = cell.GetStyle();
Console.WriteLine(style.RotationAngle);

Sample.zip (10.0 KB)

Many thanks!

Ruhong

@ruhongcai,

Good to know that your issue is sorted out by the suggested code. Feel free to contact us at any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thanks! It works for vertical.

How to detect “center text” alignment? The attached file shows the original XLSX and the html converted. Please provide the sample code to detect “center text alignment”.

Many thanks!

Ruhongcell_text_center.zip (397.0 KB)

@ruhongcai,
We are working on this requirement and will share our feedback soon.

@ruhongcai,
You may try using the following sample code to get the horizontal and vertical alignment property of a cell and share the feedback.

Workbook workbook = new Workbook(path + "alignement.xlsx");
Cell cell = workbook.Worksheets[0].Cells["A2"];
Aspose.Cells.Style style = cell.GetStyle();
Console.WriteLine(style.HorizontalAlignment);
Console.WriteLine(style.VerticalAlignment);

Hi,

Thanks for help!

We read in xls and appy Aspose cell api to interpret cell content and format , then transfer to html to be displayed in Web application.

The alignment is integer, how it map to value in html CSS?

(1)The sample.zip (attached here before) contains cell vertically, according to your sample code
in such case cell.getStyle().getRotationAngle()=90, this cell value is vertical text which is downside,
also in the right most in cell.
cell.getStyle().getVerticalAlignment() = 0
cell.getStyle().getHorizontalAlignment() = 5
what is “5” means? How could present in html CSS?

(2)cell_text_center.zip, in this case,
cell.getStyle().getHorizontalAlignment()=1
cell.getStyle().getVerticalAlignment()=1

What “1” means?
how could tell this is “center”? How could present in html CSS?

Thanks!

Ruhong

@ruhongcai,
You may please consider the following enumerator which represents these values. Please use it for your translation to HTML. You may also try to convert the Excel file to HTML using Aspose.Cells and check the properties for your reference.

public enum TextAlignmentType
{
	/// <summary>
	///       Represents bottom text alignment.
	///       </summary>
	Bottom,
	/// <summary>
	///       Represents center text alignment.
	///       </summary>
	Center,
	/// <summary>
	///       Represents center across text alignment.
	///       </summary>
	CenterAcross,
	/// <summary>
	///       Represents distributed text alignment.
	///       </summary>
	Distributed,
	/// <summary>
	///       Represents fill text alignment.
	///       </summary>
	Fill,
	/// <summary>
	///       Represents general text alignment.
	///       </summary>
	General,
	/// <summary>
	///       Represents justify text alignment.
	///       </summary>
	Justify,
	/// <summary>
	///       Represents left text alignment.
	///       </summary>
	Left,
	/// <summary>
	///       Represents right text alignment.
	///       </summary>
	Right,
	/// <summary>
	///       Represents top text alignment.
	///       </summary>
	Top,
	/// <summary>
	///       Aligns the text with an adjusted kashida length for Arabic text.
	///       </summary>
	JustifiedLow,
	/// <summary>
	///       Distributes Thai text specially, because each character is treated as a word.
	///       </summary>
	ThaiDistributed
}

Hi,

Thanks for the information, however that seems are not what we need. “TextAlignmentType” seems
applied in “setMethod” to build cells during creatation of xlsx.

what we need is “read or get” information about the format/alignment,etc for cell content.
I research and could not find any API for “getProperty…” for those information.

Tried “convert xlsx to html” and read the html, I could see “CSS style” information there, but how could
read them from Aspose cells API?

Is there a way to do the following?
convert xlsx to html ----- found the sample for run time
read css style from html — API? Aspose cells or html? Please provide some sample code including
TextAlignmentType

Again, what we need to do is “read xlsx, display them in webUI(html) in our product”.
Scroll up, there are two sample zip,

  1. “vertical” (Could call api, cell,getstyle().getRotationAngle() , then display text vertically but not
    alignment)
  2. Alignment center

Could not find a way to get alignment for them to be used.

Thanks for help!

Ruhong

@ruhongcai,
Thank you for writing us again.

Convert this XLSX file to HTML using any other third party tool like MS Excel and identify the properties in the output HTML. Please share those properties along with images which you expect from Aspose.Cells. We will analyze the information and provide assistance accordingly.

Thanks for help!
Finally I could apply TextAlignmentType to get what I need.

@ruhongcai,
Good to know that your issue is sorted out by the suggested information. Feel free to contact us at any time if you need further help or have some other issue or queries, we will be happy to assist you soon.