LibXL: excel cross-sheet formulas not updated

1.2k Views Asked by At

I'm dealing with a problem with libXL and Office365. I created an Excel file with Office 365: a simple formula which shows the content of a cell from another sheet. Then I proceeded to write something in that source cell through libXl. When I open the output file, the formula is not calculated until I press CTRL+ALT+SHIFT+F9.

If I create the xlsx file from Office 2013 then the formula is correctly updated.

Couldn't find anything on their website about whether O365 is supported or not.

Here's the code to reproduce the issue, (I can provide the two input xlsx files if needed):

#include "stdafx.h"
#include "libxl.h"

using namespace libxl;

int main()
{   
    Book* book = xlCreateXMLBook();

    // xlsx file created by Office 2013
    if (book->load(L"office2013.xlsx"))
    {
        Sheet* sheet = book->getSheet(0);
        if (sheet)
            sheet->writeNum(2, 2, 42);

        book->save(L"okay.xlsx"); // works correctly when opened
    }

    // xlsx file created by O365
    if (book->load(L"office365.xlsx"))
    {
        Sheet* sheet = book->getSheet(0);
        if (sheet)
            sheet->writeNum(2, 2, 42);

        book->save(L"bugged.xlsx"); // must press CTRL+ALT+SHIFT+F9 to see '42' in the second sheet
    }
    
    book->release();
    
    return 0;
}

This is the source sheet (number 42 written by the above code): source sheet

This is the not working formula (written in Excel): not working formula

0

There are 0 best solutions below