2017-01-30 30 views
1

私の例(単なる "輸出PDF" をクリックしてください):jsPDF autotable右整列x位置のバグ

enter image description herehttps://jsfiddle.net/j9vaqpnz/7/

私の例では、このようになります私のテーブルをエクスポートします。

テーブルは、ライブラリjspdfautotableを使用してpdfにエクスポートされます。 私は「drawCell」機能を使用してエクスポート機能の間に

と、次のように私はそれらを右揃え番号が含まれているすべての列の

drawCell: function (cell, data) { 
       var col = data.column.index; 
       if(col==3 || col==5 || col==6 || col==7 || col==8 || col==9 || col==10){ 
        cell.styles.halign = 'right'; 
       } 
      } 

問題:PDF私はinproperly配置されている右寄せしているすべての列を、それは次のようになります。

enter image description here

これはバグですか?または、私は正しく "drawCell"を使用していますか?

+0

はcreatedCell代わりのdrawCellを使用してみてください。 –

+0

Takk Simon。他の誰かがこれを探しているなら、私は完成のための更新された働く例を以下に掲示しました。 – DavidDunham

答えて

1

"createdCell"と "createdHeaderCell"を使用すると、右揃えによって要素が適切に配置されます。

更新例:https://jsfiddle.net/j9vaqpnz/10/

新しいコード:

... 
createdHeaderCell: function (cell, data) { 
    alignCol(cell, data); 
}, 
createdCell: function (cell, data) { 
    alignCol(cell, data); 
} 
... 

function alignCol(cell, data){ 
    var col = data.column.index; 
    if(col==3 || col==5 || col==6 || col==7 || col==8 || col==9 || col==10){ 
     cell.styles.halign = 'right'; 
    } 
} 
関連する問題