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

hide worksheet and reorder sheets #226

Closed
dvsoukup opened this issue Nov 11, 2016 · 7 comments
Closed

hide worksheet and reorder sheets #226

dvsoukup opened this issue Nov 11, 2016 · 7 comments
Labels

Comments

@dvsoukup
Copy link

Hello,

Would be useful if I could hide/unhide a worksheet. Currently couldn't see an option to do so.

Maybe as some property:
var sheet = workbook.addWorksheet('My Sheet', {properties: {hidden: true}});

Along with some function to check hidden status
workbook.getWorksheet('My Sheet').IsHidden(); // true or false

And to also toggle hidden status on the fly:
workbook.getWorksheet('My Sheet').hidden = true; // or false...

Would also be useful to re-order sheets in the workbook programmatically. I guess you could technically just "add" sheets in the correct order then circle back around and add data as necessary... but reordering sheets would allow you to not need to do that.

@king612
Copy link

king612 commented Nov 29, 2016

Up Vote (the reordering part)! Would love to have a way to reorder sheets after they are added, particularly with streaming. I'm streaming in the first place because I'm working with large datasets. I have to create new sheets as I encounter certain types of data while streaming, which will occur randomly, but this means I can never control the final order of the sheets. I don't commit sheets until the very end anyway. If they haven't been committed, I really need a way to programmatically re-order the sheets (e.g., alphabetize by name with a Summary sheet as first one) just before doing the final commits.

@king612
Copy link

king612 commented Dec 9, 2016

+1 on the hiding of sheets also

@LogansUA
Copy link

LogansUA commented Apr 2, 2018

@guyonroche Any thoughts about it? Need this actually, especially hiding of worksheet.

Also would be great to export class Worksheet and add ability to add worksheet as parameter with addWorksheet method. I think this is must have feature in order to create Workbook from custom worksheets in defined order.

@Hsinfu
Copy link
Contributor

Hsinfu commented May 29, 2018

@dvsoukup @king612 @LogansUA

npm install my branch
"exceljs": "thingnario/exceljs#feature/DeploySheetAddState",

the following will hide the second_sheet

const wb = new Excel.Workbook();
wb.addWorksheet('first_sheet');
wb.addWorksheet('second_sheet', { state: 'hidden' });

if you want to hide the first_sheet, you need to specify the activeTab to second_sheet

const wb = new Excel.Workbook();
wb.views = [{ activeTab: 1 }];
wb.addWorksheet('first_sheet', { state: 'hidden' });
wb.addWorksheet('second_sheet');

@guyonroche
Copy link
Collaborator

Published @Hsinfu 's fix in v1.5.0

@vinothsm92
Copy link

vinothsm92 commented Jul 30, 2018

const wb = new Excel.Workbook();
wb.views = [{ activeTab: 1 }];
wb.addWorksheet('first_sheet', { state: 'hidden' });
wb.addWorksheet('second_sheet');

this code is not working to hide the second sheet can explain how you did this

@nitin-kapoor
Copy link

Hide all rows and column which doesn't have data when writing to excel.

Want to hide rows and columns which does have data as highlighted in Screenshot 1

image

Want to achieve Screenshot 2

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants