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
 All Forums
 Origin Forum for Programming
 Forum for Python
 Open Excel File as Worksheet

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
fly1342 Posted - 08/29/2022 : 04:42:27 AM
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
1   L A T E S T    R E P L I E S    (Newest First)
YimingChen Posted - 08/29/2022 : 08:49:19 AM
Can you try:

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

James

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000