Free Support Forum - aspose.com

Save() method System.NullReferenceException Error

I have an excel template with an .xlsx extension and I have a graphic in it. I want to copy this template and save it with a new name, but the save () method throws a SystemNullException error. I share the code and template below, please help
Foy.zip (Template) (15.8 KB)

string InputPath = Server.MapPath("~/Taslaklar/Foy.xlsx");
Workbook excelWorkbook0 = new Workbook(InputPath);
excelWorkbook0.Worksheets.Add(“Foy1”);
excelWorkbook0.Worksheets[“Foy1”].Copy(excelWorkbook0.Worksheets[“Foy”]);
excelWorkbook0.Save(Server.MapPath("~/Taslaklar/Foy2.xlsx"));

@mehmet_46

Thanks for using Aspose API.

Please download and try the most recent version. It should fix your issue. We have tested your issue with this version and it worked fine. Let us know your feedback.

The problem is still going on. Could it be the case that my .NET framework is version 4.5.2

@mehmet_46

.NET Framework should not be a problem. We will look into this issue and update you asap.

@mehmet_46

Please download the Microsoft Visual Studio 2015 Console Application Project from the following link and run it at your end. It also prints the version number using CellsHelper.GetVersion() method.

Make sure, it prints 17.7.7.0.

Let us know if it runs fine or throws exception and if you still find the issue, please diagnose this issue and narrow down it with this simplified sample project. Please feel free to ask us any question while you do it.

C#

namespace TestProject
{
    class Program
    {
        static void Main(string[] args)
        {
            string strVer = "Version: Aspose.Cells for .NET v" + CellsHelper.GetVersion();

            Console.WriteLine(strVer);
            Debug.WriteLine(strVer);

            //--------------------------------
            //--------------------------------
            string InputPath = "Foy.xlsx";
            Workbook excelWorkbook0 = new Workbook(InputPath);
            excelWorkbook0.Worksheets.Add("Foy1");
            excelWorkbook0.Worksheets["Foy1"].Copy(excelWorkbook0.Worksheets["Foy"]);
            excelWorkbook0.Save(InputPath + ".out.xlsx");

        }
    }
}