charset problem with richtext

Oct 7, 2009 at 2:29 PM
Edited Oct 7, 2009 at 2:45 PM

Hi,

1. i got a problem, if i create a richtext-object. The output data change e.g. &,< and > to html specials chars like &amp; &gt; &lt, etc.

2. I also have problems with richtext-objects, when 2 linefeeds (Chr(10) or \n) follow-up -> excel shows unvalid signs (2 squares) ...

 

Any idea to fix that? :-(

 

ps: i use UTF-8 charset.

Developer
Oct 8, 2009 at 10:04 AM

>> 1. i got a problem, if i create a richtext-object. The output data change e.g. &,< and > to html specials chars like &amp; &gt; &lt, etc.

Yes, this has been fixed:

http://phpexcel.codeplex.com/WorkItem/View.aspx?WorkItemId=10455

Use latest source code from here:

http://phpexcel.codeplex.com/SourceControl/ListDownloadableCommits.aspx

>> 2. I also have problems with richtext-objects, when 2 linefeeds (Chr(10) or \n) follow-up -> excel shows unvalid signs (2 squares) ...

Not sure what the problem is. Do you have some code to reproduce this?

Oct 8, 2009 at 10:47 AM
Edited Oct 8, 2009 at 10:48 AM

thx for reply koyama! and sorry for 1. that i dont investigate more time about that topic!

 

to 2:

for example:

$richtext_obj = new PHPExcel_RichText($worksheet_obj->getCellByColumnAndRow(1,1));

$textrun1 = $richtext_obj->createTextRun(Chr(10));                           //i think this causes the problem...
$textrun2 = $richtext_obj->createTextRun(Chr(10)."for testing...");

 

this phenomenon really only appears with richtext-objects!

Developer
Oct 9, 2009 at 11:56 AM

I am trying this code with PHPExcel 1.7.0 as well as latest source code:

$excel = new PHPExcel();

$worksheet = $excel->getActiveSheet();

$richtext_obj = new PHPExcel_RichText($worksheet->getCellByColumnAndRow(1,1));
$textrun1 = $richtext_obj->createTextRun(Chr(10));
$textrun2 = $richtext_obj->createTextRun(Chr(10)."for testing...");

$objWriter = PHPExcel_IOFactory::createWriter($excel, 'Excel2007');
$objWriter->save('write.xlsx');

But I don't see any squares? It looks ok?

Oct 9, 2009 at 12:00 PM
Edited Oct 9, 2009 at 12:01 PM

well you have to apply that the cell is wraptext!

and i am using excel 2003 .xlsx with autoconverting...

 

Developer
Oct 9, 2009 at 12:10 PM

Here it is with wraptext, still no squares:

$excel = new PHPExcel();

$worksheet = $excel->getActiveSheet();

$worksheet->getStyle('B1')->getAlignment()->setWrapText(true);

$richtext_obj = new PHPExcel_RichText($worksheet->getCellByColumnAndRow(1,1));
$textrun1 = $richtext_obj->createTextRun(Chr(10));
$textrun2 = $richtext_obj->createTextRun(Chr(10)."for testing...");

$objWriter = PHPExcel_IOFactory::createWriter($excel, 'Excel2007');
$objWriter->save('write.xlsx');

Would it be possible for you to run the code and perhaps post a screen shot showing the error?

Oct 9, 2009 at 12:17 PM
koyama wrote:

Would it be possible for you to run the code and perhaps post a screen shot showing the error?

 

//format_array

$format_colheadtitle_kw = array('alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT,
                                                     'vertical'   => PHPExcel_Style_Alignment::VERTICAL_TOP)
                               ,'borders'   => array('outline'    => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM,
                                                                           'color' => array('argb' => PHPExcel_Style_Color::COLOR_WHITE)))
                               ,'fill'      => array('type'       => PHPExcel_Style_Fill::FILL_SOLID,
                                                     'color'      => array('rgb' => $t_grau))
                               ,'font'      => array('color'      => array('argb' => PHPExcel_Style_Color::COLOR_WHITE)));

$format_colheadtitle_kw['borders']['bottom']['style'] = PHPExcel_Style_Border::BORDER_NONE;

$format_colheadtitle_info = $format_colheadtitle_kw;
$format_colheadtitle_info['borders']['top']['style'] = PHPExcel_Style_Border::BORDER_NONE;
$format_colheadtitle_info['alignment']['vertical'] = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
$format_colheadtitle_info['alignment']['wrap'] = true;

//testscript

$wks_container->getStyleByColumnAndRow($col,6)->applyFromArray($format_colheadtitle_info);

$colheadtitle_info = new PHPExcel_RichText($wks_container->getCellByColumnAndRow($col,6));
$colheadtitle_info->createTextRun(Chr(10));
$colheadtitle_info->createTextRun(Chr(10)."testing...");


Screenshot

 

Developer
Oct 13, 2009 at 2:44 AM
Edited Oct 13, 2009 at 2:48 AM

grustardo, can you try to open this file in your Excel 2003 and post a screen shot?

newlines-in-richtext.xlsx

I would very much like to know if you are seeing those Unicode replacement characters.

 

Oct 19, 2009 at 8:55 AM
Edited Oct 19, 2009 at 3:24 PM

yes, i can see it... that's what i mean... i guess it is only in EXCEL 2003

Screenshot

ps. sry, for late reply

Developer
Oct 20, 2009 at 1:28 AM
Edited Oct 20, 2009 at 1:31 AM

Can you try to open this file and say what you see?

newlines-in-richtext-2.xlsx

What I have done is to change the line endings in xl/sharedString.xml from \n to \r\n.

Oct 20, 2009 at 7:57 AM

no changing... :( same output as newlines-in-richtext.xlsx

Developer
Oct 21, 2009 at 12:00 AM
Edited Oct 21, 2009 at 12:02 AM

Ok, how about this file:

newlines-in-richtext-3.xlsx

What I have done is to open newlines-in-richtext-2.xlsx and do a plain save in MS Office Excel 2007

Oct 21, 2009 at 8:25 AM

nope :-( , again...

grustardo wrote:

no changing... :( same output as newlines-in-richtext.xlsx

 

Developer
Oct 22, 2009 at 8:23 PM
Edited Oct 22, 2009 at 8:26 PM

How about this file:

newlines-in-richtext-4.xlsx

It was created in MS Office Excel 2007. No PHPExcel involved.

Oct 23, 2009 at 7:58 AM

always the same, but now we know it is the converter... :>

i just do a <space> after 2 x \n in a row...

 

thx 4 help