Skip to content

Infragistics Community Forum / Web / Ignite UI for jQuery / Excel – "Value cannot be null. Parameter name: key" error when saving

Excel – "Value cannot be null. Parameter name: key" error when saving

New Discussion
Paul Decristoforo
Paul Decristoforo asked on Sep 18, 2018 7:26 PM

Hello,

I’m receiving a “Value cannot be null. Parameter name: key” error when saving an Excel workbook. I’ve pretty much stripped everything out of the workbook and I’ve narrowed it down to the attached example file.

To duplicate this, just run the following code on the attached file:

Workbook workbook = Workbook.Load(@”C:\buggedspreadsheet.xlsx”);

workbook.Worksheets[1].Rows.Remove(2);

workbook.Save(@”C:\Users\Paul\Downloads\new.xlsx”);

This is a critical issue for us as we’ve built a process around the Infragistics Excel functionality that needs to run everyday. We have multiple worksheets that this started happening in, and I’m unable to track down the underlying problem. Please provide more information on this error.

Thanks,

Paul

buggedspreadsheet

Sign In to post a reply

Replies

  • 0
    Zdravko Kolev
    Zdravko Kolev answered on Dec 15, 2015 12:47 PM

    Hello Paul,

    Thank you for contacting us.

    I will need more information in order to reproduce the issue and to investigate it further for you. Could you please share a small sample or a code snippet, along with details like: exact product version and when this issue started to appear.

    Looking forward to hearing from you.

    • 0
      Paul Decristoforo
      Paul Decristoforo answered on Dec 15, 2015 2:34 PM

      Thanks for the quick response.

      The version I am using is 2015.1.2112.

      I provided a code snippet and example file in my initial post. Did you not get those? Just run the code using the attached xlsx file and the issue should reproduce on the "workbook.Save(@"C:\Users\Paul\Downloads\new.xlsx");" call.

      Thanks,

      Paul

      • 0
        Zdravko Kolev
        Zdravko Kolev answered on Dec 16, 2015 8:43 AM

        Hello,

        In the initial post there was one xlsx file with empty rows and just one value in cell A10 (number 1) and 3 rows of code. In order to create a sample I will need more code and information. The thread is under "ASP.NET MVC Helpers" section and I am wondering if it is related to them.

        Is it possible for you to provide a small sample that is showing the issue, this would be highly appreciated.

      • 0
        Paul Decristoforo
        Paul Decristoforo answered on Dec 16, 2015 3:17 PM

        Yes, that is the file where the bug occurs. Please use the code I provided (Remove that exact line only) with that exact file (don't make any changes to the file). The error should occur even though there is not much in the file. This was one of the points I made in my original post. I removed most information from the file to try to determine what the issue was. The file I've provided is a bare-bones example where the issue duplicates. The error is very non-descriptive and I wish I could provide you more information, but I cannot.

        Please let me know if you are able to re-create the error with the code and the file I provided.

        Thanks,

        Paul

      • 0
        Zdravko Kolev
        Zdravko Kolev answered on Dec 17, 2015 10:10 AM

        Hello,

        I loaded the file with our online sample Save/Load Excel files, and everything was okay. You can try it yourself from the hyperlink below:

        https://www.infragistics.com/samples/aspnet/infragistics-excel/save-load-excel-files

        Could you please let me know what is the version of our product that you are using.

      • 0
        Paul Decristoforo
        Paul Decristoforo answered on Dec 17, 2015 2:26 PM

        I've already mentioned in the second post that I am using version 2015.1.2112.

        The link you provided does not use the code snippet I provided, so it is useless for duplicating the problem. Please use the following (the paths can be changed, but the middle line must be run to duplicate this):

        Workbook workbook = Workbook.Load(@"C:\buggedspreadsheet.xlsx");

        workbook.Worksheets[1].Rows.Remove(2);

        workbook.Save(@"C:\Users\Paul\Downloads\new.xlsx");

        Thanks,

        Paul

      • 0
        dhairya patel
        dhairya patel answered on Sep 11, 2018 12:39 PM

        We have similar issue with following code which we use to convert .xls to .xlsx. It fails to convert some of the files. Is this the known issue in Vol 13.1 for WinForms?

                public static void ConvertXLStoXLSX(string oldFile, string newFile)
                {
                    var formatt = Infragistics.Documents.Excel.Workbook.GetWorkbookFormat(oldFile);
                    Workbook wb = Infragistics.Documents.Excel.Workbook.Load(oldFile);
                    wb.SetCurrentFormat(WorkbookFormat.Excel2007);
                    wb.Save(newFile);
                }

        Here is the stack trace.

           at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
           at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
           at Infragistics.Documents.Excel.Serialization.WorkbookReferenceBase.GetScopeDictionary(String name)
           at Infragistics.Documents.Excel.Serialization.WorkbookReferenceBase.GetNamedReference(String name, Object scope, Boolean createIfNotPresent)
           at Infragistics.Documents.Excel.Formula.InitializeSerializationManagerVisitor.RetainNamedReference(NamedReferenceBase& namedReferenceBase)
           at Infragistics.Documents.Excel.Formula.InitializeSerializationManagerVisitor.VisitNameToken(NameToken token)
           at Infragistics.Documents.Excel.FormulaUtilities.Tokens.NameToken.Accept(FormulaTokenVisitor visitor)
           at Infragistics.Documents.Excel.FormulaUtilities.Tokens.FormulaTokenVisitor.VisitAll()
           at Infragistics.Documents.Excel.Formula.InitializeSerializationManager(WorkbookSerializationManager manager, Worksheet owningWorksheet)
           at Infragistics.Documents.Excel.Serialization.WorkbookSerializationManager.InitializeReferencesHelper.FormulaCallback(Worksheet owningWorksheet, Formula formula)
           at Infragistics.Documents.Excel.Workbook.IterateFormulas(IEnumerable`1 namedReferences, IterateFormulasCallback callback)
          at Infragistics.Documents.Excel.Serialization.WorkbookSerializationManager.InitializeReferences()
           at Infragistics.Documents.Excel.Serialization.Excel2007.Excel2007WorkbookSerializationManager.InitializeReferences()
           at Infragistics.Documents.Excel.Serialization.WorkbookSerializationManager.Save()
           at Infragistics.Documents.Excel.Workbook.SaveXLSXFile(Stream stream, IPackageFactory packageFactory)
           at Infragistics.Documents.Excel.Workbook.SaveHelper(Stream stream, IPackageFactory packageFactory)
          at Infragistics.Documents.Excel.Workbook.Save(String fileName, IPackageFactory packageFactory)
           at Infragistics.Documents.Excel.Workbook.Save(String fileName)
        

        Any Suggestions?

      • 0
        Alan Halama
        Alan Halama answered on Sep 18, 2018 7:26 PM

        I recommend downloading 18.1 and testing with the same excel file to see if this has already been addressed.  If it hasn't, we need an excel file that we can use to reproduce the issue so that we can look into what is happening.

        Note that you should post in the Ultimate UI for Windows Forms forum rather than the Ignite UI for JavaScript forum for questions on the Windows Forms toolset.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Paul Decristoforo
Favorites
0
Replies
8
Created On
Sep 18, 2018
Last Post
7 years, 5 months ago

Suggested Discussions

Created by

Created on

Sep 18, 2018 7:26 PM

Last activity on

Feb 12, 2026 9:16 AM