Comments (2)
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.
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)
- This action cannot be recorded and cannot copy as code. HOT 12
- Issue in the sample HOT 5
- Documentation should reflect that refresh is supported for Power BI
- Error: Line 27: Table addRows: This won't work because it would move cells in a table on your worksheet. HOT 8
- Contradicting wording in docs? HOT 7
- The ability to simply update tables in XLSM is often inquired about - is it possible? HOT 1
- 'Open in VSCode' doesn't work HOT 5
- Move rows across tables additional filters HOT 3
- Excel Office Scripting default parameters HOT 8
- Tutorial: Update a spreadsheet from a Power Automate flow need update. HOT 1
- "Run Script" action not available HOT 1
- Run Office Scripts in Excel from buttons page out of date HOT 1
- 'excelonlinebusiness' operation 'GetSingleScript' failed with status code 'BadRequest' "status": 400, "message": "Unable to parse script reference" HOT 3
- Script converting then corrupt XLSX? HOT 6
- Wrong title of sample code HOT 1
- No information if refreshAllDataConnections() is supposed to wait for refresh to finish before it continues. HOT 4
- The wrong chart type HOT 1
- Error after Run the code HOT 3
- Platfrom support is inconsistent with other documentations HOT 3
- Ability to Change Column Header Text in Pivot Table HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from office-scripts-docs.