-
Notifications
You must be signed in to change notification settings - Fork 1
3. 对齐
ogenes edited this page Jun 30, 2022
·
1 revision
属性 | 说明 | 默认值 |
---|---|---|
horizontal | 水平对齐 | Alignment::HORIZONTAL_LEFT; 居左 |
vertical | 垂直对齐 | Alignment::VERTICAL_CENTER; 居中 |
wrapText | 自动换行 | false |
textRotation | 旋转 | 0 |
indent | 缩进 | 0 |
shrinkToFit | 内容自动缩小 |
$alignment = [];
$alignment['horizontal'] = Alignment::HORIZONTAL_LEFT;
$alignment['vertical'] = Alignment::VERTICAL_CENTER;
$alignment = [];
$alignment['horizontal'] = Alignment::HORIZONTAL_RIGHT;
$data['sheet1'] = [
['goodsName' => '半裙', 'price' => 1490, 'actualStock' => 2,],
['goodsName' => '半裙', 'price' => 1590, 'actualStock' => 1]
];
$config['sheet1'] = [
['bindKey' => 'goodsName', 'columnName' => '商品名称'],
['bindKey' => 'price', 'columnName' => '售价', 'style' => ['alignment' => $alignment]],
['bindKey' => 'actualStock', 'columnName' => '实际库存'],
];
$client = ExportClient::getInstance();
return $client->setFilepath(__DIR__ . '/file/' . date('Y/m/d/'))
->setFilename('alignmentDemo' . date('His'))
->setData($data)
->setConfig($config)
->export();
$alignment['vertical'] = Alignment::VERTICAL_CENTER;
$alignment = [];
$alignment['wrapText'] = false;
$data['sheet1'] = [
['goodsName' => '半裙', 'price' => 1490, 'actualStock' => 2, 'remark' => "像裙子\r\n像连衣裙"],
['goodsName' => '半裙', 'price' => 1590, 'actualStock' => 1, 'remark' => "像裙子\r\n像连衣裙"]
];
$config['sheet1'] = [
['bindKey' => 'goodsName', 'columnName' => '商品名称'],
['bindKey' => 'price', 'columnName' => '售价'],
['bindKey' => 'actualStock', 'columnName' => '实际库存'],
['bindKey' => 'remark', 'columnName' => '备注', 'style' => ['alignment' => $alignment] ],
];
$alignment['textRotation'] = 90;
$alignment['indent'] = 20;
$alignment['shrinkToFit'] = true;