2016-08-23 1 views
0

저는 현재 테이블의 셀 안에 텍스트를 넣기 위해 큰 어려움을 겪고 있습니다.

내가 이렇게 될 텍스트를 원하는 : 는 "컴퓨터의 컴퓨터 이름에서 분석"다음은PHPWord를 사용하여 표 셀에서 텍스트를 나누는 방법은 무엇입니까?

:

그리고 셀 내부에 다음과 같이 표시됩니다 "컴퓨터에서
컴퓨터 이름을 분석" 내 현재 코드 :

$table = $section->addTable('myTable'); 

$table->addRow(300); 
$table->addCell(4000)->addImage('logo_sat.png',array ('width'=>100,'align'=>'center')); 
$table->addCell(6400, $styleVertical)->addText("Analyse from computer \n $computername", $styleFirstHeader, $styleCenter); 
$table->addCell(4000, $styleVertical)->addText("SAT" , $styleFirstHeader, $styleCenter); 
$table->addRow(30); 
$table->addCell(4000, $styleVertical)->addText("ADR $chantier_code/$analyse_id" , $styleFirstHeader, $styleCenter); 
$table->addCell(5200, $styleVertical)->addText("Indice : $indice Date : $analyse_datemaj " , $styleFirstHeader, $styleCenter); 
$table->addCell(5200, $styleVertical)->addText("Page : " , $styleFirstHeader, $styleCenter); 

나는 문서 내부 $section->addTextBreak([$breakCount], [$fontStyle], [$paragraphStyle]); 을 보았다하지만이야 eems는 표 셀과 호환되지 않습니다.

우리가 어떻게 만들 수 있을지 아십니까?

+0

당신이'CHAR (10)'(Enter 키)를 추가 시도? – WillardSolutions

+0

@EatPeanutButter \ n의 위치에 추가했습니다. CHAR (10) – BackTrack57

답변

0

phpword에서 개행 문자를 추가하면 나를 괴롭 히고 나는 실수로 해결책을 찾았습니다. 그래서 여기에 있습니다 : 그리고 이것은 텍스트를 정당화합니다.

$PHPWord->addParagraphStyle('pJustify', array('align' => 'both', 'spaceBefore' => 0, 'spaceAfter' => 0, 'spacing' => 0)); 
//add this style then append it to text below 
$section->addText('something', 'textstyle', 'pJustify'); 
//the text behind this will be justified and will be in a new line, not in a new paragraph 
$section->addText('behind', 'textstyle', 'pJustify'); 

이 출력됩니다 :

+0

코드를 실행했는데 텍스트가 테이블 밖에 있습니다. 제대로 사용하지 못하거나 단순히 테이블과 셀에서 작동하지 않습니다. – BackTrack57

+0

필요에 따라 스타일을 설정하십시오. –

+0

미안하지만 나는 그것을 테이블과 함께 사용할 수 없다. 당신은 당신의 대답에 표와 몇몇 세포를 가진 예를 들어 주시겠습니까? – BackTrack57