"Ghost" sheet objects returned while using Excel.Application

M

mjohnson

I am trying to parse a spreadsheet using JavaScript and I'm finding
"ghost" Sheet objects in the file. It seems that if the user copied
and renamed the file and then deleted some tabs that those tabs are
still accessible programmitcally. If I view the excel file in Excel or
try to load it into SQL Server then the "ghost" tabs don't show up.
But if I read it using the Excel.Application in JavaScript then they
show up. Here's an excerpt of what I'm doing:


var wb = XLS.WorkBooks.Open(fname);
var ws = XLS.Sheets;
var cell = null;
var e = new Enumerator(XLS.Sheets);
for(;!e.atEnd(); e.moveNext() )
{
Sheet = e.item();
cell = Sheet.Cells(1,GetPos("D"));
WScript.Echo( "\t"+Sheet.Name+" -- " + cell.Value );
}

this is the output:

Power Survey 1190 ALLENE.1 - Complete.xls:
Basic Power Audit -- ATLN-CPOP-6
Fuse Panel Sheet -- ATLN-CPOP-6
Fuse Panel Sheet (2) -- 250 WILLIAMS (FOCAL)
Fuse Panel Sheet (3) -- 250 WILLIAMS (FOCAL)

I cannot visually see sheets (2) and (3) but I can dump them just fine
with my script. This makes it problematic for me to parse because I
will inadvertantly suck in data that I shouldn't...

The BOL do not describe any useful attribute for the Sheet object to
help me determine how to ignore these false sheets in the workbook. Any
suggestions how to ignore these "ghost" sheets?
thanks for your time,

Mark
 
M

mjohnson

Figured out that I could check the Sheet.Visible attribute and it was 0
for the "ghost" sheets...
 
Top