本文整理汇总了PHP中PHPWord类的典型用法代码示例。如果您正苦于以下问题:PHP PHPWord类的具体用法?PHP PHPWord怎么用?PHP PHPWord使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PHPWord类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test
public function test()
{
// Include the PHPWord.php, all other classes were loaded by an autoloader
require_once APPPATH . '/libraries/PHPWord.php';
//$this->load->library('PHPWord');
// Create a new PHPWord Object
$PHPWord = new PHPWord();
//$PHPWord = $this->phpword;
// Every element you want to append to the word document is placed in a section. So you need a section:
$section = $PHPWord->createSection();
// After creating a section, you can append elements:
$section->addText('Hello world!');
// You can directly style your text by giving the addText function an array:
$section->addText('Hello world! I am formatted.', array('name' => 'Tahoma', 'size' => 16, 'bold' => true));
// If you often need the same style again you can create a user defined style to the word document
// and give the addText function the name of the style:
$PHPWord->addFontStyle('myOwnStyle', array('name' => 'Verdana', 'size' => 14, 'color' => '1B2232'));
$section->addText('Hello world! I am formatted by a user defined style', 'myOwnStyle');
// You can also putthe appended element to local object an call functions like this:
$myTextElement = $section->addText('Hello World!');
//$myTextElement->setBold();
//$myTextElement->setName('Verdana');
//$myTextElement->setSize(22);
$styleTable = array('borderColor' => '006699', 'borderSize' => 6, 'cellMargin' => 50);
$styleFirstRow = array('bgColor' => '66BBFF');
$PHPWord->addTableStyle('myTable', $styleTable, $styleFirstRow);
$table = $section->addTable('myTable');
$table->addRow();
$cell = $table->addCell(2000);
$cell->addText('Cell 1');
$cell = $table->addCell(2000);
$cell->addText('Cell 2');
// $cell = $table->addCell(2000);
//$cell->addText('Cell 3');
// Add image elements
$section->addImage(APPPATH . '/images/side/jqxs-l.JPG');
$section->addTextBreak(1);
//$section->addImage(APPPATH.'/images/side/jqxs-l.JPG', array('width'=>210, 'height'=>210, 'align'=>'center'));
//$section->addTextBreak(1);
//$section->addImage(APPPATH.'/images/side/jqxs-l.jpg', array('width'=>100, 'height'=>100, 'align'=>'right'));
// At least write the document to webspace:
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('helloWorld.docx');
exit;
//download
/*
$filename='just_some_random_name.docx'; //save our document as this file name
header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document'); //mime type
header('Content-Disposition: attachment;filename="'.$filename.'"'); //tell browser what's the file name
header('Cache-Control: max-age=0'); //no cache
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('php://output');
*/
//force download
// $this->load->helper('download');
// $data = file_get_contents("helloWorld.docx"); // Read the file's contents
// $name = 'helloWorld.docx';
// force_download($name, $data);
}
示例2: postCancelar
public function postCancelar()
{
//return Input::all();
$this->response->Cancelar(Input::get('contratos'), Input::get('penaCapital'), Input::get('penaAccesorios'), Input::get('penaMoratorios'), Input::get('capital'));
$cliente = DB::table('expediente')->where('id_expediente', Input::get('contratos'))->join('cliente', 'cliente.rfc', '=', 'expediente.fk_rfc')->select('cliente.nombre', 'cliente.ape_mate', 'cliente.ape_pate')->get()[0];
$terreno = DB::table('expediente')->where('id_expediente', Input::get('contratos'))->join('solicitud', 'solicitud.fk_expediente', '=', 'expediente.id_expediente')->join('lote', 'lote.id_lote', '=', 'solicitud.fk_lote')->join('manzana', 'manzana.id_manzana', '=', 'lote.fk_manzana')->join('desarrollo', 'desarrollo.id_desarrollo', '=', 'manzana.fk_desarrollo')->select('lote.lote', 'manzana.num_letra', 'desarrollo.nombre')->get()[0];
if (Input::get('capital') - Input::get('penaCapital') > 0) {
$ImporteLiquido = Input::get('capital') - Input::get('penaCapital');
} else {
$ImporteLiquido = 0;
}
$PHPWord = new PHPWord();
$document = $PHPWord->loadTemplate(dirname(__FILE__) . '/PHPWord/recibo_liquidacion.docx');
$fecha = explode('-', date('Y-m-d'));
$document->setValue('dia', $fecha[2]);
$document->setValue('mes', $fecha[1]);
$document->setValue('anio', $fecha[0]);
$document->setValue('cantidadDevuelta', '$' . $ImporteLiquido);
$document->setValue('expediente', Input::get('contratos'));
$document->setValue('Terreno', $terreno->lote);
$document->setValue('Manzana', $terreno->num_letra);
$document->setValue('Fraccionamiento', $terreno->nombre);
$document->setValue('Penalizacion', Input::get('penalizacionCapital') . '%');
$document->setValue('PrecioVenta', '$' . Input::get('importeTotal'));
$document->setValue('CapitalPagado', '$' . Input::get('capital'));
$document->setValue('cantidadPenal', '$' . Input::get('penaCapital'));
$document->setValue('ImporteLiquido', '$' . $ImporteLiquido);
$document->setValue('Cliente', $cliente->nombre . " " . $cliente->ape_pate . " " . $cliente->ape_mate);
$document->save(Input::get('contratos') . '_cancelacion.docx');
return View::make('cobranza/mensajeCobranza')->with('datos', array('seccion' => 'SICyA | Cobranza | Cancealr Terreno', 'cabecera' => 'Cancelando Contrato', 'icono' => 'glyphicon glyphicon-file', 'tipo_mensaje' => true, 'mensaje' => "Se ha Cancelado el Contrato."));
}
示例3: writeDocument
public function writeDocument(PHPWord $pPHPWord = null)
{
// Create XML writer
if ($this->getParentWriter()->getUseDiskCaching()) {
$objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
$objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
}
// XML header
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
// w:document
$objWriter->startElement('w:document');
$objWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
$objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
$objWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math');
$objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
$objWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing');
$objWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word');
$objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
$objWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
$objWriter->startElement('w:body');
$_sections = $pPHPWord->getSections();
$countSections = count($_sections);
$pSection = 0;
if ($countSections > 0) {
foreach ($_sections as $section) {
$pSection++;
$_elements = $section->getElements();
foreach ($_elements as $element) {
if ($element instanceof PHPWord_Section_Text) {
$this->_writeText($objWriter, $element);
} elseif ($element instanceof PHPWord_Section_TextRun) {
$this->_writeTextRun($objWriter, $element);
} elseif ($element instanceof PHPWord_Section_Link) {
$this->_writeLink($objWriter, $element);
} elseif ($element instanceof PHPWord_Section_Title) {
$this->_writeTitle($objWriter, $element);
} elseif ($element instanceof PHPWord_Section_TextBreak) {
$this->_writeTextBreak($objWriter);
} elseif ($element instanceof PHPWord_Section_PageBreak) {
$this->_writePageBreak($objWriter);
} elseif ($element instanceof PHPWord_Section_Table) {
$this->_writeTable($objWriter, $element);
} elseif ($element instanceof PHPWord_Section_ListItem) {
$this->_writeListItem($objWriter, $element);
} elseif ($element instanceof PHPWord_Section_Image || $element instanceof PHPWord_Section_MemoryImage) {
$this->_writeImage($objWriter, $element);
} elseif ($element instanceof PHPWord_Section_Object) {
$this->_writeObject($objWriter, $element);
} elseif ($element instanceof PHPWord_TOC) {
$this->_writeTOC($objWriter);
}
}
if ($pSection == $countSections) {
$this->_writeEndSection($objWriter, $section);
} else {
$this->_writeSection($objWriter, $section);
}
}
}
$objWriter->endElement();
// End w:body
$objWriter->endElement();
// End w:document
// Return
return $objWriter->getData();
}
示例4: generate
public function generate($xml_file)
{
if (!file_exists($xml_file)) {
throw new Exception("XML-file '{$xml_file}' NOT exosts.");
}
$xml = new SimpleXMLElement(file_get_contents($xml_file));
// Create a new PHPWord Object
$objPHPWord = new PHPWord();
// Every element you want to append to the word document is placed in a section. So you need a section:
$section = $objPHPWord->createSection();
foreach ($xml->body->p as $p) {
$section->addText((string) $p);
dbg::write((string) $p);
}
header('Content-Type: application/vnd.ms-word');
header('Content-Disposition: attachment;filename="' . (string) $xml->body['title'] . '.doc"');
header('Cache-Control: max-age=0');
$objWriter = PHPWord_IOFactory::createWriter($objPHPWord, 'Word2007');
$objWriter->save('php://output');
exit;
}
示例5: generateResume
public function generateResume($id = NULL)
{
//Проверяем, зарегестрированн ли пользователь и его роль
if (isset($this->session->userdata['id'])) {
$user = Doctrine::getTable('User')->findOneBy('id', $this->session->userdata['id']);
if ($user->getRole() == 'applicant') {
echo json_encode(array('status' => false, 'msg' => 'Скачивать резюме могут только работодатели и агентства!'));
exit;
}
} else {
echo json_encode(array('status' => false, 'msg' => 'Скачивать резюме могут только зарегестрированные пользователи!'));
exit;
}
if (empty($id)) {
echo json_encode(array('status' => false));
exit;
}
$resume = Doctrine::getTable('Resume')->findOneBy('id', $id);
if (empty($resume)) {
echo json_encode(array('status' => false));
exit;
}
//Папка для хранения файлов
$path = str_replace('system/', '', BASEPATH) . 'downloads/resumes/';
//Создаем ее, если она была созданна ранее
if (!file_exists($path)) {
mkdir($path, 0, true);
}
//Имя файла с резюме
$file_name = 'resume_' . $id . '.docx';
//Если такой файл уже есть, то проверяем дату его создания
if (file_exists($path . $file_name)) {
if ($resume->modification_date != NULL and $resume->modification_date >= date('Y-m-d H:i:s', filectime($path . $file_name))) {
echo json_encode(array('status' => true, 'url' => site_url() . 'downloads/resumes/' . $file_name));
exit;
} else {
unlink($path . $file_name);
}
}
$this->load->library('PHPWord');
$word = new PHPWord();
$section = $word->createSection();
$section->addText('Резюме от: ' . date('Y.m.d', $resume->getPlacementDate()), array('name' => 'Verdana', 'color' => '006699'));
$section->addText($resume->formatName('s n p'), array('name' => 'Verdana', 'bold' => true, 'size' => 20));
$section->addImage($resume->getRealImagePath(), array('align' => 'left'));
$section->addTextBreak();
$bold = array('bold' => true);
$grey = array('bgColor' => 'dcdcdc', 'valign' => 'center');
$center = array('valign' => 'center');
$styleTable = array('borderSize' => 4, 'borderColor' => 'dcdcdc');
$word->addTableStyle('myOwnTableStyle', $styleTable);
$table = $section->addTable('myOwnTableStyle');
$data = array('Возраст:' => $resume->getResumeAuthorAge(), 'Пол:' => $resume->gender->getDescription(), 'Семейное положение:' => $resume->family_state->getValue(), 'Наличие детей:' => $resume->getChilds(), 'Город проживания:' => $resume->getCity(), 'Район проживания:' => $resume->getArea(), 'Национальность:' => $resume->getNationality(), 'E-mail:' => $resume->getContactEmail(), 'Контактный телефон:' => $resume->getContactPhone());
foreach ($data as $key => $value) {
$table->addRow();
$table->addCell(3000, $grey)->addText($key, $bold, array('spaceAfter' => 0));
$table->addCell(6000, $center)->addText($value, array(), array('spaceAfter' => 0));
}
$section->addTextBreak();
//Желаемая должность
$section->addText(trim($resume->getDesiredPosition()) == '' ? 'Точная информация о интересующей должности не указанна' : $resume->getDesiredPosition(), array('name' => 'Verdana', 'bold' => true, 'size' => 16));
//Дополнительно рассматриваемые должности
if (count($resume->getPositions()) > 0) {
$section->addText('Также рассматриваются:', array('name' => 'Verdana', 'bold' => true, 'size' => 12));
foreach ($resume->getPositions() as $position_id) {
$position = Doctrine::getTable('Position')->findOneBy('id', $position_id);
$section->addText($position->getName());
}
}
$table = $section->addTable('myOwnTableStyle');
$table->addRow();
$table->addCell(3000, $grey)->addText("Квалификация:", $bold);
$cell = $table->addCell('3000', $center);
foreach ($resume->getQualificationForWord() as $item) {
$cell->addText($item);
}
$data = array('Описание опыта работы:' => $resume->getExperienceDescription(), 'Период опыта работы:' => $resume->experience->getValue(), 'Наличие рекомендаций:' => $resume->getGuidanceAvailability());
foreach ($data as $key => $value) {
$table->addRow();
$table->addCell(3000, $grey)->addText($key, $bold, array('spaceAfter' => 0));
$table->addCell(6000, $center)->addText($value, array(), array('spaceAfter' => 0));
}
$section->addTextBreak();
$section->addText('Образование', array('name' => 'Verdana', 'color' => '006699', 'bold' => true, 'size' => 16));
$table = $section->addTable('myOwnTableStyle');
$table->addRow();
$table->addCell(3000, $grey)->addText("Образование:", $bold, array('spaceAfter' => 0));
$table->addCell(6000, $center)->addText($resume->education->getValue(), array(), array('spaceAfter' => 0));
$table->addRow();
$table->addCell(3000, $grey)->addText("Специальность:", $bold, array('spaceAfter' => 0));
$table->addCell(6000, $center)->addText($resume->getSpeciality(), array(), array('spaceAfter' => 0));
$section->addTextBreak();
$section->addText('Пожелания к работе', array('name' => 'Verdana', 'color' => '006699', 'bold' => true, 'size' => 16));
$table = $section->addTable('myOwnTableStyle');
$data = array('Регион работы:' => $resume->getWorkRegion()->getValue(), 'Работа с проживанием в семье:' => (int) $resume->getHomestay() == 1 ? 'Да' : 'Нет', 'Вид занятости:' => $resume->getOperatingSchedulesText(), 'График работы:' => $resume->getWorkTimetable(), 'Заработная плата:' => $resume->getPaymentDetails());
foreach ($data as $key => $value) {
$table->addRow();
$table->addCell(3000, $grey)->addText($key, $bold, array('spaceAfter' => 0));
$table->addCell(6000, $center)->addText($value, array(), array('spaceAfter' => 0));
}
//.........这里部分代码省略.........
示例6: executeIndex
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function executeIndex(sfWebRequest $request)
{
// Recuperar el Tramite y el Proceso
$this->setLayout('descarga');
$template = Doctrine::getTable('ClaDocumentos')->findOneByClaTramiteIdAndClaProcesoId($request->getParameter('tramite'), $request->getParameter('proceso'));
$seguimiento = Doctrine::getTable('ProcSeguimiento')->getTramite($request->getParameter('seguimiento'));
$PHPWord = new PHPWord();
$filename = 'carta_' . $request->getParameter('tramite') . '_' . $request->getParameter('proceso') . '.docx';
$document = $PHPWord->loadTemplate(sfConfig::get('sf_root_dir') . '/archivos/templates/' . $template->getPath());
date_default_timezone_set('America/La_Paz');
setlocale(LC_TIME, 'spanish');
$document->setValue('fecha_carta', strftime("%d de %B de %Y"));
foreach ($seguimiento->ProcFormularios as $formulario) {
$tabla = Doctrine::getTable($formulario->ClaTabla->getDescripcion())->findOneById($formulario->getGetId());
if ($formulario->ClaTabla->getDescripcion() == 'DatPersonas') {
$document->setValue('nombre_estudiante', $tabla->getNombreCompleto());
}
}
$document->save(sfConfig::get('sf_root_dir') . '/archivos/generados/' . $filename);
// $guardar = new ClaDocumentos();
// $guardar->setClaTramiteId(1);
// $guardar->setClaProcesoId(1);
// $guardar->setPath($filename);
// $guardar->save();
$this->filename = $filename;
$this->enlace = sfConfig::get('sf_root_dir') . '/archivos/generados//' . $filename;
}
示例7: save
public function save($html, $dir)
{
import("@.ORG.htmltodocx.documentation.support_functions");
$phpword_object = new PHPWord();
$section = $phpword_object->createSection();
// HTML Dom object:
$html_dom = new simple_html_dom();
$html_dom->load('<html><body>' . $html . '</body></html>');
// Note, we needed to nest the html in a couple of dummy elements.
// Create the dom array of elements which we are going to work on:
$html_dom_array = $html_dom->find('html', 0)->children();
// We need this for setting base_root and base_path in the initial_state array
// (below). We are using a function here (derived from Drupal) to create these
// paths automatically - you may want to do something different in your
// implementation. This function is in the included file
// documentation/support_functions.inc.
$paths = htmltodocx_paths();
// Provide some initial settings:
$initial_state = array('phpword_object' => &$phpword_object, 'base_root' => $paths['base_root'], 'base_path' => $paths['base_path'], 'current_style' => array('size' => '11'), 'parents' => array(0 => 'body'), 'list_depth' => 0, 'context' => 'section', 'pseudo_list' => TRUE, 'pseudo_list_indicator_font_name' => 'Wingdings', 'pseudo_list_indicator_font_size' => '7', 'pseudo_list_indicator_character' => 'l ', 'table_allowed' => TRUE, 'treat_div_as_paragraph' => TRUE, 'style_sheet' => htmltodocx_styles_example());
// Convert the HTML and put it into the PHPWord object
htmltodocx_insert_html($section, $html_dom_array[0]->nodes, $initial_state);
// Clear the HTML dom object:
$html_dom->clear();
unset($html_dom);
// Save File
$str = explode(".", $h2d_file_uri);
$h2d_file_uri = $dir . "wordtemp/" . time() . ".docx";
if (!file_exists($dir . "wordtemp/")) {
$this->createFolders($dir . "wordtemp/");
//判断目标文件夹是否存在
}
$objWriter = PHPWord_IOFactory::createWriter($phpword_object, 'Word2007');
$objWriter->save($h2d_file_uri);
return $h2d_file_uri;
}
示例8: getInstance
/**
* New instance
* @param bool $setDefaultProperties initialize instance with default properties
* @return PHPWord
*/
public function getInstance($setDefaultProperties = true)
{
$phpWord = new PHPWord();
if ($setDefaultProperties) {
$phpWord->getDocInfo()->setCreator(ArrayHelper::getValue($this->properties, 'creator'))->setLastModifiedBy(ArrayHelper::getValue($this->properties, 'creator'))->setTitle(ArrayHelper::getValue($this->properties, 'title'))->setSubject(ArrayHelper::getValue($this->properties, 'subject'))->setDescription(ArrayHelper::getValue($this->properties, 'description'))->setKeywords(ArrayHelper::getValue($this->properties, 'keywords'))->setCategory(ArrayHelper::getValue($this->properties, 'category'))->setCompany(ArrayHelper::getValue($this->properties, 'company'));
}
return $phpWord;
}
示例9: generate_docx
function generate_docx($html, $file_path, &$file_takeout_tmp_files)
{
$phpword_object = new PHPWord();
$section = $phpword_object->createSection();
$html_dom = new simple_html_dom();
$html_dom->load($html);
$html_dom_array = $html_dom->find('html', 0)->children();
$paths = htmltodocx_paths();
$initial_state = array('phpword_object' => &$phpword_object, 'base_root' => $paths['base_root'], 'base_path' => $paths['base_path'], 'current_style' => array('size' => '11'), 'parents' => array(0 => 'body'), 'list_depth' => 0, 'context' => 'section', 'pseudo_list' => TRUE, 'pseudo_list_indicator_font_name' => 'Wingdings', 'pseudo_list_indicator_font_size' => '7', 'pseudo_list_indicator_character' => 'l ', 'table_allowed' => TRUE, 'treat_div_as_paragraph' => FALSE, 'style_sheet' => htmltodocx_styles(), 'download_img_path' => elgg_get_data_path(), 'download_img_tmp' => &$file_takeout_tmp_files);
htmltodocx_insert_html($section, $html_dom_array[0]->nodes, $initial_state);
$html_dom->clear();
unset($html_dom);
$objWriter = PHPWord_IOFactory::createWriter($phpword_object, 'Word2007');
// Word2007 is the only option :-(
$objWriter->save($file_path);
}
示例10: writeMeta
/**
* Write Meta file to XML format
*
* @param PHPWord $pPHPWord
* @return string XML Output
* @throws Exception
*/
public function writeMeta(PHPWord $pPHPWord = null)
{
// Create XML writer
$objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
$objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
$objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
}
// XML header
$objWriter->startDocument('1.0', 'UTF-8');
// office:document-meta
$objWriter->startElement('office:document-meta');
$objWriter->writeAttribute('xmlns:office', 'urn:oasis:names:tc:opendocument:xmlns:office:1.0');
$objWriter->writeAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
$objWriter->writeAttribute('xmlns:dc', 'http://purl.org/dc/elements/1.1/');
$objWriter->writeAttribute('xmlns:meta', 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0');
$objWriter->writeAttribute('xmlns:ooo', 'http://openoffice.org/2004/office');
$objWriter->writeAttribute('xmlns:grddl', 'http://www.w3.org/2003/g/data-view#');
$objWriter->writeAttribute('office:version', '1.2');
// office:meta
$objWriter->startElement('office:meta');
// dc:creator
$objWriter->writeElement('dc:creator', $pPHPWord->getProperties()->getLastModifiedBy());
// dc:date
$objWriter->writeElement('dc:date', gmdate('Y-m-d\\TH:i:s.000', $pPHPWord->getProperties()->getModified()));
// dc:description
$objWriter->writeElement('dc:description', $pPHPWord->getProperties()->getDescription());
// dc:subject
$objWriter->writeElement('dc:subject', $pPHPWord->getProperties()->getSubject());
// dc:title
$objWriter->writeElement('dc:title', $pPHPWord->getProperties()->getTitle());
// meta:creation-date
$objWriter->writeElement('meta:creation-date', gmdate('Y-m-d\\TH:i:s.000', $pPHPWord->getProperties()->getCreated()));
// meta:initial-creator
$objWriter->writeElement('meta:initial-creator', $pPHPWord->getProperties()->getCreator());
// meta:keyword
$objWriter->writeElement('meta:keyword', $pPHPWord->getProperties()->getKeywords());
// @todo : Where these properties are written ?
// $pPHPWord->getProperties()->getCategory()
// $pPHPWord->getProperties()->getCompany()
$objWriter->endElement();
$objWriter->endElement();
// Return
return $objWriter->getData();
}
示例11: display
function display()
{
//declare variables
global $db;
$fileName = "TestTour.docx";
$PHPWord = new PHPWord();
$section = $PHPWord->createSection(array("marginTop" => "0", "marginLeft" => "0"));
/* $tour = new Tour();
$record = isset($_GET["record"]) ? htmlspecialchars($_GET["record"]) : '';
$sql = " SELECT t.id,t.name,t.tour_code,t.picture,
t.duration,t.transport2, t.operator,t.description,
t.deleted,t.tour_code,t.from_place,t.to_place,
t.start_date,t.end_date,t.division,contract_value,currency_id,
currency,u.first_name,u.last_name
FROM tours t
INNER JOIN users u
ON t.assigned_user_id = u.id
WHERE t.id = '" . $record . "' AND t.deleted = 0 AND u.deleted = 0 ";
$result = $db->query($sql);
$row = $db->fetchByAssoc($result);*/
//create word ile
// $section->addImage('C:\xampp\htdocs\carnival\modules\Tours\views\carnival_header.jpg', array("align" => "center"));
//$section->addText("haha");
$section->addImage('modules\\Tours\\views\\carnival_header.jpg', array("width" => 793, "height" => 125, "align" => "center"));
//save file
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, "Word2007");
$objWriter->save($fileName);
//return word file
if (!$fileName) {
die("file not found");
}
ob_end_clean();
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename={$fileName}");
header("Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document");
header("Content-Transfer-Encoding: binary");
readfile($fileName);
//unlink($fileName);
exit;
}
示例12: createDoc
function createDoc($name = null)
{
$PHPWord = new PHPWord();
//return;
$this->getData();
$template = $PHPWord->loadTemplate($this->modelliDir . $this->modello);
foreach ($this->data as $tb => $data) {
foreach ($data as $col => $val) {
try {
$val = mb_detect_encoding($val) == 'UTF-8' ? utf8_decode($val) : $val;
$template->setValue("{$tb}.{$col}", $val);
} catch (Exception $e) {
echo "<p>{$tb}.{$col}</p>";
}
}
}
$template->setValue("data", date("d/m/Y"));
$pr = new pratica($this->pratica);
$file = $name ? $pr->documenti . $name : $pr->documenti . $this->docName;
$template->save($file);
}
示例13: _createDocument
/**
* create new excel document
*
* @return void
*/
protected function _createDocument()
{
// this looks stupid, but the PHPDoc library is beta, so this is needed. otherwise the lib would create temp files in the template folder ;(
$templateFile = $this->_getTemplateFilename();
$tempTemplateFile = Tinebase_Core::guessTempDir() . DIRECTORY_SEPARATOR . Tinebase_Record_Abstract::generateUID() . '.docx';
copy($templateFile, $tempTemplateFile);
$this->_docObject = new PHPWord();
if ($templateFile !== NULL) {
$this->_docTemplate = $this->_docObject->loadTemplate($tempTemplateFile);
}
unlink($tempTemplateFile);
}
示例14: writeDocument
/**
*
* @param PHPWord $PHPWord
* @return string
*/
public function writeDocument(PHPWord $PHPWord = null)
{
$numbering = $PHPWord->getNumbering();
// Create XML writer
if ($this->getParentWriter()->getUseDiskCaching()) {
$objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
$objWriter = new PHPWord_Shared_XMLWriter(PHPWord_Shared_XMLWriter::STORAGE_MEMORY);
}
// XML header
$objWriter->startDocument('1.0', 'UTF-8', 'yes');
// START w:numbering
$objWriter->startElement('w:numbering');
$objWriter->writeAttribute('xmlns:ve', 'http://schemas.openxmlformats.org/markup-compatibility/2006');
$objWriter->writeAttribute('xmlns:o', 'urn:schemas-microsoft-com:office:office');
$objWriter->writeAttribute('xmlns:r', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships');
$objWriter->writeAttribute('xmlns:m', 'http://schemas.openxmlformats.org/officeDocument/2006/math');
$objWriter->writeAttribute('xmlns:v', 'urn:schemas-microsoft-com:vml');
$objWriter->writeAttribute('xmlns:wp', 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing');
$objWriter->writeAttribute('xmlns:w10', 'urn:schemas-microsoft-com:office:word');
$objWriter->writeAttribute('xmlns:w', 'http://schemas.openxmlformats.org/wordprocessingml/2006/main');
$objWriter->writeAttribute('xmlns:wne', 'http://schemas.microsoft.com/office/word/2006/wordml');
// Write all of the abstractNum elements
foreach ($numbering as $key => $value) {
$value->toXml($objWriter);
}
// Write all of the num elements
foreach ($numbering as $key => $value) {
$objWriter->startElement('w:num');
$objWriter->writeAttribute("w:numId", $key + 1);
$objWriter->startElement('w:abstractNumId');
$objWriter->writeAttribute("w:val", $key + 1);
$objWriter->endElement();
$objWriter->endElement();
}
// END w:numbering
$objWriter->endElement();
return $objWriter->getData();
}
示例15: GeraArquivoDoc
public Function GeraArquivoDoc() {
$PHPWord = new PHPWord();
$arquivo_clinica = "../../../sgmo/laudo_modelo/$MY_PARAMETRO_ID/normal/$arquivo_laudo";
$document = $PHPWord->loadTemplate($arquivo_clinica);
//caso seja necessário preencher o cabeçalho com os dados da clínica
$document->setValue('nome_emp', " $clinica_rs");
$document->setValue('cnpj_emp', " $clinica_cnpj");
$document->setValue('rua_emp', " $endereco");
$document->setValue('tel_emp', " $tel_clinica");
$document->setValue('cidade_emp', " $cidade");
$document->setValue('estado_emp', " $estado");
//Dados do funcinário para preencher o cabeçalho
$document->setValue('nome_func', " $funcionario");
$document->setValue('doc_func', " $doc_funcionario");
$document->setValue('empresa_func', " $empresa");
$document->setValue('dat_func', " $data_nascimento");
$document->setValue('func_funcionario', " $funcao");
$document->setValue('idade_func', " $idade");
$document->setValue('tel_func', " $telefone");
$document->setValue('idade_func', " $idade");
$document->setValue('data_exame_func', " $data_exame");
$document->setValue('medico_solicitante', " ");
$document->setValue('medico_solicitante', " ");
$document->setValue('convenio_func', " $clinica_rs");
$document->setValue('observacao', " XXXXXXXXXXXXXXXXXXXXXX");
//Marcações no documento
$document->setValue('nx', "X");
$nome_arquivo = $funcionario . "_" . $numero_ficha;
$arquivo = "laudados/" . removerAcento($nome_arquivo) . ".docx";
$document->save($arquivo);
}