我是 TwigSpreadsheetBundle / PHPSpreadsheet 的新手 我找不到使用 TwigSpreadsheetBundle 格式化我的 excel 导出的正确方法。我想为每个单元格设置自动大小(高度和宽度)。
该文件仅包含一张纸。第一行是用户的标题行(我知道我可以使用 xlsdocument 属性以另一种方式完成它,但客户想要这种方式。)
第二行是空的。 第三行是标题行。
这是我从现在开始得到的:
{% set header1 = {
font: {
bold: true
},
borders: {
bottom: {
borderStyle: 'thin',
color: {
rgb: '000000'
}
}
}
} %}
{% set header2 = {
font: {
bold: true
}
} %}
{% xlsdocument {
creator: user.username,
modified: now
} %}
{% xlssheet 'Blatt 1'{
columnDimension: {
'default': {
autoSize: true
}
}
} %}
{% xlsrow %}
{% xlscell {
style: { font: { size: '18' } },
merge: 4
} %}Angebot {{ offer.id }} - {{ offer.title }}{% endxlscell %}
{% endxlsrow %}
{% xlsrow %}
{% endxlsrow %}
{% xlsrow %}
{% xlscell { style: header1 } %}Position{% endxlscell %}
{% xlscell { style: header1 } %}Bezeichnung{% endxlscell %}
{% xlscell { style: header1 } %}Verkaufspreis{% endxlscell %}
{% xlscell { style: header1 } %}Montageeinkauf{% endxlscell %}
{% endxlsrow %}
{% for title in offer.titles %}
{% xlsrow %}
{% xlscell{ style: header2 } %}{{ title.position }}{% endxlscell %}
{% xlscell{ style: header2 } %}{{ title.description }}{% endxlscell %}
{% xlscell{ style: header2 } %}{{ title.salesPrice }}{% endxlscell %}
{% xlscell{ style: header2 } %}{{ title.inputPriceAssembling }}{% endxlscell %}
{% endxlsrow %}
{% for item in title.items %}
{% xlsrow %}
{% xlscell %}{{ title.position }}.{{ item.position }}{% endxlscell %}
{% xlscell %}{{ item.component.description }}{% endxlscell %}
{% endxlsrow %}
{% endfor %}
{% endfor %}
{% endxlssheet %}
{% endxlsdocument %}
当我在 Libreoffice、OnlyOffice 或 Microsoft Office 中打开文件时,它看起来像这样:
答案 0 :(得分:0)
似乎文档不正确,“默认”不起作用,另见:Second solution works
{% xlssheet 'Blatt 1'{
columnDimension: {
'A': {
autoSize: true
},
'B': {
autoSize: true
},
'C': {
autoSize: true
},
'D': {
autoSize: true
},
}
} %}