Skip to main content
added 1 character in body; edited title
Source Link
marc_s
  • 759.9k
  • 186
  • 1.4k
  • 1.5k

In an Excel Webweb script, how can a cell be tested for a checkbox?

I have an Excel sheet, which is filtered with slicers and contains a column with checkboxes. I would like to create a script which reverses the values of the visible checkboxes.

I'm new to TypeScript, but I've constructed the basic structure. Problem is; because the column contains a header, I need to check the cellValuecellValue for a checkbox, before I flip the value. Unfortunately, typeOftypeOf only returns "object" and checking with instanceOfinstanceOf didn't work either. WhatWhat would be the best approach to identify cells only with CheckBoxescheckboxes?

Thanks in advance

function main(workbook: ExcelScript.Workbook) { let selectedSheet = workbook.getActiveWorksheet(); // get all the visible cells in the 'complete' column let visibleCheckboxes = selectedSheet.getRange("F:F") .getUsedRange() .getSpecialCells(ExcelScript.SpecialCellType.visible) // itterateiterate throughover the all the checkboxes and flip their value visibleCheckboxes.getAreas().forEach((range) => { // mulitple ranges as we're filtering range.getValues().forEach(cellValue => { console.log(typeof cellValue) // if cellValue is a checkbox // flip value }); }); } 

In an Excel Web script, how can a cell be tested for a checkbox?

I have an Excel sheet, which is filtered with slicers and contains a column with checkboxes. I would like to create a script which reverses the values of the visible checkboxes.

I'm new to TypeScript, but I've constructed the basic structure. Problem is; because the column contains a header, I need to check the cellValue for a checkbox, before I flip the value. Unfortunately, typeOf only returns "object" and checking with instanceOf didn't work either. What would be the best approach to identify cells only with CheckBoxes?

Thanks in advance

function main(workbook: ExcelScript.Workbook) { let selectedSheet = workbook.getActiveWorksheet(); // get all the visible cells in the 'complete' column let visibleCheckboxes = selectedSheet.getRange("F:F") .getUsedRange() .getSpecialCells(ExcelScript.SpecialCellType.visible) // itterate through the all the checkboxes and flip their value visibleCheckboxes.getAreas().forEach((range) => { // mulitple ranges as we're filtering range.getValues().forEach(cellValue => { console.log(typeof cellValue) // if cellValue is a checkbox // flip value }); }); } 

In an Excel web script, how can a cell be tested for a checkbox?

I have an Excel sheet, which is filtered with slicers and contains a column with checkboxes. I would like to create a script which reverses the values of the visible checkboxes.

I'm new to TypeScript, but I've constructed the basic structure. Problem is; because the column contains a header, I need to check the cellValue for a checkbox, before I flip the value. Unfortunately, typeOf only returns "object" and checking with instanceOf didn't work either. What would be the best approach to identify cells only with checkboxes?

Thanks in advance

function main(workbook: ExcelScript.Workbook) { let selectedSheet = workbook.getActiveWorksheet(); // get all the visible cells in the 'complete' column let visibleCheckboxes = selectedSheet.getRange("F:F") .getUsedRange() .getSpecialCells(ExcelScript.SpecialCellType.visible) // iterate over the all the checkboxes and flip their value visibleCheckboxes.getAreas().forEach((range) => { // mulitple ranges as we're filtering range.getValues().forEach(cellValue => { console.log(typeof cellValue) // if cellValue is a checkbox // flip value }); }); } 
Source Link

In an Excel Web script, how can a cell be tested for a checkbox?

I have an Excel sheet, which is filtered with slicers and contains a column with checkboxes. I would like to create a script which reverses the values of the visible checkboxes.

I'm new to TypeScript, but I've constructed the basic structure. Problem is; because the column contains a header, I need to check the cellValue for a checkbox, before I flip the value. Unfortunately, typeOf only returns "object" and checking with instanceOf didn't work either. What would be the best approach to identify cells only with CheckBoxes?

Thanks in advance

function main(workbook: ExcelScript.Workbook) { let selectedSheet = workbook.getActiveWorksheet(); // get all the visible cells in the 'complete' column let visibleCheckboxes = selectedSheet.getRange("F:F") .getUsedRange() .getSpecialCells(ExcelScript.SpecialCellType.visible) // itterate through the all the checkboxes and flip their value visibleCheckboxes.getAreas().forEach((range) => { // mulitple ranges as we're filtering range.getValues().forEach(cellValue => { console.log(typeof cellValue) // if cellValue is a checkbox // flip value }); }); }