Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for 'veryHidden' sheets not supported #228

Closed
srefsum opened this issue Jan 25, 2019 · 3 comments
Closed

Support for 'veryHidden' sheets not supported #228

srefsum opened this issue Jan 25, 2019 · 3 comments

Comments

@srefsum
Copy link

srefsum commented Jan 25, 2019

Excel supports two modes of hidden sheets:

  • hidden
  • veryHidden

veryhidden is only available from the vba editor.

It can be implemented this way:

diff --git a/lib/Excel/Writer/XLSX/Workbook.pm b/lib/Excel/Writer/XLSX/Workbook.pm
index a9a488d..ae45dc6 100644
--- a/lib/Excel/Writer/XLSX/Workbook.pm
+++ b/lib/Excel/Writer/XLSX/Workbook.pm
@@ -2599,7 +2599,8 @@ sub _write_sheet {
         'sheetId' => $sheet_id,
     );

-    push @attributes, ( 'state' => 'hidden' ) if $hidden;
+    push @attributes, ( 'state' => 'hidden' )     if ($hidden == 1);
+    push @attributes, ( 'state' => 'veryHidden' ) if ($hidden == 2);
     push @attributes, ( 'r:id' => $r_id );


diff --git a/lib/Excel/Writer/XLSX/Worksheet.pm b/lib/Excel/Writer/XLSX/Worksheet.pm
index fa16dd4..6094218 100644
--- a/lib/Excel/Writer/XLSX/Worksheet.pm
+++ b/lib/Excel/Writer/XLSX/Worksheet.pm
@@ -454,6 +454,25 @@ sub hide {
     ${ $self->{_firstsheet} }  = 0;
 }

+###############################################################################
+#
+# hide_very()
+#
+# Hide this worksheet.
+# Only possible to enable using vba attribute editor
+#
+sub hide_very {
+
+    my $self = shift;
+
+    $self->{_hidden} = 2;
+
+    # A hidden worksheet shouldn't be active or selected.
+    $self->{_selected} = 0;
+    ${ $self->{_activesheet} } = 0;
+    ${ $self->{_firstsheet} }  = 0;
+}
+
@srefsum
Copy link
Author

srefsum commented Jan 25, 2019

I failed to implement a test case that actually works; but for my installation of office the mentioned code gives the required result.

@jmcnamara
Copy link
Owner

Seems like a reasonable suggestion. I'll look into it.

jmcnamara added a commit that referenced this issue Oct 8, 2023
@jmcnamara
Copy link
Owner

jmcnamara commented Oct 8, 2023

I've added a fix for this to main via the $worksheet->very_hidden() method.

jmcnamara added a commit that referenced this issue Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants