Coder Social home page Coder Social logo

Comments (2)

Geradav avatar Geradav commented on September 14, 2024 1

Actually, I found out what works.
The getCount() property has to first be assigned to a let variable and then we can read the value from that variable.
Weird, but maybe that is how it is supposed to work.


let vAllSheetTables = vThisWorksheet.tables;
let vCount = vAllSheetTables.getCount();

await context.sync();

console.log(vCount.value);


from office-scripts-docs.

AlexJerabek avatar AlexJerabek commented on September 14, 2024 1

Hi @Geradav,

You are correct: you need to sync with the workbook before reading the value of getCount. This is because the script is running on your local machine, without input from the workbook, until you call await context.sync(). That sync call gives values to anything required from a get method or any property referenced with a load. More about this process can be found in the Scripting fundamentals article.

I'll transfer this issue to https://github.com/OfficeDev/office-scripts-docs so we can explicitly call out those get methods as part of the load/sync cycle. I'll also tag @jedunn in reference to #38 which should help with learning this pattern.

Finally, we are working on a version of the Office Scripts API that avoids the load/sync pattern. It'll handle workbook communication for you, so you'll always have access to variables acquired from the workbook. That will become publicly available for Office Scripts are released into general availability. And don't worry, any script you write now will still work when we release the new version.

from office-scripts-docs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.