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

Opening Workbook with PT/PivotCharts - System.InvalidCastException

Jul 12, 2011 at 1:06 PM
Hi,
I added a chart to my template and now i get a System.InvalidCastException when i open the Workbook. ?!

File
.Copy("template.xlsx", FullFileName & ".xlsx"True) Dim workbook As New XLWorkbook(FullFileName & ".xlsx")

System.InvalidCastException was unhandled
  Message=Unable to cast object of type 'DocumentFormat.OpenXml.Packaging.ChartsheetPart' to type 'DocumentFormat.OpenXml.Packaging.WorksheetPart'.
  Source=ClosedXML
  StackTrace:
       at ClosedXML.Excel.XLWorkbook.LoadSpreadsheetDocument(SpreadsheetDocument dSpreadsheet)
       at ClosedXML.Excel.XLWorkbook.LoadSheets(String fileName)
       at ClosedXML.Excel.XLWorkbook.Load(String file)
       at ClosedXML.Excel.XLWorkbook..ctor(String file)
       at ConsoleApplication1.Testing.Main(String[] sArgs) in C:\Users\D027354\Documents\Visual Studio 2010\Projects\AIX_io_lunpath_details\AIX_io_lunpath_details\Testing.vb:line 205
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
       at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
       at System.Activator.CreateInstance(ActivationContext activationContext)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

Peter
Coordinator
Jul 12, 2011 at 3:21 PM

Thanks, I'll take a look.

Coordinator
Jul 15, 2011 at 3:50 AM

Sorry for the late reply. Life was getting in the way...

I couldn't reproduce the error. Could you please upload the file in the issue tracker tab or send it to me?

Thanks,

Jul 15, 2011 at 7:35 AM

I uploaded the file to the issue tracker

http://closedxml.codeplex.com/workitem/6932