I use the follwing code to set different colors in a cell and export it
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$rich_text = new RichText();
$rich_text->createText("P\n");
$text_run = $rich_text->createTextRun("A\n");
$text_run->getFont()->setColor( new \PhpOffice\PhpSpreadsheet\Style\Color( \PhpOffice\PhpSpreadsheet\Style\Color::COLOR_GREEN ) );
$text_run = $rich_text->createTextRun("N\n");
$text_run->getFont()->setColor( new \PhpOffice\PhpSpreadsheet\Style\Color( \PhpOffice\PhpSpreadsheet\Style\Color::COLOR_RED ) );
$spreadsheet->getActiveSheet()->getCell('A1')->setValue($rich_text);
$sheet->getStyle('A1')->getAlignment()->setWrapText(true);
$obj_writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
$obj_writer->save(dirname(__FILE__) . '/test.xlsx');
But open the file in different systems, I get different result, for example:
In windows, it looks normal:
In mobile(I just try open it in android), colored rich text is not displayed:
In Mac, colored rich text has strikethrough:
so, is it because of format compatibility? Do I need to set up anything?
I finally used two cells to show the contents of different colors.