Column Width

By default, all columns in Excel have the same width of 64px.

If the cell value needs more space, it will be clipped. This article provides information on how to set the column width in pixels or enable automatic width calculation.

Setting Fixed Column Widths

To manually set the column width in pixels, use the width option.

<script>
var workbook = new kendo.ooxml.Workbook({
  sheets: [
    {
      columns: [
        { width: 100 }, { /* default width */ }, { width: 200 }
      ],
      rows: [
        {
          cells: [
            { value: "100 px" }, { value: "default" }, { value: "200px" }
          ]
        }
      ]
    }
  ]
});
kendo.saveAs({
    dataURI: workbook.toDataURL(),
    fileName: "Test.xlsx"
});
</script>

Automatically Adjusting Widths to Content

To enable the automatic width calculation, set the autoWidth option to true. When set, the he column stretches to accommodate the longest cell value.

<script>
var workbook = new kendo.ooxml.Workbook({
  sheets: [
    {
      columns: [
        { /* default width */ }, { autoWidth: true }
      ],
      rows: [
        {
          cells: [
            { value: "long text is clipped if autoWidth is not set to true" }, { value: "long text fits when autoWidth is set to true" }
          ]
        }
      ]
    }
  ]
});
kendo.saveAs({
    dataURI: workbook.toDataURL(),
    fileName: "Test.xlsx"
});
</script>

See Also

In this article
Not finding the help you need? Improve this article