Dynamically creating Excel 2007 worksheet
-
Tuesday, April 27, 2010 12:57 PM
I have a document-level solution that supports Excel 2003, which needs to support to Excel 2007.
I'm using VS 2008 (VSTO 3).
The solution does not work in Excel 2007 since Microsoft.Office.Tools.Excel.Worksheet doesn't supports
a constructor that takes IHostItemProvider and IRuntimeCallback. It also doesn't exposes the RuntimeCallback member anymore.
The constructor
public TemplateSheet(IRuntimeServiceProvider runtimeCallback, Microsoft.Office.Interop.Excel.Worksheet worksheet) : base(((IHostItemProvider)(runtimeCallback.GetService(typeof(IHostItemProvider)))), runtimeCallback, worksheet.CodeName, null, worksheet.Name) { this.RuntimeCallback = runtimeCallback; }TemplateSheet inherits from Microsoft.Office.Tools.Excel.Worksheet
I've found a few comments about the issue in various sites, but still it's not clear how to implement the suggested solutions.
https://community.altiusconsulting.com/blogs/noelphillips/archive/2008/07/23/vsto-2008-tools-excel-worksheet-object-from-application-level-add-in.aspx
The post below specifies a solution, by using ISupportInitializeControl.InitializeControl method,
I'd appreciate it if the solution can be furthered explained, looking at the method's documentation
I didn't understand what are IHostItemProviderExtended and IServiceProvider
http://social.msdn.microsoft.com/Forums/en-US/vsofficetools2008prerelease/thread/2c20bc34-91fa-4da9-8267-6b6498df8e8a
Thanks

