Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Interop.Excel to open excel document. Too few worksheets is loaded
    primarykey
    data
    text
    <p>I'm having a problem with the <code>Microsoft.Office.Interop.Excel</code> api (using C#). Once I load an existing .xls file using the method shown beneath, and then requests a specific worksheet, that I know for a fact exists within the .xls file, I just get an exception. </p> <p>The .xls file I load is huge, and got about 35 worksheets, but the strange thing is that it seems like only the first 3 worksheets of the document is ever loaded.</p> <pre><code>//Code to load document var xlApp = new Microsoft.Office.Interop.Excel.Application(); var xlWorkBook = xlApp.Workbooks.Open("PathAndNameOfMyFile.xls", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); //code that fails or just returns bad ansvers: //This code just returns a list of 3 worksheets var test = xlWorkBook.Worksheets.Cast&lt;Worksheet&gt;().ToList(); //The first 3 worksheets loads fine, but not the fourth: var sheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);//ok sheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(2);//ok sheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(3);//ok sheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(4);//fails //also the command xlWorkBook.Worksheets.Count returns 3. </code></pre> <p>So does anyone have an idea of why this is the case? Any ideas wold be greately appreciated.</p> <p>UPDATE: When opening the xls file I discovered that it actually seems like excel interop opens a referenced xla file within the xls file instead. If this is the case, that would explain why the number of sheets returns wrong - have anyone seen this behaviour before?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload