Я написал код, который создает документ Word.Я намеревался создать две разделенные таблицы, но я не могу этого сделать: первая создается внутри второй.Это код:
<?php
$word= new COM("word.application") or die("Unable to create Word document");
// Hide MS Word application window
$word->Visible = 0;
//Create new document
$WrdDoc = $word->Documents->Add();
// Define page margins
$word->Selection->PageSetup->LeftMargin = '2';
$word->Selection->PageSetup->RightMargin = '2';
// Define font settings
$word->Selection->Font->Name = 'Times New Roman';
$word->Selection->Font->Size = 18;
// Add text
$word->Selection->ParagraphFormat->Alignment = 1;
$word->Selection->TypeText("Questo e' il PDP!\n");
$materia[0] = "Italiano";
$materia[1] = "Storia";
$strumenti_compensativi[0] = "Mappe concettuali";
$strumenti_compensativi[1] = "Calcolatrice";
$misure_dispensative[0] = "Lettura ad alta voce";
$misure_dispensative[1] = "Scrittura sotto dettatura";
for( $i=0; $i<2; $i++ ) {
$word->Selection->Font->Name = 'Times New Roman';
$word->Selection->Font->Size = 16;
$word->Selection->TypeText("$materia[$i]\n");
$WTable = $WrdDoc->Tables->Add($word->Selection->Range, 2, 2); // Colums, Rows
$WrdDoc->Tables[1]->Borders->InsideLineStyle=1;
$WrdDoc->Tables[1]->Borders->OutsideLineStyle = 1;
$WTable->Cell(1,1)->Width = "3";
$WTable->Cell(1,2)->Width = "12";
$WTable->Cell(1,1)->Range->Font->Name = "Times New Roman";
$WTable->Cell(1,1)->Range->Shading->BackgroundPatternColor = hexdec ( "00ff00" );
$WTable->Cell(1,1)->Range->Font->Size = 12;
$WTable->Cell(1,1)->Range->Bold = False;
$WTable->Cell(1,1)->Range->Font->Italic = False;
$WTable->Cell(1,1)->Range->Text = "Strumenti compensativi";
$WTable->Cell(1,2)->Range->Font->Size = 12;
$WTable->Cell(1,2)->Range->Bold = False;
$WTable->Cell(1,2)->Range->Font->Italic = False;
$WTable->Cell(1,2)->Range->Text = "$strumenti_compensativi[$i]";
$WTable->Cell(2,1)->Width = "3";
$WTable->Cell(2,2)->Width = "12";
$WTable->Cell(2,1)->Range->Font->Name = "Times New Roman";
$WTable->Cell(2,1)->Range->Shading->BackgroundPatternColor = hexdec ( "00ff00" );
$WTable->Cell(1,1)->Range->Font->Size = 12;
$WTable->Cell(1,1)->Range->Bold = False;
$WTable->Cell(1,1)->Range->Font->Italic = False;
$WTable->Cell(2,1)->Range->Text = "Misure dispensative";
$WTable->Cell(2,2)->Range->Font->Size = 12;
$WTable->Cell(2,2)->Range->Bold = False;
$WTable->Cell(2,2)->Range->Font->Italic = False;
$WTable->Cell(2,2)->Range->Text = "$misure_dispensative[$i]";
}
// Save document
$filename = tempnam(sys_get_temp_dir(), "word");
$word->Documents[1]->SaveAs($filename);
$file="ilMiofile.doc";
header('Content-Description: File Transfer');
header('Content-Type: application/vnd.ms-word');
header('Content-Disposition: attachment; filename="ilMiofile.doc"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($filename));
ob_clean();
flush();
readfile($filename);
unlink($filename);
// Close and quit
$word->quit();
unset($word);
echo "done";
?>
Может кто-нибудь помочь мне, пожалуйста ...?Я думаю, проблема в том, что я не закрываю первый стол перед тем, как начать второй.Если да, то как я могу это сделать?