Unplanned
Last Updated: 31 Aug 2020 06:14 by ADMIN
Dimitar
Created on: 31 Aug 2020 06:13
Category: SpreadProcessing
Type: Feature Request
0
Spreadprocessing: Handle the case where the formula starts with a plus (=+)

Handle the case where the formula starts with "=+". Detailed information: https://professor-excel.com/equal-plus-excel-formulas/

Workaround: replace the "=+" with "="

CellRange usedCellRange = workbook.Worksheets[0].UsedCellRange;

for (int rowIndex = usedCellRange.FromIndex.RowIndex; rowIndex <= usedCellRange.ToIndex.RowIndex; rowIndex++)
{
    for (int columnIndex = usedCellRange.FromIndex.ColumnIndex; columnIndex <= usedCellRange.ToIndex.ColumnIndex; columnIndex++)
    {
        CellSelection cell = workbook.Worksheets[0].Cells[rowIndex, columnIndex];
       

        FormulaCellValue formulaCellValue =cell.GetValue().Value as FormulaCellValue;
        if (formulaCellValue == null)
        {
            continue;
        }
        CellValueFormat format = cell.GetFormat().Value;
        string resultValueAsString = formulaCellValue.GetValueAsString(format);
        Console.WriteLine(resultValueAsString);
        if (resultValueAsString.StartsWith("=+"))
        {
            resultValueAsString = resultValueAsString.Remove(1, 1);
            cell.SetValue(resultValueAsString);
        }
    }
}
radSpreadsheet.Workbook = workbook;

 

0 comments