Free Support Forum -

Styles question - referencing styles defined in the workbook

We have used version 3.0.3 and 3.0.5 of the Aspose Excel DLL - trying to resolve an issue with styles:

In our C# program, we define styles in a new workbook object, then save the workbook. Then, we open the workbook again in the same C# program, and try to make reference to a style already defined from the step above. The style is there (and if we open the Excel file in Excel after the first save of the workbook, and even after the second save, all of the styles still appear in the workbook using version 3.0.5), but we are not seeing it being applied on the second part of the code when we try to use it to format cells.


This is done in the beginning of the code when the workbook object is first created:

styleIndex = excel_target.Styles.Add() ;

styleCustom = excel_target.Styles[styleIndex] ;

styleCustom.Font.Name = "Arial" ;

styleCustom.Font.IsBold = false ;

styleCustom.Font.IsItalic = false ;

styleCustom.Font.Size = 7 ;

styleCustom.VerticalAlignment = TextAlignmentType.Center ;

styleCustom.HorizontalAlignment = TextAlignmentType.Left ;

styleCustom.IsTextWrapped = false ;

styleCustom.Name = "Normal7HLeft" ;

Then we save the workbook:

excel_target.Save(@"c:\\wip_workbooks\\result - " + lnFileNameEmplId + ".xls", FileFormatType.Default);

Then later in the code, we open the workbook:

excel_target.Open (@"c:\\wip_workbooks\\result - " + lnFileNameEmplId + ".xls");

Then try to assign a Style object:
Style styleNormal7HLeft = null; // defined the style variable

styleNormal7HLeft = excel_target.Styles["Normal7HLeft"];

This last line no longer seems to work, styleNormal7HLeft does not get assigned to the style from the workbook. This did work in version 3.0.3 (but what didn't work in 3.0.3 is when you save a file, then open it, they styles completely disappeared out of Excel!).

Thanks for your help!


Hi Bob,

I will check and fix this issue ASAP.

Thank you for your fast response!


Do you have an idea of when a fix will be available? We are scheduled to release Excel workbooks into production (30,000 every two weeks) very soon - and this bug is making a mess when rendering the workbooks. Surprise



Please try this attached fix.

Seems to be working now. Smile



yes, thank you…looks like it is fixed!