Object Refernce not set to an instance of an object

Mar 18, 2011 at 6:50 PM

Hi all,

 

I developed a custom ASP.NET froms to integrate them in a sharepoint application, to update an Excel file from these Forms.

I am getting a problem with the file wich is located in a shared folder. When i get the ExcelPackage, i don't have a problem but wehn accessing to a specific Range of cells, i don't get anything.

Here is My code

 

           FileInfo info = new FileInfo(filePath);
            using (ExcelPackage exPckg = new ExcelPackage(info))
            {
                int delay = int.Parse(ICUtilities.GetConfigValue(SPContext.Current.Web, "Delay"));

               //Here i'm obliged to wait some time to get the instance of the worksheets, else it catch an exception              

                WaitUntilExcelOK(exPckg, delay);
                var exWshts = exPckg.Workbook.Worksheets[workSheet];
               
                //Here i am getting the issue exWshts.Celss : Object Refrence not set to an instance of an object.
                var exRange = exWshts.Cells[rowBegin, columnCode, rowEnd, columnCode];


                var enumRange = exRange.GetEnumerator();

                

Is there something wrong in my code. Why i am able to get the excel file, the worksheet but not the Cells?

Could you help me it's very urgent !!!

Thank you!

 

Coordinator
Mar 21, 2011 at 8:08 AM

Hi,

First make sure you use the latest version 2.8.0.2 (there has been a few issues related to defined names previously). Make sure you dont use any unsupported features in your template (have a look at the FAQ).

Jan