Vertical alignement and background color on style has no effect

Hi,

I am having problems modifiying the existing style. Vertical alignment and background color is not applyied on cell after modifying it. Only underline is applied. Please use my example below.

Regards

Ranko

Workbook wb = new Workbook();

wb.Worksheets.Clear();

Worksheet ws = wb.Worksheets.Add("Sheet");

Style s = wb.Styles[wb.Styles.Add()];

s.Name = "NewStyle";

s.Font.Underline = FontUnderlineType.Single;

s.BackgroundColor = Color.Blue;

s.VerticalAlignment = TextAlignmentType.Center;

Cells cells = ws.Cells;

Cell c = cells["F2"];

c.PutValue("Text");

c.SetStyle(s);

wb.Save(@"Result.xlsx", FileFormatType.Excel2007Xlsx);

Hi,

Thank you for considering Aspose.

For setting the background color, please change your code as below:

Workbook wb = new Workbook();

wb.Worksheets.Clear();

Worksheet ws = wb.Worksheets.Add("Sheet");

Style s = wb.Styles[wb.Styles.Add()];

s.Name = "NewStyle";

s.Font.Underline = FontUnderlineType.Single;

s.ForegroundColor = Color.Blue;

s.Pattern = BackgroundType.Solid;

s.VerticalAlignment = TextAlignmentType.Center;

Cells cells = ws.Cells;

Aspose.Cells.Cell c = cells["F2"];

c.PutValue("Text");

c.SetStyle(s);

wb.Save(@"C:\Result.xlsx",FileFormatType.Excel2007Xlsx);

Please check the following documentation link for further details regarding setting background color and patterns:

http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/colors-background-patterns.html

For Vertical Alignment issue in XLSX file, we have found the issue after an initial test. We will look into it and get back to you soon. Your issue has been registered in our issue tracking system with issue id CELLSNET-11780.

Thank You & Best Regards,

Hi

thanks on the reponse. I had few problems but it works with cell foreground color.

Regards

Ranko

Hi,

Thank you for considering Aspose.

Are you still unable to set the background color? Did you update your code lines as below:

s.ForegroundColor = Color.Blue;

s.Pattern = BackgroundType.Solid;

If yes, please try the attached latest version of Aspose.Cells and if you still face the problem, please create a sample application and post it here. We will check it soon.

Thank You & Best Regards,

Hi

sorry as mentioned above I had few problems and now it works.

Could you tell me what does attached version ?

Regards

Rako

Hi,

Good to know that your issue has been resolved.

Regarding the attached version(by Nausherwan), well you may use this latest fix if you want (it does have some feature enhancement or some bug fixes).

Have a good day!

Thank you.

Hi,

Please try the attached version. We have fixed the Vertical Alignment issue in XLSX file you mentioned.

Please let us know if you still find the problem.

Thank you

Hi Amjad

Yes this helped a lot

Thanks

BR

Ranko

Hi,

Thank you for considering Aspose.

For setting the background color, please change your code as below:

Workbook wb = new Workbook();

wb.Worksheets.Clear();

Worksheet ws = wb.Worksheets.Add(“Sheet”);

Style s = wb.Styles[wb.Styles.Add()];

s.Name = “NewStyle”;

s.Font.Underline = FontUnderlineType.Single;

s.ForegroundColor = Color.Blue;

s.Pattern = BackgroundType.Solid;

s.VerticalAlignment = TextAlignmentType.Center;

Cells cells = ws.Cells;

Aspose.Cells.Cell c = cells[“F2”];

c.PutValue(“Text”);

c.SetStyle(s);

wb.Save(@“C:\Result.xlsx”,FileFormatType.Excel2007Xlsx);

Please check the following documentation link for further details regarding setting background color and patterns:

Aspose.Total Product Family

For Vertical Alignment issue in XLSX file, we have found the issue after an initial test. We will look into it and get back to you soon. Your issue has been registered in our issue tracking system with issue id CELLSNET-11780.

Thank You & Best Regards,

Hi

Thanks a lot for your guide. It solved my problem.

Regards

Hi,

We thank you for your appreciation and using Aspose.Cells.

It is a pleasure to know that your issue is resolved with the code provided by Nausherwan. Let us know if you encounter any other issue, we will be glad to look into it and help you further.