How to control which sheet is visible when a workbook is opened in Excel #957
Replies: 4 comments 8 replies
-
Hi @Jeff-White-AZ , if I understand you correctly, you can try this (select and make the third sheet the active sheet): library(openxlsx2)
wb <- wb_workbook()
for (i in seq_len(10)) {
wb$add_worksheet(as.character(i))
}
wb$set_active_sheet(sheet = 3)
wb$set_selected(sheet = 3)
if (interactive()) wb$open() |
Beta Was this translation helpful? Give feedback.
-
Your first solution, 'wb$workbook$bookViews <- "<workbo ...' worked fine with the qualification that it looked like the XML uses numbers for sheets 0, 1, 2, 3. When I tried setting sheets to 1, I got the second sheet. |
Beta Was this translation helpful? Give feedback.
-
Jan,
Thanks for clarifying the need for selecting the sheet to avoid dangerous
behavior (such as deleting rows on all selected sheets, which I have done
in the past).
I fully sympathize with your issue of not wanting to break existing code.
As I progress with openxlsx2, I would be willing to provide more complete
documentation for you to consider. What is your preference for ways to
provide edits? I've been an editor/associate editor of major agricultural
journals, which should mean you wouldn't need to do basic editing for
punctuation, clarity, etc.
Best regards,
Jeff
…On Fri, Feb 23, 2024 at 12:01 PM Jan Marvin Garbuszus < ***@***.***> wrote:
The selection is necessary as otherwise the first sheet or, in the case of
a loaded workbook, the last previously selected sheet is selected too.
(Excel allows you to select multiple sheets, and if you change something in
the current sheet, it will be applied to all selected sheets. This could
surprise users, especially if the first sheet is not visible in the sheet
tab).
Yes, I figured there was some zero based integer logic at work, but due to
minimal testing I didn't want to implement anything beyond the basics for
this function. Now it is released and chances are, that we break exisisting
code, if we convert the argument to a zero based integer. For various
functions our documentation is still sparse, lacking explanations of what
is going on, what works or how functions can be safely combined and
examples of how to use the functions. We have already massively expanded
the documentation in the last year, but there are still so many things that
are not documented.
This function wb_set_bookview() was created by reading the Microsoft
documentation of office open xml and just adding all possible arguments.
Without much testing and therefore without much documentation. Testing,
checking and documenting things takes time, and time is always the biggest
problem in hobby projects. So if you want to improve something, please feel
free to open a bug report or an issue.
—
Reply to this email directly, view it on GitHub
<#957 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BGFFQ2HVKT723HK6753SJR3YVDRR7AVCNFSM6AAAAABDVXXCUGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DKNZSGAYDC>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Hi Jan,
I would be glad to help with providing more detailed text and use cases.
I'll probably start with Word docs but recognize that it is time I start
using GitHub more efficiently.
Thanks again for your assistance!
- Jeff White
…On Sat, Feb 24, 2024 at 2:11 AM Jan Marvin Garbuszus < ***@***.***> wrote:
Very cool if you could help with openxlsx2. This package, aside from the
time invested, is just a hobby project. I do it because I enjoy working on
it for some reason, and so should anyone who contributes. And adding a
sentence to a previously undocumented function or correcting and
rearranging text blocks are always very valuable contributions.
I asked you because you are working through the actual code/documentation
and seeing the package from a user's point of view, whereas I often see it
from a programmer's point of view, and they are often contrary.
Preferably these edits would be in the form of Github pull requests, but
if you're not familiar with Git/Github, you can also email me with a diff
or Word docs in edit mode. And I'm the last person to judge other people's
punctuation, especially not in English.
—
Reply to this email directly, view it on GitHub
<#957 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BGFFQ2GEWVWQV26B3SOJQATYVGVDFAVCNFSM6AAAAABDVXXCUGVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DKNZVGY3DG>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I am using openxlsx2 to modify a workbook with 30 sheets and then save the wb with a different name.
When I open the new workbook in Excel, the last sheet viewed in the original file is always displayed, but I would like the workbook to open to different sheets (e.g., #3).
I have tried:
wb_set_active_sheet(wb, sheet = 3)
wb_set_row_heights(wb, sheet = 3, 1, heights = 95, hidden = FALSE)
The latter was as the last command before wb_save() in the hopes that the last modified sheet would be displayed on opening in Excel.
Is there a way to control this property from openxlsx2?
Beta Was this translation helpful? Give feedback.
All reactions