2016-10-11 2 views
0

すべてうまくいっていますが、実際にはテーブル内のテキストの下に白いスペースを入れずにphpwordでテーブルを作成しようとしています。このような状況を作り出してください。PhpWordでテーブルを作成する

enter image description here

(白間隔やパディングなし)

この

$phpWord = new \PhpOffice\PhpWord\PhpWord(); 

     $phpWord->getCompatibility()->setOoxmlVersion(14); 
     $phpWord->getCompatibility()->setOoxmlVersion(15); 

     $targetFile = "./global/uploads/"; 
     $filename = $news['CompanyDetails']['QuotationCode'].' Quotation For '.$news['CompanyDetails']['CompanyName'].'.docx'; 

        $section = $phpWord->addSection(); 
      $section->getStyle()->setBreakType('continuous'); 
     $header = $section->addHeader(); 
      $header->headerTop(10); 



      $section->addImage(base_url('images/qoutlogo.jpg'), array('align'=>'center' ,'topMargin' => -5)); 

      $section->addTextBreak(-5); 
      $center = $phpWord->addParagraphStyle('p2Style', array('align'=>'center','marginTop' => 1)); 
      $section->addText('this is my name',array('bold' => true,'underline'=>'single','name'=>'TIMOTHYfont','size' => 14),$center); 
      $section->addTextBreak(-.5); 

      $section->addText('Tel: 00971-55-25553443 Fax: 00971-55- 2553443',array('name'=>'Times New Roman','size' => 13),$center); 
      $section->addTextBreak(-.5); 
      $section->addText('Quotation',array('bold' => true,'underline'=>'single','name'=>'Times New Roman','size' => 16),$center); 
      $section->addTextBreak(-.5); 
      $tableStyle = array('borderSize' => 1, 'borderColor' => '999999', 'afterSpacing' => 0, 'Spacing'=> 0, 'cellMargin'=>0 ); 
$styleCell = array('borderTopSize'=>1 ,'borderTopColor' =>'black','borderLeftSize'=>1,'borderLeftColor' =>'black','borderRightSize'=>1,'borderRightColor'=>'black','borderBottomSize' =>1,'borderBottomColor'=>'black'); 
$fontStyle = array('italic'=> true, 'size'=>11, 'name'=>'Times New Roman','afterSpacing' => 0, 'Spacing'=> 0, 'cellMargin'=>0); 
$TfontStyle = array('bold'=>true, 'italic'=> true, 'size'=>11, 'name' => 'Times New Roman', 'afterSpacing' => 0, 'Spacing'=> 0, 'cellMargin'=>0); 
$cfontStyle = array('allCaps'=>true,'italic'=> true, 'size'=>11, 'name' => 'Times New Roman','afterSpacing' => 0, 'Spacing'=> 0, 'cellMargin'=>0); 
$noSpace = array('textBottomSpacing' => -1);   
$table = $section->addTable('myOwnTableStyle',array('borderSize' => 1, 'borderColor' => '999999', 'afterSpacing' => 0, 'Spacing'=> 0, 'cellMargin'=>0 )); 
$table2 = $section->addTable('myOwnTableStyle'); 
$table->addRow(-0.5, array('exactHeight' => -5)); 
$countrystate = $news['CompanyDetails']['Country'].' - '.$news['CompanyDetails']['State']; 
$table->addCell(2500,$styleCell)->addText('Date',$TfontStyle); 
$table->addCell(6000,$styleCell)->addText($news['CompanyDetails']['Date'],$fontStyle); 
$table->addCell(1500,$styleCell)->addText('Cust. Ref',$TfontStyle); 
$table->addCell(2000,$styleCell)->addText($news['CompanyDetails']['Reference'],$fontStyle); 
$table->addRow(); 
$table->addCell(2500,$styleCell)->addText('Company Name',$TfontStyle); 
$table->addCell(6000,$styleCell)->addText($news['CompanyDetails']['CompanyName'],$cfontStyle); 
$table->addCell(1500,$styleCell)->addText('Tel',$TfontStyle); 
$table->addCell(2000,$styleCell)->addText($news['CompanyDetails']['Tel'],$fontStyle); 
$table->addRow(); 
$table->addCell(2500,$styleCell)->addText('Country',$TfontStyle); 
$table->addCell(6000,$styleCell)->addText($countrystate, $fontStyle); 
$table->addCell(1500,$styleCell)->addText('Fax',$TfontStyle); 
$table->addCell(2000,$styleCell)->addText($news['CompanyDetails']['Fex'],$fontStyle); 
$table->addRow(); 
$table->addCell(2500,$styleCell)->addText('Attn.',$TfontStyle); 
$table->addCell(6000,$styleCell)->addText($news['CompanyDetails']['ContectPerson'].' '. $news['CompanyDetails']['Designation'].' '.$news['CompanyDetails']['MobileNum'],$fontStyle); 
$table->addCell(1500,$styleCell)->addText('Email',$TfontStyle); 
$table->addCell(2000,$styleCell)->addText($news['CompanyDetails']['Email'],$fontStyle); 
$table->addRow(); 
$table->addCell(2500,$styleCell)->addText('Subject',$TfontStyle); 
$table->addCell(6000,$styleCell)->addText($news['CompanyDetails']['Subject'],$fontStyle); 
$table->addCell(1500,$styleCell)->addText('From',$TfontStyle); 
$table->addCell(2000,$styleCell)->addText($news['CompanyDetails']['From'],$fontStyle); 
$table->addRow(); 
$table->addCell(2500,$styleCell)->addText('Quotation No.',$TfontStyle); 
$table->addCell(6000,$styleCell)->addText($news['CompanyDetails']['QuotationNum'],$fontStyle); 
$table->addCell(1500,$styleCell)->addText('pages',$TfontStyle); 
$table->addCell(2000,$styleCell)->addText($news['CompanyDetails']['Pages'],$fontStyle); 

$section->addTextBreak(-1); 

結果は、この

enter image description here

です....私のコードですが、私はこのような必要

+0

これは段落の問題だと思います。段落または単一の行が終わったときにそのスペースが見えるからです。してくださいので、もし問題が解決することができますし、段落の後にこの間隔を削除してください。私は見つけようとしましたが、私はそれを見つけませんでした。 – user3776989

答えて

0

スペースを追加するだけですaddTextのように値を0に整列する:

$table->addCell(2500,$styleCell)->addText('Date',$TfontStyle,array('align' => 'left', 'spaceAfter' => 0)); 
関連する問題