Search code examples
c#excelasposeaspose-cells

Aspose formula having a column index changing issue


I am using aspose 8.0.1.0 in a windows (C#) application. When I set the formula for a column as

sheet1.Cells[3, 2].Formula = "='Supplies - Factor'!G757222";

the formula automatically changed to

"='Supplies - Factor'!G36326"

I have verified it using debugger. If I set the formula to

"='Supplies - Factor'!G757222"

Then it automatically changed to

"='Supplies - Factor'!G36326"

Any idea why this is happening?


Solution

  • Please try the latest version/fix: Aspose.Cells for .NET v8.9.0 (you may download it here). Please try to save the file to XLSX or other advanced MS Excel file formats (instead of older XLS). I have tested your scenario/case using the following sample code, it works fine and the formula is inserted correctly and does not change. e.g Sample code:

    //Instantiate a new workbook
            Workbook workbook = new Workbook();
            //Get the default worksheet (first worksheet)
            Worksheet sheet1 = workbook.Worksheets[0];
            sheet1.Name = "Supplies - Factor";
            //Enter a value to the cell
            sheet1.Cells["G757222"].PutValue("Testin...");
            //Add the formula to the C4 cell
            sheet1.Cells[3, 2].Formula = "='Supplies - Factor'!G757222";
            //Save the Excel file
            workbook.Save("e:\\test2\\out1formulatest1.xlsx", SaveFormat.Xlsx);
    

    I am working as Support developer/ Evangelist at Aspose.