Edit this page

Column Width

By default, all columns in Excel have the same width set (64px). If the cell value needs more space, it will be clipped. This article shows how to set the column width in pixels, or enable automatic width calculation.

Configuration

Set Column Width

The width configuration option specifies the column width in pixels.

The example below demonstrates how to set the width of a column in a worksheet.

Example
<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>

Enable Automatic Column Width

Enable the automatic width calculation by setting the autoWidth option to true, as demonstrated in the example below. When set, the he column stretches to accommodate the longest cell value.

Example
<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

Articles on the Excel export functionality in Kendo UI:

Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy