Categories > OpenTBS with XLSX >

Acces all worksheets dynamically

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: mister_woo
Date: 2016-03-03
Time: 16:16

Acces all worksheets dynamically

Hello there,

I was coping around with the problem, that formulas /references are not updating in very worksheet. I found the solution to loop through every sheet and just "selecting" it:

    for ($i = 0; $i < $TBS->PlugIn(OPENTBS_COUNT_SHEETS); ++$i) {
        $TBS->PlugIn(OPENTBS_SELECT_SHEET, $i);

The point is: A couple of templates I'm using dont have incrementing sheet ids. (I guess its because in the lifetime of a workbook worksheets are move, renamed and deleted.) That means, I have a workbook with 2 sheets with the ids 2 and 3. So the above loop won't work.

What I am asking is, is there a method to get all the sheet names or acutal sheet ids? I know, that the debug-method will give back a simple non-formatted string containig sheet information. So I could use a regex to find the information i want. But i am wondering if there is a better solution.


mister woo

yeah, of course i found the solution from this thread:

This is a good workaround, but anyway it would be great to be able to receive a list of actual sheets.

By: Skrol29
Date: 2016-03-04
Time: 23:11

Re: Acces all worksheets dynamically


It is true the sheetId may not be ordered nore sequential.
Thus there is not way to ensure to select the good sheet unless you know its internal id.

I think this is a kind of bug. Sheets should be accessible easily and naturally.
The next OpenTBS will fix that: OPENTBS_SELECT_SHEET will select the sheet corresponding to its order in the sheet collection.
And extra parameter will enable to use select the sheet by its sheetId for compatibility.
By: mister_woo
Date: 2016-03-05
Time: 18:34

Re: Acces all worksheets dynamically

Cool, thank you. Looking forward to the next release :)
By: Skrol29
Date: 2016-03-08
Time: 10:01

Re: Acces all worksheets dynamically

The next release should be ready in few days.
I can send the beta to you if you want.
By: mister_woo
Date: 2016-03-08
Time: 12:59

Re: Acces all worksheets dynamically

No, its not that urgent. As I already found a solution for my original problem (forced re-calculation of formulas) this feature is more like a "nice-to-have" - but thanks anyways!