Excel file with Chart Sheet as first sheet - Exception

excel

#1

Hello all!

I have an Excel file in which the first sheet of the Excel file is Chart Sheet. This special sheet does not contain rows, columns, or cells, just a chart, like this:

When trying to get the range from the associated table on the second sheet (named “Dados”), UiPath returns an Exception:

After many attempts to understand why this happens, I have discovered that if the first sheet of the Excel file is a Chart Sheet (with no columns, no rows, no cells) UIPath gives the error.
If I change the file, and move the Chart Sheet to be second in order, then UIPath can execute the “Get Table Range” activity with no errors. So the problem here is when the first sheet is a special chart.

Does everybody has the same error behaviour?
(I am wondering if this is an issue of UIPath or my old Excel 2007).
If so, is it possible to change the order of the sheets in the Excel file?

I am attaching the Workflow and Excel file for you to simulate it.
ChartExcel.zip (15.1 KB)

Regards


#2

I don’t get the error if I don’t use the application scope and when first sheet is a special chart.(not sure if it is programatically correct)


#4

Hi @Thiago

Actually you are getting this error because your cast is wrong because you are using “Excel Activity Scope” with it.

Namespace: Microsoft.Office.Interop.Excel
Assembly: Microsoft.Office.Interop.Excel (in microsoft.office.interop.excel.dll)

This interface only gives you worksheets - not charts.
https://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.worksheets(v=office.11).aspx

Go to Remark section :slight_smile:

On the other hand, if you will use “Workbook Activities” so it’s instance _Workbook.Sheets gives you a Sheets instance.

https://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.sheets(office.11).aspx

Go to Remark section :slight_smile:

The interfaces are not assignable to each other; therefore, you are getting the COM error.

i have not yet tried so do not know it’s possible to get an instance of the Worksheets interface through the “Office Primary Interop Assemblies”.

As long as you will use workbook activities i.e. _Workbook.Worksheets property instead of the _Workbook.Sheets property, you should get an instance of Sheets that only returns Worksheet objects for these charts objects etc. as i explained above.

ChartExcel.zip (15.0 KB)

Regards…!!
Aksh


Error: 'Microsoft.Office.Interop.Excel.Worksheet'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D8-0000-0000-C000-000000000046}' failed
How to read multiple excel columns in DataTable
Difference between Excel and Workbook activities
Hello, I'm confused in the Get Table Range section that people need help? If there is an example, it is great. Thank you
#5

Thanks @vvaidya and @aksh1yadav!

Using the Workbook Activites (without application scope) solves the problem. :clap:


#6

Hey @Thiago

Here this post is just for your update that now You will be able to use Excel file having chart as a sheet with Excel application scope and All Excel Related Activities..

I have tested it and it is working as per expectation :slight_smile:

Here are the Information about The Excel Activities package version in which this issue has been Fixed :slight_smile:

Hope this information will be useful for other users :slight_smile:

Package Version - 2.0.6479.13204

Published on - 10/08/2017
   
Issues has been Fixed with Excel Related, are as follows:slight_smile:  

1. Fix Excel Application activities failing if the workbook contained Charts 
2. Fix Workbook Get Table Range for Pivot tables throwing exception
3. Fix Workbook Read Range 'too many parameters' error
4. Fix Workbook Read Range 'Expression expected' error
5. Add Headers option for Read Range is set to true by default

Regards…!!
Aksh


#7

Thanks @aksh1yadav for the Update!