I'm trying to do the following:
1. Create an empty workbook with Excel 2007 and save it to disk.2. Close Excel3. Open the workbook with the following code:Using spreadSheet As SpreadsheetDocument = SpreadsheetDocument.Open(docName, True)The code throws a subject exception. What am I doing wrong? Any suggestions? Thanks.
If you have closed the previous stream properly, the following code should work properly.
using(SpreadsheetDocument spreadsheetDoc = SpreadsheetDocument.Open(excelFile, true))
Right, it should. The "previous stream" in my case is produced by EXCEL itself: as I said I create an empty workbook using Excel, save it and close Excel. Once more: I do not create workbook using Open XML code, I rather create it with MS Office 2007 component called "Excel".
It looks correct to me. The only possibility that I see is that maybe you are not referring to the file that you think in docName.
I code a direct path to it as a string literal, so it HAS to be correct. I've eve tried to copy it to a different location, the only file in the folder. Same result...