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.
Unfortunately, activation email could not send to your email. Please try again.

Vertical alignment of Excel cells

Thread ID:

Created:

Updated:

Platform:

Replies:

124336 Jun 1,2016 10:23 AM Jun 7,2016 08:09 AM ASP.NET MVC 3
loading
Tags: XlsIO
Richard Fairweather
Asked On June 1, 2016 10:23 AM

Hi,

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 14.1.0.41 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;

range.AutofitColumns();









Kesavan D [Syncfusion]
Replied On June 2, 2016 08:06 AM

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. 
 
Regards, 
Kesavan

Richard Fairweather
Replied On June 6, 2016 04:27 AM

Hi,

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?

Regards,
Richard

Attachment: PDF_c4d6b29b.zip

Kesavan D [Syncfusion]
Replied On June 7, 2016 08:09 AM

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 

  

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents  

  

Please let me know if you have any questions. 

 
Regards, 
Kesavan 


CONFIRMATION

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.

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.

;