The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Python
 Open Excel File as Worksheet
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

fly1342

Korea
7 Posts

Posted - 08/29/2022 :  04:42:27 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
When I click the Text Button 'Open File'
I want a File Browser to Pop up so that the user can double click the excel file that they want.

Then when they push ok I want this excel file to be opened as a worksheet.



I have succeded in making the Text Button and running some codes by clicking on the button.

And I know how to open a worksheet by 'hard-coding' the excel file location like below.

wks = op.new_sheet()
wks.from_file(os.path.join(op.path('e'), 'Samples', 'Graphing', 'Test-before.xlsx'))


But I can't find how to open a file browser by clicking the button
and how it can be uploaded as a new worksheet right away without any other user actions.

Can someone help please? ^^;

john

YimingChen

1617 Posts

Posted - 08/29/2022 :  08:49:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Can you try:

import originpro as op
file = op.file_dialog('*.xlsx')
if file:
    print(file)

James

Edited by - YimingChen on 08/29/2022 2:38:00 PM
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000