> On Sat, 22 Sep 2007, Yegor Kozlov wrote:
>> When we access a sheet from HSSFWorkbook we should remember its index. 
>> There are lots of places where the sheet index is involved including 
>> HSSFWorkbook.cloneSheet() and HSSFWorkbook.setSheetOrder(String 
>> sheetname, int pos). All of these should be covered.

> It might be less work to tell the sheet its name? You can then get the
> sheet index if you need it (via a workbook.getSheetIndex(name) call), and
> we only need to update things in workbook.setSheetName. My hunch is that
> reorganising it so that a sheet knows its index might be good, but it 
> would take a lot more work

I think a better idea is to lookup the sheet in the
HSSFWorkbook.sheets collection. Given a HSSFSheet finding its
index looks as follows:

    public int getSheetIndex(HSSFSheet sheet)
    {
        for (int k = 0; k < sheets.size(); k++)
        {
            if(sheets.get(k) == sheet) {
                return k;
            }
        }
        return -1;
    }

The point that HSSFSheet doesn't have a reference to the owning
HSSFWorkbook. If we add it, the fix is trivial.
    
Yegor

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to