761
Views
7
Comments
[Excel Package] Unable to cast object
Question
excel-package
Web icon
Forge asset by Alfaro
Hi,
I am having trouble with the write_range. When trying to add a List as an object, I get an error message:

UserImage.jpg
Miguel Morujão
I'm having the same problem...
UserImage.jpg
Hans de Vries
Same issue here. Any chance anyone has already migrated this extension to the new (record)list types?
2017-03-28 23-52-32
Cátia Oliveira
New version with the correction. Version from 31 of March.
2017-09-14 06-13-58
Raymond Reyes

This is the error I got. "Unable to cast object of type 'OfficeOpenXml.ExcelPackage' to type 'OfficeOpenXml.ExcelWorksheet'."

UserImage.jpg
Bruno Machado
Staff

Raymond Reyes wrote:

This is the error I got. "Unable to cast object of type 'OfficeOpenXml.ExcelPackage' to type 'OfficeOpenXml.ExcelWorksheet'."

I was having this error as well, but i spotted a mistake of mine.The cell writeRange asks for a worksheet object and not a workbook object. Because they are both objects, the platform suggests both of them.

You need to get the worksheet first (either by index or name) and use it there. Dont forget to cast you Record list into object.


2022-02-20 02-44-30
Radhika K P

Bruno Machado wrote:

Raymond Reyes wrote:

This is the error I got. "Unable to cast object of type 'OfficeOpenXml.ExcelPackage' to type 'OfficeOpenXml.ExcelWorksheet'."

I was having this error as well, but i spotted a mistake of mine.The cell writeRange asks for a worksheet object and not a workbook object. Because they are both objects, the platform suggests both of them.

You need to get the worksheet first (either by index or name) and use it there. Dont forget to cast you Record list into object.


 Hi Bruno,

I've done all the steps as you mentioned. But still, I'm unable to write a column of values into the excel sheet. What I'm trying to achieve is to replace a column of values in an existing excel sheet with the values from application. I tried to write into an empty sheet as well.  But still I couldn't get the values written. Cell_WriteColumnRange works for me. But that's not what I need. Would you be able to guide me here?

 

Capture.JPG
UserImage.jpg
Sherly S

Anybody has a solution for this problem? I got the same error log because I 'Unable to cast object of type 'System.String' to type 'OutSystems.HubEdition.RuntimePlatform.Db.RecordList'.' 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.