diff --git a/playlists-prod/excel.yaml b/playlists-prod/excel.yaml index 3b67eee0..af13e577 100644 --- a/playlists-prod/excel.yaml +++ b/playlists-prod/excel.yaml @@ -305,12 +305,12 @@ group: Custom XML Parts api_set: ExcelApi: '1.5' -- id: excel-data-types-formatted-number - name: 'Data types: Formatted numbers' +- id: excel-data-types-doubles + name: 'Data types: Doubles' fileName: data-types-formatted-number.yaml description: >- - This sample shows how to set and get data types using the formatted number - properties. + This sample shows how to set and get formatted numbers using double data + types. rawUrl: >- https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-formatted-number.yaml group: Data Types diff --git a/playlists/excel.yaml b/playlists/excel.yaml index 2a8b5c90..1cea0cf8 100644 --- a/playlists/excel.yaml +++ b/playlists/excel.yaml @@ -305,12 +305,12 @@ group: Custom XML Parts api_set: ExcelApi: '1.5' -- id: excel-data-types-formatted-number - name: 'Data types: Formatted numbers' +- id: excel-data-types-doubles + name: 'Data types: Doubles' fileName: data-types-formatted-number.yaml description: >- - This sample shows how to set and get data types using the formatted number - properties. + This sample shows how to set and get formatted numbers using double data + types. rawUrl: >- https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/20-data-types/data-types-formatted-number.yaml group: Data Types diff --git a/samples/excel/16-custom-functions/data-types-custom-functions.yaml b/samples/excel/16-custom-functions/data-types-custom-functions.yaml index a5ebdbab..8d6745ff 100644 --- a/samples/excel/16-custom-functions/data-types-custom-functions.yaml +++ b/samples/excel/16-custom-functions/data-types-custom-functions.yaml @@ -66,7 +66,7 @@ script: }, // Add Unit Price as a formatted number. "Unit Price": { - type: "FormattedNumber", + type: "Double", basicValue: product.unitPrice, numberFormat: "$* #,##0.00" }, diff --git a/samples/excel/20-data-types/data-types-formatted-number.yaml b/samples/excel/20-data-types/data-types-formatted-number.yaml index dd362a38..c4e8c36b 100644 --- a/samples/excel/20-data-types/data-types-formatted-number.yaml +++ b/samples/excel/20-data-types/data-types-formatted-number.yaml @@ -1,19 +1,19 @@ order: 1 -id: excel-data-types-formatted-number -name: 'Data types: Formatted numbers' -description: This sample shows how to set and get data types using the formatted number properties. +id: excel-data-types-doubles +name: 'Data types: Doubles' +description: This sample shows how to set and get formatted numbers using double data types. host: EXCEL api_set: ExcelApi: '1.16' script: content: |- document.getElementById("setup").addEventListener("click", () => tryCatch(setup)); - document.getElementById("set-formatted-number-date").addEventListener("click", () => tryCatch(setFormattedNumberDate)); - document.getElementById("set-formatted-number-currency").addEventListener("click", () => tryCatch(setFormattedNumberCurrency)); - document.getElementById("get-formatted-number").addEventListener("click", () => tryCatch(getFormattedNumber)); + document.getElementById("set-double-as-date").addEventListener("click", () => tryCatch(setDoubleAsDate)); + document.getElementById("set-double-as-currency").addEventListener("click", () => tryCatch(setDoubleAsCurrency)); + document.getElementById("get-double").addEventListener("click", () => tryCatch(getDouble)); - async function setFormattedNumberDate() { - // This function creates a formatted number data type, + async function setDoubleAsDate() { + // This function creates a double data type, // and sets the format of this data type as a date. await Excel.run(async (context) => { // Get the Sample worksheet and a range on that sheet. @@ -24,7 +24,7 @@ script: dateRange.valuesAsJson = [ [ { - type: Excel.CellValueType.formattedNumber, + type: Excel.CellValueType.double, basicValue: 32889.0, numberFormat: "m/d/yyyy" } @@ -34,8 +34,8 @@ script: }); } - async function setFormattedNumberCurrency() { - // This function creates a formatted number data type, + async function setDoubleAsCurrency() { + // This function creates a double data type, // and sets the format of this data type as a currency. await Excel.run(async (context) => { // Get the Sample worksheet and a range on that sheet. @@ -46,7 +46,7 @@ script: currencyRange.valuesAsJson = [ [ { - type: Excel.CellValueType.formattedNumber, + type: Excel.CellValueType.double, basicValue: 12.34, numberFormat: "$* #,##0.00" } @@ -57,7 +57,7 @@ script: }); } - async function getFormattedNumber() { + async function getDouble() { // This function prints information about data types // in cells A1 and A2 to the console. await Excel.run(async (context) => { @@ -79,13 +79,13 @@ script: console.log(" Type: " + dateValues.type); console.log(" Basic value: " + dateValues.basicValue); console.log(" Basic type: " + dateValues.basicType); - console.log(" Number format: " + (dateValues as Excel.FormattedNumberCellValue).numberFormat); + console.log(" Number format: " + (dateValues as Excel.DoubleCellValue).numberFormat); console.log("Currency"); console.log(" Type: " + currencyValues.type); console.log(" Basic value: " + currencyValues.basicValue); console.log(" Basic type: " + currencyValues.basicType); - console.log(" Number format: " + (currencyValues as Excel.FormattedNumberCellValue).numberFormat); + console.log(" Number format: " + (currencyValues as Excel.DoubleCellValue).numberFormat); }); } @@ -111,7 +111,7 @@ script: template: content: |-
-

This sample shows how to work with the formatted number data type.

+

This sample shows how to work with double data types to create formatted numbers.

Set up

@@ -119,13 +119,13 @@ template: Add worksheet

Try it out

- - -
diff --git a/snippet-extractor-metadata/excel.xlsx b/snippet-extractor-metadata/excel.xlsx index 65ff1a38..31be2805 100644 Binary files a/snippet-extractor-metadata/excel.xlsx and b/snippet-extractor-metadata/excel.xlsx differ diff --git a/snippet-extractor-output/snippets.yaml b/snippet-extractor-output/snippets.yaml index 7dc91f8b..004e38d5 100644 --- a/snippet-extractor-output/snippets.yaml +++ b/snippet-extractor-output/snippets.yaml @@ -3455,6 +3455,61 @@ console.log(`${property.key}:${property.value}`); }); }); +'Excel.DoubleCellValue#numberFormat:member': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-formatted-number.yaml + + + // This function creates a double data type, + + // and sets the format of this data type as a currency. + + await Excel.run(async (context) => { + // Get the Sample worksheet and a range on that sheet. + const sheet = context.workbook.worksheets.getItemOrNullObject("Sample"); + const currencyRange = sheet.getRange("A2"); + + // Write a number formatted as currency to cell A2. + currencyRange.valuesAsJson = [ + [ + { + type: Excel.CellValueType.double, + basicValue: 12.34, + numberFormat: "$* #,##0.00" + } + ] + ]; + + await context.sync(); + }); +'Excel.DoubleCellValue#type:member': + - >- + // Link to full sample: + https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-formatted-number.yaml + + + // This function creates a double data type, + + // and sets the format of this data type as a date. + + await Excel.run(async (context) => { + // Get the Sample worksheet and a range on that sheet. + const sheet = context.workbook.worksheets.getItemOrNullObject("Sample"); + const dateRange = sheet.getRange("A1"); + + // Write a number formatted as a date to cell A1. + dateRange.valuesAsJson = [ + [ + { + type: Excel.CellValueType.double, + basicValue: 32889.0, + numberFormat: "m/d/yyyy" + } + ] + ]; + await context.sync(); + }); 'Excel.DynamicFilterCriteria:enum': - >- // Link to full sample: @@ -3688,61 +3743,6 @@ }; filterField.applyFilter({ dateFilter: dateFilter }); - await context.sync(); - }); -'Excel.FormattedNumberCellValue#numberFormat:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-formatted-number.yaml - - - // This function creates a formatted number data type, - - // and sets the format of this data type as a currency. - - await Excel.run(async (context) => { - // Get the Sample worksheet and a range on that sheet. - const sheet = context.workbook.worksheets.getItemOrNullObject("Sample"); - const currencyRange = sheet.getRange("A2"); - - // Write a number formatted as currency to cell A2. - currencyRange.valuesAsJson = [ - [ - { - type: Excel.CellValueType.formattedNumber, - basicValue: 12.34, - numberFormat: "$* #,##0.00" - } - ] - ]; - - await context.sync(); - }); -'Excel.FormattedNumberCellValue#type:member': - - >- - // Link to full sample: - https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-formatted-number.yaml - - - // This function creates a formatted number data type, - - // and sets the format of this data type as a date. - - await Excel.run(async (context) => { - // Get the Sample worksheet and a range on that sheet. - const sheet = context.workbook.worksheets.getItemOrNullObject("Sample"); - const dateRange = sheet.getRange("A1"); - - // Write a number formatted as a date to cell A1. - dateRange.valuesAsJson = [ - [ - { - type: Excel.CellValueType.formattedNumber, - basicValue: 32889.0, - numberFormat: "m/d/yyyy" - } - ] - ]; await context.sync(); }); 'Excel.Functions:class': @@ -5940,7 +5940,7 @@ https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-formatted-number.yaml - // This function creates a formatted number data type, + // This function creates a double data type, // and sets the format of this data type as a date. @@ -5953,7 +5953,7 @@ dateRange.valuesAsJson = [ [ { - type: Excel.CellValueType.formattedNumber, + type: Excel.CellValueType.double, basicValue: 32889.0, numberFormat: "m/d/yyyy" } diff --git a/view-prod/excel.json b/view-prod/excel.json index b267d8b8..004d1fba 100644 --- a/view-prod/excel.json +++ b/view-prod/excel.json @@ -33,7 +33,7 @@ "excel-custom-xml-parts-create-set-get-and-delete-custom-xml-parts": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml", "excel-custom-xml-parts-test-xml-for-unique-namespace": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/18-custom-xml-parts/test-xml-for-unique-namespace.yaml", "excel-chart-chart-title-ts": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/private-samples/excel/20-chart/chart-title-ts.yaml", - "excel-data-types-formatted-number": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-formatted-number.yaml", + "excel-data-types-doubles": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-formatted-number.yaml", "excel-data-types-web-image": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-web-image.yaml", "excel-data-types-entity-values": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-entity-values.yaml", "excel-data-types-error-values": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/20-data-types/data-types-error-values.yaml", diff --git a/view/excel.json b/view/excel.json index c805307d..7a5a1133 100644 --- a/view/excel.json +++ b/view/excel.json @@ -33,7 +33,7 @@ "excel-custom-xml-parts-create-set-get-and-delete-custom-xml-parts": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/18-custom-xml-parts/create-set-get-and-delete-custom-xml-parts.yaml", "excel-custom-xml-parts-test-xml-for-unique-namespace": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/18-custom-xml-parts/test-xml-for-unique-namespace.yaml", "excel-chart-chart-title-ts": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/private-samples/excel/20-chart/chart-title-ts.yaml", - "excel-data-types-formatted-number": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/20-data-types/data-types-formatted-number.yaml", + "excel-data-types-doubles": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/20-data-types/data-types-formatted-number.yaml", "excel-data-types-web-image": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/20-data-types/data-types-web-image.yaml", "excel-data-types-entity-values": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/20-data-types/data-types-entity-values.yaml", "excel-data-types-error-values": "https://raw.githubusercontent.com/OfficeDev/office-js-snippets/main/samples/excel/20-data-types/data-types-error-values.yaml",