本文整理汇总了PHP中PHPWord_IOFactory::createWriter方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPWord_IOFactory::createWriter方法的具体用法?PHP PHPWord_IOFactory::createWriter怎么用?PHP PHPWord_IOFactory::createWriter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPWord_IOFactory
的用法示例。
在下文中一共展示了PHPWord_IOFactory::createWriter方法的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: word
function word()
{
$this->load->library('word');
$PHPWord = $this->word;
// New Word Document
$section = $this->word->createSection();
// New portrait section
// Add text elements
$header = $section->createHeader();
$fontStyle = array('name' => 'Times New Roman', 'size' => 20);
$header->addImage(FCPATH . '/assets/img/header.png');
$header->addText('Address');
$test = 'jishnu';
$section->addText('Hello World!' . $test);
$section->addTextBreak(2);
$section->addText('I am inline styled.', array('name' => 'Verdana', 'color' => '006699'));
$section->addTextBreak(2);
$PHPWord->addFontStyle('rStyle', array('bold' => true, 'italic' => true, 'size' => 20));
$PHPWord->addParagraphStyle('pStyle', array('align' => 'center', 'spaceAfter' => 100));
$section->addText('I am styled by two style definitions.', 'rStyle', 'pStyle');
$section->addText('I have only a paragraph style definition.', null, 'pStyle');
// Save File / Download (Download dialog, prompt user to save or simply open it)
$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');
}
示例3: 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;
}
示例4: generateResume
//.........这里部分代码省略.........
$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));
}
$section->addTextBreak();
$section->addText('Предоставляемые услуги', array('name' => 'Verdana', 'color' => '006699', 'bold' => true, 'size' => 16));
foreach ($resume->getResposibilitysArrayForWord() as $item) {
$section->addListItem($item, 0, 'fNormal', array('listType' => 7), 'pNormal');
}
$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));
$cell = $table->addCell('3000', $center, array('spaceAfter' => 0));
foreach ($resume->getLanguageSkillsArrayForWord() as $item) {
$cell->addText($item);
}
$data = array('Наличие загранпаспорта:' => (int) $resume->getForeignPassport() == 0 ? 'Нет' : 'Есть', 'Вероисповедание:' => $resume->getFaith(), 'Водительские права:' => $resume->getDriverLicence(), 'Наличие собственного авто:' => $resume->getOwnCar(), 'Наличие медкниги:' => (int) $resume->getMedicalBook() == 0 ? 'Нет' : 'Есть', 'Отношение к животным:' => $resume->getAnimalsAttitude(), 'Вредные привычки:' => $resume->getBadHabits());
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));
}
$objWriter = PHPWord_IOFactory::createWriter($word, 'Word2007');
$objWriter->save($path . $file_name);
echo json_encode(array('status' => true, 'url' => site_url() . 'downloads/resumes/' . $file_name));
}
示例5: 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;
}
示例6: index
function index($idCiudadano)
{
$this->load->library('word');
//our docx will have 'lanscape' paper orientation
$section = $this->word->createSection(array('orientation' => 'landscape', 'marginTop' => 2000, 'marginBottom' => 2000));
$header = $section->createHeader();
// Add a watermark to the header
$header->addWatermark('plantilla.png', array('marginTop' => -35, 'marginLeft' => -85));
$styleTable = array('borderSize' => 6, 'borderColor' => '000000', 'cellMargin' => 80);
$styleFirstRow = array('valign' => 'center', 'marginTop' => 90, 'borderBottomSize' => 14, 'borderBottomColor' => 'FFFFF', 'bgColor' => '393939');
$this->load->model(array('model_denuncias'));
$styleCell = array('jc' => 'center', 'valign' => 'center');
$styleCellBTLR = array('valign' => 'center', 'textDirection' => PHPWord_Style_Cell::TEXT_DIR_BTLR);
// Define font style for first row
$fontStyle = array('bold' => true, 'align' => 'center');
// Query
$resultados = $this->model_denuncias->by_ciudadano($idCiudadano);
$ciudadano = "Reporte de " . utf8_decode($resultados[0]['ciudadano']);
if (empty($resultados[0]['ciudadano'])) {
$section->addText("No se encontraron registros", array("color" => "3B0B17", "size" => 14, "bold" => true));
} else {
// Add table style
$this->word->addTableStyle('myOwnTableStyle', $styleTable, $styleFirstRow, $sectionStyle);
$section->addText(" ", array("size" => 12, "bold" => true));
$section->addText("Reporte Generado", array("color" => "3B0B17", "size" => 14, "bold" => true));
$section->addText($ciudadano, array("size" => 10, "bold" => true));
$section->addText($resultados[0]['telefono'], array("size" => 10, "bold" => true));
// Add table
$table = $section->addTable('myOwnTableStyle', $sectionStyle);
// Add row
$table->addRow(90);
$table->addCell(2000, $styleCell)->addText('Fecha', $fontStyle);
$table->addCell(2000, $styleCell)->addText('Dependencia', $fontStyle);
$table->addCell(2000, $styleCell)->addText('Estatus', $fontStyle);
$table->addCell(2000, $styleCell)->addText(utf8_decode('Recepción'), $fontStyle);
$table->addCell(2000, $styleCell)->addText('Medio', $fontStyle);
$table->addCell(500, $styleCell)->addText('Asunto', $fontStyle);
$table->addCell(500, $styleCell)->addText(utf8_decode('Dirección'), $fontStyle);
foreach ($resultados as $resultado) {
$table->addRow();
$table->addCell(2000)->addText("" . utf8_decode($resultado['fecha']));
$table->addCell(2000)->addText("" . utf8_decode($resultado['dependencia']));
$table->addCell(2000)->addText("" . utf8_decode($resultado['estatus']));
$table->addCell(2000)->addText("" . utf8_decode($resultado['recepcion']));
$table->addCell(2000)->addText("" . utf8_decode($resultado['medios']));
$table->addCell(2000)->addText("" . utf8_decode($resultado['asunto']));
$table->addCell(2000)->addText("" . utf8_decode($resultado['direccion']));
}
}
$filename = "DenunciasPorCiudadano.docx";
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
// Save File
$objWriter = PHPWord_IOFactory::createWriter($this->word, 'Word2007');
$objWriter->save('php://output');
}
示例7: generate
public function generate()
{
$this->createTitle();
// New portrait section
$section = $this->PHPWord->createSection();
// Add text elements
$section->addText('Привет мир!');
$section->addTextBreak(2);
$q = $this->calculation->get_q();
$section->addText($q, array('size' => 18, 'name' => 'Verdana', 'color' => '006699'));
$section->addTextBreak(2);
// Save File
$objWriter = \PHPWord_IOFactory::createWriter($this->PHPWord, 'Word2007');
$objWriter->save(PHP_WORD_ROOT . $this->fileName);
}
示例8: save_as_word
public function save_as_word($comments, $mark, $student_id, $assignment_id)
{
vendor('PHPWord.PHPWord');
$word = new PHPWord();
$url_base = C('URL_BASE');
$section = $word->createSection();
$section->addTitle(iconv('utf-8', 'GB2312//IGNORE', '评语 和 分数:'));
$section->addTextBreak(2);
$section->addText(iconv('utf-8', 'GB2312//IGNORE', $comments));
$section->addTextBreak(2);
$section->addText(iconv('utf-8', 'GB2312//IGNORE', $mark));
$output = \PHPWord_IOFactory::createWriter($word, 'Word2007');
$output->save($url_base . '/uploads/assignments/' . $student_id . '/' . $assignment_id . '/modify.doc');
return 1;
}
示例9: index
function index()
{
$this->load->library('word');
//our docx will have 'lanscape' paper orientation
$section = $this->word->createSection();
// Create header
$header = $section->createHeader();
// Add a watermark to the header
$header->addWatermark('plantilla.png', array('marginTop' => -35, 'marginLeft' => -85));
$styleTable = array('borderSize' => 6, 'borderColor' => '006699', 'cellMargin' => 80);
$styleFirstRow = array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF');
// Define cell style arrays
$styleCell = array('valign' => 'center');
$styleCellBTLR = array('valign' => 'center', 'textDirection' => PHPWord_Style_Cell::TEXT_DIR_BTLR);
// Define font style for first row
$fontStyle = array('bold' => true, 'align' => 'center');
// Add table style
$this->word->addTableStyle('myOwnTableStyle', $styleTable, $styleFirstRow);
// Add table
$table = $section->addTable('myOwnTableStyle');
// Add row
$table->addRow(900);
$table->addCell(2000, $styleCell)->addText('Row 1', $fontStyle);
$table->addCell(2000, $styleCell)->addText('Row 2', $fontStyle);
$table->addCell(2000, $styleCell)->addText('Row 3', $fontStyle);
$table->addCell(2000, $styleCell)->addText('Row 4', $fontStyle);
$table->addCell(500, $styleCellBTLR)->addText('Row 5', $fontStyle);
// Add more rows / cells
for ($i = 1; $i <= 10; $i++) {
$table->addRow();
$table->addCell(2000)->addText("Cell {$i}");
$table->addCell(2000)->addText("Cell {$i}");
$table->addCell(2000)->addText("Cell {$i}");
$table->addCell(2000)->addText("Cell {$i}");
$text = $i % 2 == 0 ? 'X' : '';
$table->addCell(500)->addText($text);
}
$filename = "descarga.docx";
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
// Save File
$objWriter = PHPWord_IOFactory::createWriter($this->word, 'Word2007');
$objWriter->save('php://output');
}
示例10: 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);
}
示例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: generate
//.........这里部分代码省略.........
$table->addCell(400, $styleTable)->addText("", $fontStyle, 'pHead');
$table->addCell(8200, $styleTable)->addText("{$d->di}", 'underline', 'pHead');
$section->addText('', $fontStyle, 'pHead');
$table = $section->addTable();
$table->addRow();
$table->addCell(400)->addText("");
$table->addCell(10000)->addText("Dengan Hormat,", $fontStyle, 'pHead');
$table->addRow();
$table->addCell(400, $styleTable)->addText("", $fontStyle, 'pHead');
$table->addCell(10000, $styleTable)->addText("Pertama sekali kami do’akan agar Bapak/Ibu senantiasa dalam keadaan sehat dan sukses selalu dalam menjalankan aktifitas, Amin.", $fontStyle, 'pHead');
$table->addRow();
$table->addCell(400)->addText("");
$table->addCell(10000)->addText("Selanjutnya kami memperkenalkan diri bahwa kami adalah Perguruan Tinggi Ilmu Komputer (STMIK-AMIK Riau) yang berlokasi di Jalan Purwodadi Indah Km. 10 Panam Pekanbaru Riau.", $fontStyle);
$table->addRow();
$table->addCell(400, $styleTable)->addText("", $fontStyle, 'pHead');
$table->addCell(10000, $styleTable)->addText("Sesuai dengan kalender akademik, setiap mahasiswa Jenjang Strata I (S.1) dan Diploma III (D.3) yang akan memasuki tahap akhir diwajibkan untuk melaksanakan Praktek Kerja Lapangan (PKL) / Magang dalam rangka mengasah kemampuan mereka untuk mengenal dunia kerja yang sesungguhnya.", $fontStyle, 'pHead');
$table->addRow();
$table->addCell(400)->addText("");
$table->addCell(10000)->addText("Sebagai upaya pelaksanaan kegiatan magang tersebut, kami mohon kiranya Bapak/Ibu dapat berkenan memberikan kesempatan kepada para mahasiswa kami untuk dapat melaksanakan PKL/Magang dari tangal 01 Juli s/d 24 Agustus 2013.", $fontStyle);
$table->addRow();
$table->addCell(400, $styleTable)->addText("", $fontStyle, 'pHead');
$table->addCell(10000, $styleTable)->addText("Perhatian dan binaan dari Bapak/Ibu sangat kami harapkan nantinya selama kegiatan tersebut dilaksanakan. Untuk Konfirmasi Selanjutnya Bapak/Ibu dapat menghubungi STMIK-AMIK Riau. Melalui :", $fontStyle, 'pHead');
//Kontak Dosen
$section->addText('', $fontStyle, 'pHead');
$table = $section->addTable();
foreach ($cont as $cnt) {
$table->addRow();
$table->addCell(400, $styleTable)->addText("", $fontStyle, 'pHead');
$table->addCell(400, $styleTable)->addText("{$no}. ", $fontStyle, 'pHead');
$table->addCell(4300, $styleTable)->addText("{$cnt->nama_dosen}", $fontStyle, 'pHead');
$table->addCell(4300, $styleTable)->addText("Hp ({$cnt->nomor_telp})", $fontStyle, 'pHead');
$no++;
}
$section->addText('', $fontStyle, 'pHead');
$table = $section->addTable();
$table->addRow();
$table->addCell(400, $styleTable)->addText("", $fontStyle, 'pHead');
$table->addCell(9000, $styleTable)->addText("Adapun nama-nama mahasiswa kami tersebut adalah :", $fontStyle, 'pHead');
//Nama Mahasiswa
$section->addText('', $fontStyle, 'pHead');
$table = $section->addTable();
$table->addRow();
$table->addCell(400, $styleTable)->addText("", $fontStyle, 'pHead');
$table->addCell(400, $styleTable_mhs)->addText("No. ", $fontStyle, 'pHead');
$table->addCell(2600, $styleTable_mhs)->addText("Nama", $fontStyle, 'pHead');
$table->addCell(2500, $styleTable_mhs)->addText("NPM", $fontStyle, 'pHead');
$table->addCell(2500, $styleTable_mhs)->addText("Jurusan", $fontStyle, 'pHead');
foreach ($mhs as $m) {
$table->addRow();
$table->addCell(400, $styleTable)->addText("", $fontStyle, 'pHead');
$table->addCell(400, $styleTable_mhs)->addText("{$no2}.", $fontStyle, 'pHead');
$table->addCell(2600, $styleTable_mhs)->addText("{$m->nama_mahasiswa}", $fontStyle, 'pHead');
$table->addCell(2500, $styleTable_mhs)->addText("{$m->npm}", $fontStyle, 'pHead');
$table->addCell(2500, $styleTable_mhs)->addText("{$m->nama_jurusan}", $fontStyle, 'pHead');
$no2++;
}
//Footer
$section->addText('', $fontStyle);
$table = $section->addTable();
$table->addRow();
$table->addCell(400)->addText("", $fontStyle);
$table->addCell(8600)->addText("Besar Harapan Kami kiranya Bapak/Ibu dapat menerima mahasiswa kami tersebut, selanjutnya kami sangat mengharapkan informasi berapa orang mahasiswa kami yang dapat diterima untuk melaksanakan PKL di instansi/perusahaan yang Bapak/Ibu pimpin.", $fontStyle);
$table->addRow();
$table->addCell(400)->addText("", $fontStyle);
$table->addCell(8600)->addText("Atas bantuan dan kerjasama yang baik dari Bapak/Ibu kami ucapkan terima kasih.", $fontStyle, 'pHead');
$section->addTitle('');
$section->addText("\tPekanbaru, " . tanggal(date('d-m-Y')), $fontStyle, 'pStyle_footer');
$section->addText("\tAn. Ketua, ", $fontStyle, 'pStyle_footer');
$section->addTitle('');
$section->addTitle('');
$section->addText("\t{$d->ketua_jurusan}", 2, 'pStyle_footer');
$section->addText("\tKetua Jurusan {$d->nama_jurusan}", $fontStyle, 'pStyle_footer');
$section->addText("Tembusan :", 'underline', 'pStyle_tbs');
$section->addText("1. Yth. Bapak Ketua STMIK-AMIK Riau", 'pStyle_tbs');
$section->addText("2. Yth. Ibu Pembantu Ketua I", 'pStyle_tbs');
$section->addText("3. Arsip", 'pStyle_tbs');
////open file////
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$filename = date('d-m-Y-Hms') . '-Permohonan_PKL.docx';
$objWriter->save($filename);
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $filename);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($filename));
flush();
readfile($filename);
unlink($filename);
// deletes the temporary file
exit;
}
////end of open file////
///save file////
//$document->save('assets/docs/'.$d->nama_kar.'-'.$d->id_pegawai.'.docx');
//redirect(base_url().'assets/docs/'.$d->nama_kar.'-'.$d->id_pegawai.'.docx', 'assets/manage_pegawai');
///end of save file////
}
示例13: reporte_final_to_word
//.........这里部分代码省略.........
}
}
$aux = implode(", ", $aux);
//PROCEDO A ESCRIBIR EL DOCUMENTO...
$section->addText(prepara_texto("REPORTE FINAL DE AJUSTE"), "titulo1", "parrafo1");
$section->addTextBreak(1);
$section->addText("DATOS GENERALES", "titulo2", "parrafo1");
$section->addTextBreak(1);
$section->addText("PARA USO EXCLUSIVO Y CONFIDENCIAL DE:", "titulo2", "parrafo2");
$section->addText(prepara_texto($inspeccion_inicial->uso_exclusivo), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText("REFERENCIA:", "titulo2", "parrafo2");
$section->addText(prepara_texto($reclamo->referencia), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText("ASEGURADO:", "titulo2", "parrafo2");
$section->addText(prepara_texto($reclamo->asegurado), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText("ASEGURADORA:", "titulo2", "parrafo2");
$section->addText(prepara_texto($this->indicadores_model->get_aseguradora($reclamo->id_aseguradora)->nombre), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText("CO - ASEGURADORAS:", "titulo2", "parrafo2");
$section->addText(prepara_texto($aux), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText(prepara_texto("ATENCIÓN A:"), "titulo2", "parrafo2");
$section->addText(prepara_texto($inspeccion_inicial->atencion_a), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText("CORREDOR DE SEGUROS:", "titulo2", "parrafo2");
$section->addText(prepara_texto($reclamo->corredor_seguros), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText(prepara_texto("NÚMERO DE POLIZA:"), "titulo2", "parrafo2");
$section->addText(prepara_texto($reclamo->numero_poliza), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText("VIGENCIA:", "titulo2", "parrafo2");
$section->addText(prepara_texto($inspeccion_inicial->vigencia), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText("RAMO:", "titulo2", "parrafo2");
$section->addText(prepara_texto($this->indicadores_model->get_ramo($reclamo->id_ramo)->nombre), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText("COBERTURA:", "titulo2", "parrafo2");
$section->addText(prepara_texto($this->indicadores_model->get_cobertura($reclamo->id_cobertura)->nombre), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText("CAUSA:", "titulo2", "parrafo2");
$section->addText(prepara_texto($this->indicadores_model->get_causa($inspeccion_inicial->id_causa)->nombre), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText("BIENES ASEGURADOS:", "titulo2", "parrafo2");
$section->addText(prepara_texto($inspeccion_inicial->bienes_asegurados), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText("SUMA ASEGURADA:", "titulo2", "parrafo2");
$section->addText(prepara_texto($inspeccion_inicial->suma_asegurada), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText("LIMITE DE RESPONSABILIDAD:", "titulo2", "parrafo2");
$section->addText(prepara_texto($inspeccion_inicial->limite_responsabilidad), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText("DEDUCIBLE:", "titulo2", "parrafo2");
$section->addText(prepara_texto($inspeccion_inicial->deducible), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText(prepara_texto("UBICACIÓN DEL SINIESTRO:"), "titulo2", "parrafo2");
$section->addText(prepara_texto($reclamo->ubicacion_siniestro), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText("FECHA DEL SINIESTRO:", "titulo2", "parrafo2");
$section->addText(prepara_texto($reclamo->fecha_siniestro), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText(prepara_texto("FECHA DE NOTIFICACIÓN - ASEGURADORA:"), "titulo2", "parrafo2");
$section->addText(prepara_texto($reclamo->fecha_notificacion_ase), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText(prepara_texto("NOTIFICACIÓN - AVINCO AJUSTES:"), "titulo2", "parrafo2");
$section->addText(prepara_texto($reclamo->fecha_notificacion), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText(prepara_texto("FECHA DE INSPECCIÓN:"), "titulo2", "parrafo2");
$section->addText(prepara_texto($inspeccion_inicial->fecha_inspeccion), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText("RESERVA INICIAL:", "titulo2", "parrafo2");
$section->addText(prepara_texto($inspeccion_inicial->reserva_inicial), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText("SUMA ASEGURADORA:", "titulo2", "parrafo2");
$section->addText(prepara_texto($inspeccion_inicial->suma_aseguradora), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText(prepara_texto("PÉRDIDA RECLAMADA:"), "titulo2", "parrafo2");
$section->addText(prepara_texto($reporte_final->perdida_reclamada), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText(prepara_texto("AJUSTES:"), "titulo2", "parrafo2");
$section->addText(prepara_texto($reporte_final->ajustes), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText(prepara_texto("INDEMNIZACIÓN RECOMENDADA:"), "titulo2", "parrafo2");
$section->addText(prepara_texto($reporte_final->indemnizacion_recomendada), "titulo3", "parrafo2");
$section->addTextBreak(1);
$section->addText("FECHA DE REPORTE:", "titulo2", "parrafo2");
$section->addText(prepara_texto($reporte_final->fecha_guardar_final), "titulo3", "parrafo2");
$section->addTextBreak(1);
$filename = 'reporte_final_de_ajuste.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($this->word, 'Word2007');
$objWriter->save('php://output');
}
示例14: downloadApprovalNotice
/**
* @return boolean
*/
function downloadApprovalNotice()
{
$phpword_object = new PHPWord();
$section = $phpword_object->createSection();
$header = $section->createHeader();
$footer = $section->createFooter();
// Replace the keys by the values of the proposal
$this->_replaceHTMLs($this->sectionEditorSubmission);
// Convert the HTML and put it into the PHPWord object
$headerDomArray = $this->_getHtmlDomArray($this->header);
$headerDomArray = $headerDomArray[0];
$bodyDomArray = $this->_getHtmlDomArray($this->body);
$bodyDomArray = $bodyDomArray[0];
$footerDomArray = $this->_getHtmlDomArray($this->footer);
$footerDomArray = $footerDomArray[0];
htmltodocx_insert_html($header, $headerDomArray->nodes, $this->_getSettings('header'));
htmltodocx_insert_html($section, $bodyDomArray->nodes, $this->_getSettings());
htmltodocx_insert_html($footer, $footerDomArray->nodes, $this->_getSettings('footer'));
// Always include the page number in the footer
$footer->addPreserveText(Locale::translate('submission.approvalNotice.pageNumberOfTotalPages.page') . ' {PAGE} ' . Locale::translate('submission.approvalNotice.pageNumberOfTotalPages.of') . ' {NUMPAGES}', null, array('size' => 6, 'align' => 'center'));
// Save File
$h2d_file_uri = tempnam('', 'htd');
$objWriter = PHPWord_IOFactory::createWriter($phpword_object, 'Word2007');
$objWriter->save($h2d_file_uri);
// Download the file:
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $this->fileName . '.docx');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($h2d_file_uri));
ob_clean();
flush();
$status = readfile($h2d_file_uri);
unlink($h2d_file_uri);
return true;
}
示例15: doDoc
function doDoc($title, $headertext, $footertext, $items)
{
// New Word Document
$PHPWord = new PHPWord();
// New portrait section
$section = $PHPWord->createSection();
// Add header
$header = $section->createHeader();
$table = $header->addTable();
$table->addRow();
$table->addCell(4500)->addText($headertext);
// Add footer
$footer = $section->createFooter();
//$footer->addPreserveText('Page {PAGE} of {NUMPAGES}.', array('align'=>'center'));
$footer->addPreserveText($footertext, array('align' => 'center'));
// Title styles
$PHPWord->addTitleStyle(1, array('size' => 20, 'color' => '333333', 'bold' => true));
$PHPWord->addTitleStyle(2, array('size' => 16, 'color' => '666666'));
$section->addTitle($title, 1);
foreach ($items as $item) {
$section->addTitle($item->title, 2);
$section->addTextBreak(1);
$section->addText($item->text);
$section->addTextBreak(1);
$section->addImage($item->filename);
$section->addTextBreak(1);
}
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
header('Content-Type: application/vnd.ms-word');
header('Content-Disposition: attachment;filename="' . $title . '.docx"');
header('Cache-Control: max-age=0');
// At least write the document to webspace:
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('php://output');
}