sheetjs icon indicating copy to clipboard operation
sheetjs copied to clipboard

How to determine last viewed sheet?

Open jlouie opened this issue 8 years ago • 4 comments

When parsing a Workbook, is there a way to determine what sheet was last viewed? Is this information even available in an XLS file?

To further clarify, if I have 3 sheets in a workbook (named Sheet1, Sheet2, Sheet3) and Sheet2 was edited then saved, upon importing the workbook through SheetJS, is there a way to surface Sheet2 as the last viewed sheet in the workbook structure?

jlouie avatar Aug 31 '18 22:08 jlouie

Sounds like interesting functionality you'd have in the code for the view's model. As such, I'd expect to get clearer input from https://github.com/SheetJS/SheetJS.github.io/ because they have a view there.

My guess is that they don't have this functionality, but that it should be "easy" to add in.

bean5 avatar Sep 19 '18 21:09 bean5

This information is stored in the Window1 record in XLS as well as in the workbookView tag in the XLSX/XLSM workbook xml and corresponding record in XLSB. The problem is that it isn't uniquely defined: if you have multiple windows, there are multiple "last viewed" sheets, one for each view.

We could surface the current selected worksheet index/name in the wb.Workbook.Views array. The file itself just stores the index -- should the index or the name be stored here, and how should worksheet reordering (re-sorting the wb.SheetNames array) affect this?

SheetJSDev avatar Sep 20 '18 02:09 SheetJSDev

@SheetJSDev Sorry, I'm not sure if your response was waiting for a response from me. ;)

We could surface the current selected worksheet index/name in the wb.Workbook.Views array.

I think this would be a sufficient solution in my use case as I don't have multiple windows opening the same spreadsheet.

As I am not experienced enough with the inner workings of SheetJS at this moment, I would hazard a guess and suggest that storing the worksheet name would probably work best to address the worksheet reordering use case you brought up.

Having said the above, my need for this functionality has been lowered in priority since I first asked the question so unless others would find a need for this functionality, it can probably be noted and placed on the backburner. Thanks for taking a look!

jlouie avatar Oct 01 '18 20:10 jlouie

This is the same question as #1251

reviewher avatar Sep 17 '21 01:09 reviewher