2

I try to import excel file on Genexus. I use .open to make sure that selected file is excel file like this.


&ret = &w_Excel.Open(&w_FilePath)               
&w_Excel.Close()

If &ret = 0
//import excel deta
Else
//show message 'this is not excel file'
EndIf

On the develop environment, this code works well. But another environment, this one does not.

I'm guessing that .open method returns 0 whether the selected file is excel file or is not.

I understood that .open returns 0 when the excel file was selected. And it returns 10 when other file types. Is it correct?

I'm not sure because this site just says return a Numeric type. https://wiki.genexus.com/commwiki/servlet/wiki?6992,Open+Method,

Does the values that .open returns changes by running enviroment?

VinothRaja
  • 1,405
  • 10
  • 21

2 Answers2

1

According to the documentation 0 (zero) means everything went Ok, but there are some more codes you should check for.

EDIT: Try to get the ErrorDescription for detailed info about the error.

&w_Excel.ErrorDescription

sebagomez
  • 9,501
  • 7
  • 51
  • 89
0

Check that the file exists before you try to open the file using, for example, a variable &File of type File: If &file.exists() ...

The open() method will create the file if the file doesn't exist.

So first check if the file exists, then open it.

Sergio
  • 122
  • 4