Styles corrupted after upgrading Aspose.Excel


#1

Hi

I've upgraded from Version 2.9.7.3 to Version 3.6.1.0. And my generated styles in my excel all went bongkus. Please advise, thanks a million. Attached is a copy of 2 version output.


#2

Could you please post your code to set styles? And have you tried latest version of Aspose.Cells? Aspose.Cells is an upgrade of Aspose.Excel.


#3

Hi

I'm using the following to create styles and added to the excel.styles collection.

No we are not using Aspose.Cells. There are too many dependency from too many parties to change this.

Aspose.Excel.Style style;

int styleIndex;

//----------------------------------

//Set None style

//----------------------------------

styleIndex = myExcel.Styles.Add();

style = myExcel.Styles[styleIndex];

style.Font.Name = "Arial";

style.Font.Size = 9;

style.Custom = "_(* #,##0_);_(* (#,##0);_(* \"-\"??_)";

style.Font.IsBold = false;

style.HorizontalAlignment = TextAlignmentType.Left;

style.IsTextWrapped = false;

style.Font.IsItalic = false;

style.Font.Underline = FontUnderlineType.None;

style.Font.Color = System.Drawing.Color.White;

style.IsFormulaHidden=true;

//----------------------------------

//Set ItemHeaderTop style

//----------------------------------

styleIndex = myExcel.Styles.Add();

style = myExcel.Styles[styleIndex];

style.Font.Name = "Arial";

style.Font.Size = 9;

style.Custom = "_(* #,##0_);_(* (#,##0);_(* \"-\"??_)";

style.Font.IsBold = false;

style.HorizontalAlignment = TextAlignmentType.Left;

style.VerticalAlignment = TextAlignmentType.Top;

style.IsTextWrapped = true;

style.Font.IsItalic = false;

style.Font.Underline = FontUnderlineType.None;

style.IsFormulaHidden=true;

//style.VerticalAlignment = TextAlignmentType.Distributed;

//----------------------------------

//Set ItemHeaderCenter style

//----------------------------------

styleIndex = myExcel.Styles.Add();

style = myExcel.Styles[styleIndex];

style.Font.Name = "Arial";

style.Font.Size = 9;

style.Custom = "_(* #,##0_);_(* (#,##0);_(* \"-\"??_)";

style.Font.IsBold = false;

style.HorizontalAlignment = TextAlignmentType.Center;

style.IsTextWrapped = false;

style.Font.IsItalic = false;

style.Font.Underline = FontUnderlineType.None;

style.IsFormulaHidden=true;

//style.VerticalAlignment = TextAlignmentType.Distributed;

//----------------------------------

//Set ItemHeaderItalics style

//----------------------------------

styleIndex = myExcel.Styles.Add();

style = myExcel.Styles[styleIndex];

style.Font.Name = "Arial";

style.Font.Size = 9;

style.Custom = "_(* #,##0_);_(* (#,##0);_(* \"-\"??_)";

style.Font.IsBold = false;

style.HorizontalAlignment = TextAlignmentType.Left;

style.IsTextWrapped = false;

style.Font.IsItalic = true;

style.Font.Underline = FontUnderlineType.None;

style.IsFormulaHidden=true;

//style.VerticalAlignment = TextAlignmentType.Distributed;

//----------------------------------

//Set ItemHeaderBold style

//----------------------------------

styleIndex = myExcel.Styles.Add();

style = myExcel.Styles[styleIndex];

style.Font.Name = "Arial";

style.Font.Size = 9;

style.Custom = "_(* #,##0_);_(* (#,##0);_(* \"-\"??_)";

style.Font.IsBold = true;

style.HorizontalAlignment = TextAlignmentType.Left;

style.IsTextWrapped = false;

style.Font.IsItalic = false;

style.Font.Underline = FontUnderlineType.None;

style.IsFormulaHidden=true;

//style.VerticalAlignment = TextAlignmentType.Distributed;

//----------------------------------

//Set ItemHeaderBoldTop style

//----------------------------------

styleIndex = myExcel.Styles.Add();

style = myExcel.Styles[styleIndex];

style.Font.Name = "Arial";

style.Font.Size = 9;

style.Custom = "_(* #,##0_);_(* (#,##0);_(* \"-\"??_)";

style.Font.IsBold = true;

style.HorizontalAlignment = TextAlignmentType.Left;

style.VerticalAlignment = TextAlignmentType.Top;

style.IsTextWrapped = true;

style.Font.IsItalic = false;

style.Font.Underline = FontUnderlineType.None;

style.IsFormulaHidden=true;

//style.VerticalAlignment = TextAlignmentType.Distributed;

//----------------------------------

//Set ItemHeaderValue style

//----------------------------------

styleIndex = myExcel.Styles.Add();

style = myExcel.Styles[styleIndex];

style.Font.Name = "Arial";

style.Font.Size = 9;

style.Custom = "_(* #,##0_);_(* (#,##0);_(* \"-\"??_)";

style.Font.IsBold = false;

style.HorizontalAlignment = TextAlignmentType.CenterAcross;

style.IsTextWrapped = false;

style.Font.IsItalic = false;

style.Font.Underline = FontUnderlineType.None;

style.IsFormulaHidden=true;

//style.VerticalAlignment = TextAlignmentType.Distributed;

//----------------------------------

//Set ItemHeaderLeftAlignValue style

//----------------------------------

styleIndex = myExcel.Styles.Add();

style = myExcel.Styles[styleIndex];

style.Font.Name = "Arial";

style.Font.Size = 9;

style.Custom = "_(* #,##0_);_(* (#,##0);_(* \"-\"??_)";

style.Font.IsBold = false;

style.HorizontalAlignment = TextAlignmentType.Left;

style.IsTextWrapped = false;

style.Font.IsItalic = false;

style.Font.Underline = FontUnderlineType.None;

style.IsFormulaHidden=true;

//style.VerticalAlignment = TextAlignmentType.Distributed;

//----------------------------------

//Set ItemHeaderUnderlineValue style

//----------------------------------

styleIndex = myExcel.Styles.Add();

style = myExcel.Styles[styleIndex];

style.Font.Name = "Arial";

style.Font.Size = 9;

style.Custom = "_(* #,##0_);_(* (#,##0);_(* \"-\"??_)";

style.Font.IsBold = false;

style.HorizontalAlignment = TextAlignmentType.CenterAcross;

style.IsTextWrapped = false;

style.Font.IsItalic = false;

style.Font.Underline = FontUnderlineType.Accounting;

style.IsFormulaHidden=true;

//style.VerticalAlignment = TextAlignmentType.Distributed;

//----------------------------------

//Set ItemHeaderUnderlineWrapTextValue style

//----------------------------------

styleIndex = myExcel.Styles.Add();

style = myExcel.Styles[styleIndex];

style.Font.Name = "Arial";

style.Font.Size = 9;

style.Custom = "_(* #,##0_);_(* (#,##0);_(* \"-\"??_)";

style.Font.IsBold = false;

style.HorizontalAlignment = TextAlignmentType.CenterAcross;

style.IsTextWrapped = true;

style.Font.IsItalic = false;

style.Font.Underline = FontUnderlineType.Accounting;

style.IsFormulaHidden=true;

//----------------------------------

//Set ItemUnderline style

//----------------------------------

styleIndex = myExcel.Styles.Add();

style = myExcel.Styles[styleIndex];

style.Font.IsBold = false;

style.HorizontalAlignment = TextAlignmentType.Center;

style.Font.Underline = FontUnderlineType.Accounting;

style.IsTextWrapped = false;

style.IsFormulaHidden=true;

//style.VerticalAlignment = TextAlignmentType.Distributed;

//--------------------------------------------

//Set ItemUnderlineWithWrap style

//-------------------------------------------

styleIndex = myExcel.Styles.Add();

style = myExcel.Styles[styleIndex];

style.Font.IsBold = false;

style.HorizontalAlignment = TextAlignmentType.Center;

style.Font.Underline = FontUnderlineType.Accounting;

style.IsTextWrapped = true;

style.IsFormulaHidden=true;

//style.VerticalAlignment = TextAlignmentType.Distributed;

//----------------------------------

//Set ItemValue style

//----------------------------------

styleIndex = myExcel.Styles.Add();

style = myExcel.Styles[styleIndex];

style.Font.Name = "Arial";

style.Font.Size = 9;

style.Custom = "_(* #,##0_);_(* (#,##0);_(* \"-\"??_)";

style.Font.IsBold = false;

style.HorizontalAlignment = TextAlignmentType.Right;

style.IsTextWrapped = false;

style.Font.IsItalic = false;

style.Font.Underline = FontUnderlineType.None;

style.IsFormulaHidden=true;

//style.VerticalAlignment = TextAlignmentType.Distributed;

//----------------------------------

//Set ItemValueYear style

//----------------------------------

styleIndex = myExcel.Styles.Add();

style = myExcel.Styles[styleIndex];

style.Font.Name = "Arial";

style.Font.Size = 9;

style.Custom = "_(* ###0_);_(* (###0);_(* \"-\"??_)";

style.Font.IsBold = false;

style.HorizontalAlignment = TextAlignmentType.Right;

style.IsTextWrapped = false;

style.Font.IsItalic = false;

style.Font.Underline = FontUnderlineType.None;

style.IsFormulaHidden=true;

//style.VerticalAlignment = TextAlignmentType.Distributed;

//----------------------------------

//Set ItemValueUnderline style

//----------------------------------

styleIndex = myExcel.Styles.Add();

style = myExcel.Styles[styleIndex];

style.Font.Name = "Arial";

style.Font.Size = 9;

style.Custom = "_(* #,##0_);_(* (#,##0);_(* \"-\"??_)";

style.Font.IsBold = false;

style.HorizontalAlignment = TextAlignmentType.Right;

style.IsTextWrapped = false;

style.Font.IsItalic = false;

style.Font.Underline = FontUnderlineType.Accounting;

style.IsFormulaHidden=true;

//style.VerticalAlignment = TextAlignmentType.Distributed;

//----------------------------------

//Set ItemValueDoubleUnderline style

//----------------------------------

styleIndex = myExcel.Styles.Add();

style = myExcel.Styles[styleIndex];

style.Font.Name = "Arial";

style.Font.Size = 9;

style.Custom = "_(* #,##0_);_(* (#,##0);_(* \"-\"??_)";

style.Font.IsBold = false;

style.HorizontalAlignment = TextAlignmentType.Right;

style.IsTextWrapped = false;

style.Font.IsItalic = false;

style.Font.Underline = FontUnderlineType.DoubleAccounting;

style.IsFormulaHidden=true;

//style.VerticalAlignment = TextAlignmentType.Distributed;

//----------------------------------

//Set ItemValueTextWrap style

//----------------------------------

styleIndex = myExcel.Styles.Add();

style = myExcel.Styles[styleIndex];

style.Font.Name = "Arial";

style.Font.Size = 9;

style.Custom = "_(* #,##0_);_(* (#,##0);_(* \"-\"??_)";

style.Font.IsBold = false;

style.VerticalAlignment = TextAlignmentType.Top;

style.HorizontalAlignment = TextAlignmentType.Left;

style.IsTextWrapped = true;

style.Font.IsItalic = false;

style.Font.Underline = FontUnderlineType.None;

style.IsFormulaHidden=true;

//style.VerticalAlignment = TextAlignmentType.Distributed;

//----------------------------------

//Set ItemValuePercent style

//----------------------------------

styleIndex = myExcel.Styles.Add();

style = myExcel.Styles[styleIndex];

style.Font.Name = "Arial";

style.Font.Size = 9;

style.Custom = "0.00%";

style.Font.IsBold = false;

style.HorizontalAlignment = TextAlignmentType.Right;

style.IsTextWrapped = false;

style.Font.IsItalic = false;

style.Font.Underline = FontUnderlineType.None;

style.IsFormulaHidden=true;

//style.VerticalAlignment = TextAlignmentType.Distributed;

//----------------------------------

//Set ItemValue5Decimal style

//----------------------------------

styleIndex = myExcel.Styles.Add();

style = myExcel.Styles[styleIndex];

style.Font.Name = "Arial";

style.Font.Size = 9;

style.Custom = "_(* #,##0.00000_);_(* (#,##0.00000);_(* \"-\"??_)";

style.Font.IsBold = false;

style.HorizontalAlignment = TextAlignmentType.Left;

style.IsTextWrapped = false;

style.Font.IsItalic = false;

style.Font.Underline = FontUnderlineType.None;

style.IsFormulaHidden=true;

//style.VerticalAlignment = TextAlignmentType.Distributed;


#4

Maybe it’s a bug in v3.6.1. Please download and try Aspose.Cells v3.9.