0

テキストの回転を 90 に使用してセルに垂直テキストを表示しようとしていますが、すべてのテキストが水平に表示され、機能していません。これが私のphpコードです

$spreadsheet = new Spreadsheet();

// Create a new worksheet called "Technical Skills"
$technicalSkillsSheet = new Worksheet($spreadsheet, 'Technical Skills');
// Attach the "Technical Skills" worksheet as the first worksheet in the Spreadsheet object
$spreadsheet->addSheet($technicalSkillsSheet, TECHNICAL_SKILLS_INDEX);
$sheet = $spreadsheet->getSheet(TECHNICAL_SKILLS_INDEX);
foreach($term_sheet_array as $term_sheet){
    $sheet->setCellValue($term_sheet['cell'], $term_sheet['name']);
    $styleArray = array(
        'fill' => array(
            'fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID,
            'startColor' => array(
                'argb' => $term_sheet["color"],
            ),
        ),
        'alignment' => array(
            'wrapText' => TRUE,
            'textRotation' => 90,
            'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_BOTTOM,
        ),
    );
    $sheet->getStyle($term_sheet['cell'])->applyFromArray($styleArray);
    $color_key++;

    if($color_key >= count($sheetColors)){
       $color_key = 0;
    }
}
4

2 に答える 2

0

テキストの回転は、次の 2 つの方法で定義できます。

最初の方法:

$styleArray = [
    'font' => [
        'bold'  =>  true,
        'size'  =>  14,
    ],
    'alignment' => [
        'textRotation' => 90,
        'horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER,
        'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER
    ]
];
$activeSheet->getStyle('A1')->getAlignment()->applyFromArray($styleArray);

2 番目の方法:

$activeSheet->getStyle('A1')->getAlignment()->setTextRotation(90);
于 2021-03-23T07:39:24.417 に答える