cancel
Showing results for 
Search instead for 
Did you mean: 

Browse for Excel file

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Hello everyone!

I am working on some automation that will require specifying an Excel file for read and write.

Is it possible to browse for Excel file using NativeFileBrowser from UI Styler, or is it restricted only to PRT file format? Shall I go for Windows forms instead?

3 REPLIES

Re: Browse for Excel file

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Yes it is possible. You can even add a filter in the file browser to accept only .xls format. The FileSelection class has a SetFileter method.

 

https://docs.plm.automation.siemens.com/data_services/resources/nx/10/nx_api/en_US/custom/open_c++_r...

 

Elias.

Re: Browse for Excel file

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Thank you, got it. 

 

Is it possible to use this browser to set the name of the new file that does not yet exists? It works if I point to the existing file, but it returns error if file does not exist. What if I need to create a new file? Is it possible?

Re: Browse for Excel file

Siemens Phenom Siemens Phenom
Siemens Phenom

Unfortunately, it is not possible to set a non-existing name. This is a capability that is sorely needed. Please file an IR with GTAC requesting this to make your vote heard.

 

A Block Styler Workaround is to use 2 blocks: a FolderBrowser to select the folder and a String to specify the filename. This works if you are always creating a new file, but is a bit ugly if you want to have the possibility of new or existing.

 

Other alternatives are the .NET System.Windows.Forms.FileDialog class. It contains methods for specifying paths, extensions, existence checking, etc.