OfficeDev / office-js-docs-pr

Microsoft Office Add-ins Documentation
https://learn.microsoft.com/office/dev/add-ins
Creative Commons Attribution 4.0 International
405 stars 250 forks source link

Error in Update All Cells... example #2013

Closed choiway closed 4 years ago

choiway commented 4 years ago

There is an error in the Update All Cells In Range section:

The following two lines need to be wrapped in a 2d array.

    range.numberFormat = 'm/d/yyyy';
    range.values = '3/11/2015';

It works as follows:

    range.numberFormat = '[[m/d/yyyy]]';
    range.values = '[[3/11/2015]]';

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

AlexJerabek commented 4 years ago

Thanks for reporting this @choiway. I'll look into fixing the sample code and report back.

AlexJerabek commented 4 years ago

Hi @choiway,

So that sample code actually works as is. It won't compile with TypeScript definitions, but setting those properties (formulas, numberFormat, and values) with a single value (not in an array) does populate the entire range.

I'm working with the product team to figure out how to reconcile the behavior with the definitions. I just wanted to keep you updated so you're not blocked.

choiway commented 4 years ago

Got it. I should have mentioned that I am using Typescript React.

AlexJerabek commented 4 years ago

Hi @choiway,

Thanks again for pointing this out. We decided that while the sample code originally in the article does work, the convenience is mitigated by the confusing TypeScript narrative. Rather than explaining the workaround (#2021), we'll just follow our own type definitions.

The corrected articles have been checked into the master branch and will be live soon. Please let me know if you have any other questions.