aVadim483 / fast-excel-writer

Lightweight and very fast XLSX Excel Spreadsheet Writer in PHP
MIT License
178 stars 31 forks source link

Rich text problem #74

Closed kouroshfar closed 3 months ago

kouroshfar commented 3 months ago

Hi. Thanks for your great library. I have a problem about using rich text as you mentioned on this line of documents (https://github.com/aVadim483/fast-excel-writer/blob/master/docs/03-writing.md#using-rich-text) when i want to have rich text, i have 2 ways to do it my problem is when i put it bold on a word, next words will be bold until a new tag Untitled and it's different from what did you do rich-text

i tried in both ways and there isn't different on the result. can you help me?

aVadim483 commented 3 months ago

I used this code

$excel = \avadim\FastExcelWriter\Excel::create();
$sheet = $excel->sheet();

$richText = new \avadim\FastExcelWriter\RichText();
$richText->addText('ATTENTION!')->setBold();
$richText->addText(' The product is reserved for ');
$richText->addText('5 days')->setUnderline()->setColor('#f00');

//$sheet->writeCell($richText);
$sheet->writeTo('B2', $richText);
//$sheet->writeRow(['plain text', $richText]);

$richText = new \avadim\FastExcelWriter\RichText('<b>ATTENTION!</b> The product is reserved for <u><c="#f00">5 days</c></u>');
$sheet->writeTo('B5', $richText);

$excel->save(__DIR__ . '/rich_text.xlsx');

and got this result

image

aVadim483 commented 3 months ago

I don't understand what your problem is.