Buenos días chicos
Estoy intentando (sin exito) generar un archivo word desde una página php con un formato determinado.
El problema son las columnas y las filas que no se como tratarlos. ¿ Alguien me podría orientar ?
Este es el código que uso para generar el archivo word
<?php
$debug= true;
if($debug){
//ini_set('display_errors', 1);
//ini_set('display_startup_errors', 1);
//error_reporting(E_ALL);
}
include "../core/autoload.php";
include "../core/modules/index/model/SellData.php";
include "../core/modules/index/model/ClientData.php";
include "../core/modules/index/model/CamisaData.php";
$sell = SellData::getById($_GET["sell_id"]);
$client = $sell->getClient();
$traje = CamisaData::getById($_GET["id"]);
require_once '../PhpWord/Autoloader.php';
use PhpOffice\PhpWord\Autoloader;
use PhpOffice\PhpWord\Settings;
Autoloader::register();
$word = new PhpOffice\PhpWord\PhpWord();
$section1 = $word->AddSection();
$section1->addText("Detalles del pedido",array("size"=>22,"bold"=>true,"align"=>"right"));
$styleTable = array('borderSize' => 6, 'borderColor' => '888888', 'cellMargin' => 40);
$styleFirstRow = array('borderBottomColor' => '0000FF', 'bgColor' => 'AAAAAA');
$tienda ="";
if($sell->tienda_id==1){ $tienda = "Sprezzatura";}
else if($sell->tienda_id==2){ $tienda = "Gentleman";}
$table1 = $section1->addTable("table1");
$table1->addRow();
$table1->addCell()->addText("Nombre");
$table1->addCell()->addText("Telefono");
$table1->addCell()->addText("Tienda");
$table1->addCell()->addText("Fecha");
//foreach($clients as $client){
$table1->addRow();
$table1->addCell(5000)->addText($client->nombre);
$table1->addCell(2000)->addText($client->telefono);
$table1->addCell(2000)->addText($tienda);
$table1->addCell(2000)->addText(date("d-M-y"));
//}
$tela_data = array(
array("name"=>"camisa","label"=>"Camisa : "),
array("name"=>"cuello_camisa","label"=>"Cuello : "),
array("name"=>"collar","label"=>"Collar : "),
array("name"=>"punio_camisa","label"=>"Puño :"),
array("name"=>"tapa","label"=>"Tapa : "),
array("name"=>"ojales","label"=>"Ojales : "),
array("name"=>"botones","label"=>"Botones : ")
);
$estilo_data = array(
array("name"=>"es_cuello","label"=>"Cuello : "),
array("name"=>"es_punio","label"=>"Puño : "),
array("name"=>"es_bolsillo","label"=>"Bolsillo:"),
array("name"=>"es_espalda","label"=>"Espalda:"),
array("name"=>"es_tapa","label"=>"Tapa : "),
array("name"=>"es_acabado","label"=>"Acabado:"),
array("name"=>"es_iniciales","label"=>"Iniciales")
);
$medidas_data = array(
array("name"=>"me_cuello","label"=>"Cuello"),
array("name"=>"me_largo","label"=>"Largo"),
array("name"=>"me_hombros","label"=>"hombros"),
array("name"=>"me_pecho","label"=>"Pecho"),
array("name"=>"me_cintura","label"=>"Cintura"),
array("name"=>"me_cadera","label"=>"Cadera"),
array("name"=>"me_ancho_brazo","label"=>"Ancho Brazo"),
array("name"=>"me_largo_brazo","label"=>"Largo Brazo"),
array("name"=>"me_munieca","label"=>"Muñeca"),
array("name"=>"co_altura","label"=>"Altura"),
array("name"=>"co_observaciones","label"=>"Observaciones")
);
$complexion_data = array(
array("name"=>"co_altura","label"=>"Altura"),
array("name"=>"co_observaciones","label"=>"Observaciones")
);
$section1->addText("Camisa",array("size"=>20,"bold"=>true,"align"=>"right"));
$table1 = $section1->addTable("table1");
$table1->addRow();
$medidas1 = $table1->addCell();
$estilos1 = $table1->addCell();
$medidas1->addText("TELA");
$estilos1->addText("ESTILO");
//foreach($clients as $client){
$table2 = $medidas1->addTable("table2");
foreach($tela_data as $td){
$table2->addRow();
$table2->addCell(7000)->addText($td["label"]);
$table2->addCell(7000)->addText($traje->{$td["name"]});
}
$table3 = $estilos1->addTable("table3");
foreach($estilo_data as $td){
$table3->addRow();
$table3->addCell(7000)->addText($td["label"]);
$table3->addCell(7000)->addText($traje->{$td["name"]});
}
$table1 = $section1->addTable("table1");
$table1->addRow();
$medidas1 = $table1->addCell();
$medidas1->addText("MEDIDAS");
//foreach($clients as $client){
$table2 = $medidas1->addTable("table2");
// ultimo cambio foreach($complexion_data as $td){
foreach($medidas_data as $td){
$table2->addRow();
$table2->addCell(7000)->addText($td["label"]);
$table2->addCell(7000)->addText($traje->{$td["name"]});
}
$word->addTableStyle('table1', $styleTable,$styleFirstRow);
/// datos bancarios
$filename = "camisa-".time().".docx";
#$word->setReadDataOnly(true);
$word->save($filename,"Word2007");
//chmod($filename,0444);
header("Content-Disposition: attachment; filename='$filename'");
readfile($filename); // or echo file_get_contents($filename);
unlink($filename); // remove temp file
?>
Este código genera el documento de la izquierda ( de la foto) y me gustaría tener el documento de la derecha
Adjunto imagen
http://pruebagonzalo.org.es/entredesarrolladores/formato.jpg