Calendar

<<  mars 2010  >>
lumamejevesadi
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar
Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

(mars 26, 2008 21:41)

On the personal VSTO project I currently work on, I was first working on sheets I had added at design time. I was thinking it would be simpler to be able to generate the worksheets at runtime depending of my needs.

To add a sheet, we can just do something like :

Globals.ThisWorkbook.Worksheets.Add(System.Type.Missing, System.Type.Missing, 1, XlSheetType.xlWorksheet);

However we can note the following things

  • The worksheets added at design time are Microsoft.Office.Tools.Excel.Worksheet
  • The worksheets added at runtime are Microsoft.Office.Interop.Excel.Worksheet
  • The add method :
    • expects only optional arguments
    • its two first arguments (Before and After) must be of type Interop.Excel.Worksheet
    • it will return an Interop.Excel.Worksheet
  • As far as I have seen - after googling quite a lot - there is no way to convert a Tools.Excel.Worksheet to a Interop.Excel.Worksheet

However there are some way (not given or advised by the MSDN) to convert a Interop.Excel.Worksheet to a Tools.Excel.Worksheet (search GetExtendedWorksheet in google).

 

Having these two types and no built in conversion is driving me crazy... I think for now I will continue working with sheets at design time. If you have any advice, leave a comment !

Billets liés

Commentaires

décembre 25. 2009 23:39

Note that in VS 2008 SP1, some extensions methods have been added to facilitate the conversion !

Pierre-Emmanuel Dautreppe

Ajouter un commentaire


 

  Country flag





Live preview

mars 12. 2010 15:35

Powered by BlogEngine.NET 1.2.0.0 | Theme by Pierre-Emmanuel Dautreppe