I am trying to upload a excel file onto a moss 2007 site. In the event handler I try to read the file using ExcelPackage. My code is as below...
MemoryStream fileContent = new MemoryStream();
fileContent.Write(properties.ListItem.File.OpenBinary(), 0, Convert.ToInt32(properties.ListItem.File.TotalLength));
using (ExcelPackage package = new ExcelPackage(fileContent))
{
ExcelWorksheet worksheetWR = package.Workbook.Worksheets[1];
.....
}
But I am always receiving the File contains corrupted data error at the using stmt. I have been trying to find a solution for this for quite sometime but so far no break through. Does anyone know how to solve this?
I used MS Office Interop Excel to read the same excel without any errors.