ExcelError.png (89.9 KB)
Ok, so I’ve created a test method in my project to reproduce the issue. I hope you can get it to run. I’ve also upgraded from ASPOSE Cells 19.2 to 19.5 - with no benefit.
Please provide us with an answer ASAP as we’re releasing next Friday, and this is a part of the system that hasn’t changed. I reiterate: This works PERFECTLY on the old ASPOSE assemblies, it was upgrading to the newest version of ASPOSE.CELLS that caused this to now malfunction. Having broken ASPOSE assemblies is not expected and hugely inconvenient. PLEASE TREAT THIS AS HIGH PRIORITY.
The code is as follow, and the result is attached:
public static Workbook CreateWorkbook()
{
Workbook workbook = new Workbook();
workbook.ChangePalette(_headerColor, 55);
workbook.ChangePalette(_level1Color, 54);
workbook.ChangePalette(_level2Color, 53);
workbook.ChangePalette(_level3Color, 52);
workbook.ChangePalette(_growthColor, 51);
workbook.ChangePalette(_prudentColor, 50);
workbook.ChangePalette(_stableColor, 49);
workbook.ChangePalette(_problemColor, 48);
workbook.ChangePalette(_correctColor, 47);
workbook.ChangePalette(_highlightColor, 46);
return workbook;
}
private void AddTestPage()
{
if (_workbook == null)
{
_workbook = CreateWorkbook();
}
int index = _workbook.Worksheets.Add();
Worksheet testSheet = _workbook.Worksheets[index];
testSheet.Name = "TestSheet";
DateTime date = new DateTime(2019,01,01);
int maxRow = 900;
for (int i = 5; i < maxRow; i++)
{
PutValue(index, i, 0, "Arial", 10, false,false,FontUnderlineType.None,TextAlignmentType.Left,TextAlignmentType.Top, "dd MMM yyyy", date, false);
date = date.AddDays(1);
}
string percentageFormat = GlobalSettings.PercentageFormat; //
PutFormula(index, 5, 0, null, 10, true, FontUnderlineType.None, TextAlignmentType.Right, percentageFormat, "=(A" + maxRow + "- A6)/365", true);
PutValue(index, 4, 11, "Arial", 10, false, false, FontUnderlineType.None, TextAlignmentType.Left, TextAlignmentType.Top, percentageFormat + " %", 0.0701, false);
PutFormula(index, 5, 11, null, 10, true, FontUnderlineType.None, TextAlignmentType.Right, percentageFormat + " %", "=(1+R[-1]C[0])^($A$6)-1", true);
string workBookFile = "C\:PerformanceFeeComposition_" + Guid.NewGuid().ToString() + ".xls";
_workbook.Save(workBookFile, SaveFormat.Excel97To2003);
System.Diagnostics.Process.Start(workBookFile);
}
public void PutValue(int worksheetIndex, int rowIndex, int columnIndex, string fontName, int fontSize, bool isBold, bool isItalic, FontUnderlineType underlineType, TextAlignmentType horizontalAlignment, TextAlignmentType verticalAlignment, string customStyle, object value, bool isTextWrapped = false)
{
if (_leaveZeroValuesEmpty && (value is int && (int)value == 0 || value is decimal && (decimal)value == 0) ||
_leaveNullDatesEmpty && value is DateTime && (DateTime)value == GlobalSettings.NullDate)
{
value = string.Empty;
}
_workbook.Worksheets[worksheetIndex].Cells[rowIndex, columnIndex].PutValue(value);
Style style = _workbook.Worksheets[worksheetIndex].Cells[rowIndex, columnIndex].GetStyle();
style.Font.Name = string.IsNullOrEmpty(fontName) ? FontNameGeorgia : fontName;
style.Font.Size = fontSize;
style.Font.IsBold = isBold;
style.Font.IsItalic = isItalic;
style.Font.Underline = underlineType;
style.HorizontalAlignment = horizontalAlignment;
style.VerticalAlignment = verticalAlignment;
style.Custom = string.IsNullOrEmpty(customStyle) ? string.Empty : customStyle;
style.IsTextWrapped = style.IsTextWrapped ? style.IsTextWrapped : isTextWrapped;
_workbook.Worksheets[worksheetIndex].Cells[rowIndex, columnIndex].SetStyle(style);
}
protected void PutFormula(int worksheetIndex, int rowIndex, int columnIndex, string fontName, int fontSize, bool isBold, FontUnderlineType underlineType, TextAlignmentType horizontalAlignment, string customStyle, string formula, bool isR1C1)
{
try
{
_workbook.Worksheets[worksheetIndex].Cells[rowIndex, columnIndex].SetFormula(formula, isR1C1, true, null);
/*
if (isR1C1)
{
_workbook.Worksheets[worksheetIndex].Cells[rowIndex, columnIndex].R1C1Formula = formula;
}
else
{
_workbook.Worksheets[worksheetIndex].Cells[rowIndex, columnIndex].Formula = formula;
}*/
Style style = _workbook.Worksheets[worksheetIndex].Cells[rowIndex, columnIndex].GetStyle();
style.Font.Name = string.IsNullOrEmpty(fontName) ? FontNameGeorgia : fontName;
style.Font.Size = fontSize;
style.Font.IsBold = isBold;
style.Font.Underline = underlineType;
style.HorizontalAlignment = horizontalAlignment;
style.Custom = string.IsNullOrEmpty(customStyle) ? string.Empty : customStyle;
_workbook.Worksheets[worksheetIndex].Cells[rowIndex, columnIndex].SetStyle(style);
}
catch (Exception ex)
{
Aspose.Cells.Cell cell = _workbook.Worksheets[worksheetIndex].Cells[rowIndex, columnIndex];
Style style = cell.GetStyle();
cell.PutValue(ex.Message);
style.Font.Color = Color.Red;
style.Font.IsBold = true;
cell.SetStyle(style);
}
}