OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
676 stars 95 forks source link

Excel Data Validation - Whole Numbers have restricted integer values #3088

Open ChrisWRWX opened 1 year ago

ChrisWRWX commented 1 year ago

Provide required information needed to triage your issue

Your Environment

Expected behavior

Setting data validation for whole numbers using JS should allow larger positive and negative integers, as is possible by the Excel UI.

Current behavior

When setting 'wholeNumber' data validation in JS, only values in the range 0-65535 can be set.

It appears this is using a 16 bit unsigned integer, where the Excel UI itself is not restricted by the same limitation.

65,535 works as expected but 65,536 does not.

Steps to reproduce

This code does work as expected:

const range = context.workbook.getSelectedRange();

range.dataValidation.rule = {
  wholeNumber: {
    formula1: 65535,
    operator: Excel.DataValidationOperator.lessThan
  }
};

await context.sync();

But not if the integer is outside the range 0-65535

const range = context.workbook.getSelectedRange();

range.dataValidation.rule = {
  wholeNumber: {
    formula1: 65536,
    operator: Excel.DataValidationOperator.lessThan
  }
};

await context.sync();
AlexJerabek commented 1 year ago

Thanks for reporting this @ChrisWRWX.

@yaweizhu-henson, could you please investigate?

donlvMSFT commented 1 year ago

Hi, yes currently the number have limitation, we have internal backlog to track this: #8009234

We will start the investigation ASAP when we have the bandwidth. Or you can provide the scale of affected users, it will help us re-prioritize this bug. Thanks for your patience!

thomasjungblut commented 4 days ago

We're also running into this right now, where we want to ensure different integer ranges (16 bit, 32 bit, 64 bit - signed/unsigned). I can see this works within Excel, is this a limitation of officejs?

edit: we can workaround by using "decimal" instead.