我正在爲SharePoint 2013的ItemAdded編寫事件接收器。我使用OpenXML來讀取電子表格。當我嘗試打開生活在SharePoint庫中編程的日誌文件,我得到以下錯誤:使用OpenXML打開Excel工作表時,文件包含損壞的數據錯誤
文件包含損壞的數據
的代碼引發此錯誤的塊是:
using (SpreadsheetDocument spreadsheet = SpreadsheetDocument.Open(mstream, false))
using (SpreadsheetDocument logsheet = SpreadsheetDocument.Open(logstream, false))
的第一行傳遞正常,第二行(日誌)中斷。它們都是從流中讀取的。電子表格是在事件觸發時添加的項目,日誌表是SharePoint中當前存在的項目。
電子表格從數據流使用的路徑打開:
string workbookpath = properties.ListItem.Web.Url + "/" + properties.ListItem.File.Url;
和logsheet使用使用它的直接URL數據流開在SharePoint
string logFilePath = "http://SPSiteName/sites/SP/Dropbox/RuntimeLog.xml";
任何幫助或洞察力是極大的讚賞。
我想它作爲一個.xlsx文件。同樣的問題。一個隨機的博客,我讀了關於這個問題的建議,我也嘗試了一個.xml文件 – Tangster