exceljs / exceljs

Excel Workbook Manager

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hide worksheet and reorder sheets

dvsoukup opened this issue · comments

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.

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.

+1 on the hiding of sheets also

@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.

@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');

Published @Hsinfu 's fix in v1.5.0

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

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