Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Excel
123quattro
charting
crashesgpfs
datamap
excel
interopoledde
links
misc
newusers
printing
programming
querydao
sdk
setup
templates
worksheet.functions
  
 
date: Tue, 18 Sep 2007 04:44:01 -0700,    group: microsoft.public.excel.interopoledde        back       


Iterating over all filled cells in VSTO C# plugin for Excel   
Currently I am working on an application that needs to make a graphical 
representation of the contents of an Excel file. For this, I have made a 
graph data structure which I need to fill with all the cells that have a 
numerical value or formula in them. This means that I need something that 
will give me an IEnumerator iterating over all non-empty cells on all 
worksheets of the currently opened workbook.

I tried two things so far, in these code snippets, Connect.excelApp gives 
access to Excel:

IEnumerator e = Connect.excelApp.Cells.GetEnumerator(); // This gives me an 
enumerator of ALL possible cells, including empty ones. Obviously not useful.

I figured I'd better try to iterate over the worksheets first (since these 
seem to be limited), then iterating over the cells inside the worksheet 
hoping that empty ones would be omitted, so I tried:

IEnumerator e = Connect.excelApp.ThisWorkbook.Sheets.GetEnumerator(); // 
Raises an exception "Exception from HRESULT: 0x800A03EC".

Thus, I already got stuck at iterating over the worksheets for a reason I do 
not understand. All I want is either an IEnumerator for all cells in all 
worksheets of the current file or an IEnumerator for all sheets and and 
IEnumerator for cells per sheet for the current file so I can build up a 
graph structure representing the contents of the Excel file. How hard can it 
be? A simple API call I used in a Java library in some other part of the 
tooling we're developing worked like a breeze...
date: Tue, 18 Sep 2007 04:44:01 -0700   author:   Tjaard

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us