Hi,
I have a requirement where on button click, programatically Ihave to upload an Excel (it could be .xls, .xlsx) file from user local machine to 'shared documents' library and read it (spreadsheets and all) and delete it once completed.
Here, Uploading and deleting to shared documents library code i have done.
Issue is with programatically reading uploaded excel file to 'shared documents' library. I tried some examples with OpenXml but getting error "data is corrupted" while reading stream.
excelSheets = new ExcelHelper().GetExcelSheets(file.fi);
SPFile _file = web.GetFile(string.Format("{0}/Shared Documents/" + _fileUrl, SPContext.Current.Site.RootWeb.Url));//("http://servername:1000/ExcelDocs//ExcelFile.xlsx");
Stream dataStream = file.OpenBinaryStream();
SpreadsheetDocument document = SpreadsheetDocument.Open(dataStream, false);
Workbook workbook = document.WorkbookPart.Workbook;
List<string> _sheets = new List<string>();
Sheets workSheets = workbook.Sheets;
foreach (Sheet s in workSheets)
{
_sheets.Add(s.Name);
}
Regards,
Rahul












