sheets.columns Array

The column configuration.

sheets.columns.autoWidth Boolean (default: false)

If set to true the column will stretch to fit the contents of all cells.

Example - enable auto width

  <script>
  var workbook = new kendo.ooxml.Workbook({
    sheets: [
        {
            columns: [ { autoWidth: true } ],
            rows: [
              { cells: [ { value: "short" } ] },
              { cells: [ { value: "longer text value" } ] }
            ]
        }
    ]
  });
  kendo.saveAs({
    dataURI: workbook.toDataURL(),
    fileName: "Test.xlsx"
  });
  </script>

sheets.columns.index Number

The zero-based index of the column in the sheet. Defaults to the index of the object in the array.

Example - set width on second column

  <script>
  var workbook = new kendo.ooxml.Workbook({
    sheets: [{
        columns: [{
            width: 100,
            index: 1
        }]
    }]
  });
  kendo.saveAs({
    dataURI: workbook.toDataURL(),
    fileName: "Test.xlsx"
  });
  </script>

sheets.columns.width Number

The width of the column in pixels.

Example - set the column widths

<script>
var workbook = new kendo.ooxml.Workbook({
  sheets: [
      {
          columns: [ { width: 100 }, { width: 200 } ],
          rows: [
            {
              cells: [
                { value: "this column is 100px" }, { value: "this column is 200px" }
              ]
            }
          ]
      }
  ]
});
kendo.saveAs({
  dataURI: workbook.toDataURL(),
  fileName: "Test.xlsx"
});
</script>
In this article
Not finding the help you need? Improve this article