This project has moved. For the latest updates, please go here.

ExcelPackage Constructor hangs in Event Reciever

Aug 10, 2012 at 5:19 PM
Edited Aug 10, 2012 at 5:27 PM

I am simply trying to get values from an excel spreadsheet uploaded to a document library in Sharepoint. I have placed the code in an event receiver similar to this link :


Everything works properly until using (ExcelPackage ep = new ExcelPackage() ). The sublist "testthis" is never populated and the event receiver hangs. I checked to make sure the openBinaryFile method is returning a non empty byte array and also that the memory stream is populated. Again, everything works until that using declaration.


public override void ItemAdded(SPItemEventProperties properties)
            SPDocumentLibrary someLibrary;
            web = properties.OpenWeb();
            if (web.Lists[properties.ListTitle] is SPDocumentLibrary)
                someLibrary = (SPDocumentLibrary)web.Lists[properties.ListTitle];

            if (properties.ListItem.File != null)
                SPListItemCollection table = web.Lists["testthis"].Items;
                SPListItem newRow = table.Add();
                MemoryStream fs = new MemoryStream();
                fs.Write(properties.ListItem.File.OpenBinary(), 0, Convert.ToInt32(properties.ListItem.File.TotalLength));

                using (ExcelPackage ep = new ExcelPackage())


		newRow["Title"] = "test";