Different width for each columns in jspdf autotable?

前端 未结 4 1662
谎友^
谎友^ 2021-01-01 18:06

My table has 13 columns. How can I get different width for each column? Can I give each column width like this?

styles: {overflow: \'linebreak\' ,columnWidt

4条回答
  •  萌比男神i
    2021-01-01 18:43

    In previous release (1.3.4) it could have done like below:

    var columns = [
              {title: "Signum", dataKey: "signum"},
              {title: "Name", dataKey: "name"},
              {title: "Role", dataKey: "role"},
              {title: "Location", dataKey: "location"} 
              ]
    

    But the latest one i.e. 2.3.2 requires the below format

    doc.autoTable(colums,data,{
        addPageContent:pageContent,
        margin: {horizontal:5,top: 20},
        startY: 0.47*doc.internal.pageSize.height,
        styles: {overflow: 'linebreak'},
        columnStyles: {
         id: {columnWidth: 25}, 
         name:{columnWidth:40}, 
         role: {columnWidth: 15}, 
         location: {columnWidth: 30}
        }
      });
    

    This will fix only id, name, role, and location to the specified limits. Rest other headers will be adjusted accordingly by autotable.js

提交回复
热议问题