Better support of worksheets & pivot tables in yarg


I add to tweak Yarg to add support for multiple pivot tables in multiple worksheets, and in the process I found a minor bug that lead to broken sheet at Excel startup (calcChain problem).

The problem comes from XlsxFormatter::updateFormula : the workaround does not work when you have multiple worksheets.
As I’m very using a very old 1.1.3 Yarg release, here is a file containing the changes I suggest, by using Sheet index instead of 1.
I promise I will upgrade and clone in a very near future.

XlsxFormatterTweak.txt (6.5K)

1 Like

Better correction : no more hypothesis on sheet order (did not always work)

    private long getSheetIndex(Worksheet worksheet) { 
        for (Document.SheetWrapper sheetWrapper : result.getWorksheets()) { 
            if (worksheet == sheetWrapper.getWorksheet().getJaxbElement()) { 
                for (Sheet aSheet : result.getWorkbook().getSheets().getSheet()) { 
                    if (aSheet.getName().equals(sheetWrapper.getName())) { 
                        return aSheet.getSheetId(); 
        // Defaulting 
        return 1; 


We have included a similar fix into YARG 2.0.9 version.

Subbotin Andrey

1 Like