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
 How to fix the workbook name

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 - 09/18/2022 : 8:09:21 PM
If I Make a worksheet, the workbook name become something like this.
'Book3 - minuschart'

When I make a new worksheet like below.
wks_minus = op.new_sheet('w', 'minuschart')

But later when I want to refer to the book.
I have to refer to the workbook as below..

wb = op.find_book('w', 'Book3')

Is there any way to fix the workbook name as I want when making the worksheet?
Or Do I have to make a workbook and then make a worksheet linked to it?

Since the naming of the book keeps changing everytime I make a worksheet, I'm having a hard time referring to the workbook I want.

Please help ^^ㅠㅠ

john
5   L A T E S T    R E P L I E S    (Newest First)
minimax Posted - 09/20/2022 : 03:33:34 AM
Good to know it is solved now.

There is some further comments:

The 2nd argument in new_sheet() is a kind of dynamic.

When it is a valid short name, it will be set as the short name of the book,
when it is not, it will be set as the long name of the book.

And underbar is not a valid character for short name in Origin.

See more in
https://www.originlab.com/doc/en/Origin-Help/ChildWindow-Names
fly1342 Posted - 09/20/2022 : 01:36:06 AM
Thank you very much for your support.

I was keep trying ..
op.new_sheet('w', 'plus_chart')

But it didn't work.
But when I tried below it worked.

op.new_sheet('w', 'plusBook')

Seems that if underbar is in the naming, it doesn't get applied as the Book name.

I should have tried it... Sorry and Thanks for your support!

john
minimax Posted - 09/19/2022 : 9:47:19 PM
Hi,

Sorry that we are not very sure what you need.

1. You can specify the book name on new sheet moment, like
wks=op.new_sheet('w', 'hello')

but note that it will try enumeration if there already exists a book named as "hello".


2. the book name does not affect the subsequent load excel action, as long as you have the worksheet object. like
wks=op.new_sheet('w')
f = op.path('e')+r'Samples\Graphing\Excel Data.xls'
wks.from_file(f)


3. If you do need the book name, you can try
wks=op.new_sheet('w')
wb=wks.get_book()
print(wb.name)
wb.name='hello'  #rename short name
wb.lname='world'  #rename long name



fly1342 Posted - 09/19/2022 : 7:42:31 PM
The question was how to change the book name.
When I make a new sheet the book name keeps changing
Book1 Book2 Book3 .. etc.

What I want to do is after making a new worksheet by loading excel.
I want to refer to the following worksheet(workbook) and add some calculations to make a new worksheet.

I can make a new worksheet by adding a sheet with the above method that you mentioned..

But I have to refer to the Worksheet that I loaded excel with.
But when I load excel with the below method.

op.new_sheet()

The Book name is made randomly.
So I want to know how I could fix the book name to a specific name.

So I can refer to the book with the following method below.
wb = op.find_book('w', 'Book_name')

Since if I don't fix the Book name, it keeps changing everytime I make a new worksheet.



john
minimax Posted - 09/19/2022 : 05:44:07 AM
Hi,

Please try using add_sheet()

wb=op.find_book('w','Book3')
wks=wb.add_sheet()

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