Skip to content

[F] Checkbox #31

@wpyoga

Description

@wpyoga

🚀 Feature Proposal

Checkbox feature as available in MS Excel.

Motivation

I need the checkbox to take user input and record it in the cell. This is similar to data validation with TRUE/FALSE values, but much more convenient and intuitive for the user.

Example

Image
ws.getCell("J1".value = true;
ws.getCell("K1".value = false;
ws.getCell("J2").value = { checkbox: true };
ws.getCell("K2").value = { checkbox: false };

Notes

Full disclosure: I have also requested this same feature on ExcelTS cjnoname/excelts#35

This is the minimum set of changes necessary for the functionality to work correctly on MS Excel Online. Please note that the files have been formatted with xmllint --format before diffing.

  • [Content_Types].xml
    @@ -11,4 +11,5 @@
       <Default Extension="vml" ContentType="application/vnd.openxmlformats-officedocument.vmlDrawing"/>
       <Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>
       <Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/>
    +  <Override PartName="/xl/featurePropertyBag/featurePropertyBag.xml" ContentType="application/vnd.ms-excel.featurepropertybag+xml"/>
     </Types>
    
  • xl/featurePropertyBag/featurePropertyBag.xml (a whole new file)
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <FeaturePropertyBags xmlns="http://schemas.microsoft.com/office/spreadsheetml/2022/featurepropertybag">
      <bag type="Checkbox"/>
      <bag type="XFControls">
        <bagId k="CellControl">0</bagId>
      </bag>
      <bag type="XFComplement">
        <bagId k="XFControls">1</bagId>
      </bag>
      <bag type="XFComplements" extRef="XFComplementsMapperExtRef">
        <a k="MappedFeaturePropertyBags">
          <bagId>2</bagId>
        </a>
      </bag>
    </FeaturePropertyBags>
    
  • xl/_rels/workbook.xml.rels
    @@ -5,4 +5,5 @@
       <Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" Target="sharedStrings.xml"/>
       <Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/>
       <Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet2.xml"/>
    +  <Relationship Id="rId6" Type="http://schemas.microsoft.com/office/2022/11/relationships/FeaturePropertyBag" Target="featurePropertyBag/featurePropertyBag.xml"/>
     </Relationships>
    
  • xl/styles.xml
    @@ -50,7 +50,7 @@
       <cellStyleXfs count="1">
         <xf numFmtId="0" fontId="0" fillId="0" borderId="0"/>
       </cellStyleXfs>
    -  <cellXfs count="8">
    +  <cellXfs count="9">
         <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/>
         <xf numFmtId="49" fontId="0" fillId="0" borderId="0" xfId="0" applyNumberFormat="1" applyAlignment="1">
           <alignment horizontal="left"/>
    @@ -69,6 +69,13 @@
         </xf>
         <xf numFmtId="0" fontId="0" fillId="2" borderId="0" xfId="0" applyFill="1"/>
         <xf numFmtId="0" fontId="0" fillId="3" borderId="0" xfId="0" applyFill="1"/>
    +    <xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0" applyAlignment="1">
    +      <extLst>
    +        <ext xmlns:xfpb="http://schemas.microsoft.com/office/spreadsheetml/2022/featurepropertybag" uri="{C7286773-470A-42A8-94C5-96B5CB345126}">
    +          <xfpb:xfComplement i="0"/>
    +        </ext>
    +      </extLst>
    +    </xf>
       </cellXfs>
       <cellStyles count="1">
         <cellStyle name="Normal" xfId="0" builtinId="0"/>
    
  • xl/worksheets/sheet1.xml
    @@ -35,10 +35,10 @@
           </c>
         </row>
         <row r="2" spans="4:5">
    -      <c r="D2" s="3" t="b">
    +      <c r="D2" s="8" t="b">
             <v>1</v>
           </c>
    -      <c r="E2" s="3" t="b">
    +      <c r="E2" s="8" t="b">
             <v>0</v>
           </c>
         </row>
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions