We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Vertical alignment of Excel cells

Thread ID:





124336 Jun 1,2016 02:23 PM UTC Jun 7,2016 12:09 PM UTC ASP.NET MVC 3
Tags: XlsIO
Richard Fairweather
Asked On June 1, 2016 02:23 PM UTC


I am using XlsIO to convert a CSV file to PDF. One requirement is that text is vertically aligned in the centre of each cell. However, applying vertical alignment to the range doesn't seem to have any effect on the final PDF. Other style options such as horizontal alignment and the background colour of the cells work correctly. I think I'm doing this the right way, adding a new style to the workbook, changing the properties of this style and then applying the style to the CellStyle of the range I have selected. I'm using version of Syncfusion.

Here is the code for applying the vertical alignment to the range:

IWorkbook workbook = application.Workbooks.Open(csvPath, ExcelOpenType.CSV);

IWorksheet sheet = workbook.Worksheets[0];


IStyle style = workbook.Styles.Add("AlignStyle");

style.VerticalAlignment = ExcelVAlign.VAlignCenter;

IRange range = sheet.Range[4, 1, sheet.UsedRange.LastRow, sheet.UsedRange.LastColumn];

range.CellStyle = style;


Kesavan D [Syncfusion]
Replied On June 2, 2016 12:06 PM UTC

Hi Richard, 
Thank you for contacting Syncfusion support. 
We are unable to reproduce the reported issue from our side. We have prepared a sample based on your requirement and shared it for your reference which can downloaded from the following link. 

Kindly try this sample and let us know whether the issue is resolved or not. If you are still facing this issue, then kindly share us the issue reproducing sample which will be helpful for us to provide you a prompt solution at the earliest. 

Richard Fairweather
Replied On June 6, 2016 08:27 AM UTC


Thanks for the response and sample code.

The only difference in the sample you have provided and my conversion code that I can see is that you are setting the range's RowHeight to 50. This seems to give the appearance of centred vertical alignment. However, if I then reduce the RowHeight, the vertical alignment doesn't seem to be being applied anymore.

I have three PDFs here (attached to this ticket), one with the range's RowHeight set to 50, one set to 25 and one set to 15. I have applied the appearance options from the sample you have provided which seem to display crosses showing the centre of each cell. As you can see in each PDF, the vertical alignment is less and less centred as the RowHeight reduces in each one.

How can I prevent this and have centred vertical alignment regardless of the range's RowHeight?


Attachment: PDF_c4d6b29b.zip

Kesavan D [Syncfusion]
Replied On June 7, 2016 12:09 PM UTC

Hi Richard, 


We were able to reproduce the problem and have logged defect report regarding this. A support incident to track the status of this defect has been created under your account. Please log on to our support website to check for further updates 




Please let me know if you have any questions. 



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon