本文整理汇总了PHP中PHPWord_IOFactory类的典型用法代码示例。如果您正苦于以下问题:PHP PHPWord_IOFactory类的具体用法?PHP PHPWord_IOFactory怎么用?PHP PHPWord_IOFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PHPWord_IOFactory类的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: index
public function index()
{
$PHPWord = $this->word->create_word_object();
$section = $PHPWord->createSection();
$entries = $this->entries_model->get_entries();
$first_date = $entries[0]['datum'];
$start_week = date('W', strtotime($first_date));
$last_weekday = 1;
$day_string = '';
$chain_date = '';
$chain_string = '';
$pagebreak = 0;
for ($i = 0; $i < count($entries); $i++) {
// if ($i < (count($entries) - 1)) {
// if ($entries[$i]['datum'] == $entries[$i + 1]['datum']) {
// $day_string .= $entries[$i]['datum'] .' - '. $entries[$i]['titel'] .' - '. $entries[$i]['beschreibung'] .'; ';
// continue;
// }
// else {
// $day_string = '';
// }
// }
$current_week = date('W', strtotime($entries[$i]['datum']));
$year = date('Y', strtotime($entries[$i]['datum']));
$current_weekday = intval(date('w', strtotime($entries[$i]['datum'])));
// Wenn aktueller Wochentag kleiner als der Letzte ist -> neue Woche
if ($current_weekday < $last_weekday) {
$last_week = date('W', strtotime($entries[$i - 1]['datum']));
$first_day_of_last_week = date('d.m.Y', strtotime($year . 'W' . $last_week . '1'));
$last_day_of_last_week = date('d.m.Y', strtotime($year . 'W' . $last_week . '5'));
$table = $section->addTable();
//Kopfzeile
$table->addRow();
$table->addCell(10)->addText('Vom ' . $first_day_of_last_week . ' bis ' . $last_day_of_last_week);
$table->addCell(10)->addText('DummyText');
//Beschreibungszeile
$table->addRow();
$table->addCell(20)->addText($day_string);
$section->addTextBreak();
if ($pagebreak == 1) {
$section->addPageBreak();
$pagebreak = 0;
} else {
$pagebreak++;
}
// echo '<table border="1">';
// echo '<tr><td>'. $first_day_of_last_week .' bis '. $last_day_of_last_week .'</td><td>Dummy Text</td></tr>';
// echo '<tr><td colspan="2">'. $day_string .'</td></tr>';
// echo '</table><br/><br/>';
$day_string = '';
} else {
if (count($entries[$i]) > 0) {
if ($entries[$i]['datum'] != $entries[$i + 1]['datum']) {
if ($chain_date != '' and $chain_string != '') {
$day_string .= $chain_date . $chain_string;
$day_string .= $entries[$i]['titel'] . ' - ' . utf8_decode($entries[$i]['beschreibung']);
$chain_date = '';
$chain_string = '';
} else {
$day_string .= date('d.m.Y', strtotime($entries[$i]['datum'])) . ': ' . $entries[$i]['titel'] . ' - ' . utf8_decode($entries[$i]['beschreibung']);
}
} else {
$chain_date = date('d.m.Y', strtotime($entries[$i]['datum'])) . ': ';
$chain_string .= $entries[$i]['titel'] . ' - ' . utf8_decode($entries[$i]['beschreibung']) . '; ';
}
}
}
$last_weekday = intval(date('w', strtotime($entries[$i]['datum'])));
}
// Save File
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('BasicTable.docx');
// for ($i = 0; $i < 3; $i++) {
// print_r($entries[$i]);
// }
}
示例14: _save
/**
*
*/
protected function _save()
{
$objWriter = PHPWord_IOFactory::createWriter($this->_word, 'Word2007');
$objWriter->save($this->_fileName);
}
示例15: generate
public function generate($id = 0)
{
$this->load->library('PHPWord');
$this->load->helper('util');
$date = date('Y-m-d_H-i-s');
//if ($id==0);
$conf = $this->db->get($this->cms_complete_table_name('konfigurasi'))->result();
$data = $this->db->where('id_ket_lulusan', $id)->get($this->cms_complete_table_name('ket_lulusan'))->result();
$ket = $this->db->where('fk_id_ket_lulusan', $id)->get($this->cms_complete_table_name('keterangan_lulusan'))->result();
$PHPWord = new PHPWord();
// New portrait section
$section = $PHPWord->createSection(array('pageSizeH' => 20500));
// Define the TOC font style
// Add title styles
$PHPWord->addFontStyle(1, array('size' => 16, 'color' => '000', 'underline' => PHPWord_Style_Font::UNDERLINE_SINGLE));
$PHPWord->addFontStyle(2, array('size' => 12, 'color' => '000', 'bold' => true));
$PHPWord->addParagraphStyle('pStyle', array('align' => 'center', 'spaceAfter' => 10));
$PHPWord->addParagraphStyle('pStyle_footer', array('tabs' => array(new PHPWord_Style_Tab('left', 6000)), 'align' => 'center', 'spaceAfter' => 10));
$PHPWord->addParagraphStyle('pStyle_tbs', array('size' => 11, 'align' => 'left', 'spaceAfter' => 10));
$fontStyle = array('spaceAfter' => 60, 'size' => 12);
//Generate Document
foreach ($data as $d) {
$section->addTitle('');
$section->addTitle('');
$section->addTitle('');
$section->addText('SURAT KETERANGAN LULUSAN', 1, 'pStyle');
$section->addText('No.' . $d->nomor_surat . '/B-01/STMIK-AMIK/' . $d->bulan . '/' . $d->tahun, $fontStyle, 'pStyle');
$section->addTitle('');
$section->addTitle('');
$section->addText('Yang bertanda tangan dibawah ini :', $fontStyle);
//Table
foreach ($conf as $c) {
$table = $section->addTable();
$table->addRow();
$table->addCell(500)->addText("");
$table->addCell(1750)->addText("Nama", $fontStyle);
$table->addCell(3750)->addText(": " . $c->nama_puket, $fontStyle);
$table->addRow();
$table->addCell(500)->addText("");
$table->addCell(1750)->addText("Pangkat/Gol", $fontStyle);
$table->addCell(3750)->addText(": " . $c->pangkat_puket, $fontStyle);
$table->addRow();
$table->addCell(500)->addText("");
$table->addCell(1750)->addText("Jabatan", $fontStyle);
$table->addCell(3750)->addText(": Pembantu Ketua I. Bid. Akademis", $fontStyle);
}
//End OfTable
$section->addText('Menerangkan bahwa :', $fontStyle);
//Table
$table = $section->addTable();
$table->addRow();
$table->addCell(500)->addText("");
$table->addCell(1750)->addText("Nama", $fontStyle);
$table->addCell(3750)->addText(": " . $d->nama_mahasiswa, $fontStyle);
$table->addRow();
$table->addCell(500)->addText("");
$table->addCell(1750)->addText("NPM", $fontStyle);
$table->addCell(3750)->addText(": " . $d->npm, $fontStyle);
$table->addRow();
$table->addCell(500)->addText("");
$table->addCell(1750)->addText("Tempat/Tgl Lahir", $fontStyle);
$table->addCell(3750)->addText(": " . $d->tempat_lahir . ", " . tanggal(date($d->tanggal_lahir)), $fontStyle);
//End OfTable
$section->addText('Adalah benar mahasiswa Sekolah Tinggi Manajemen Informatika & Komputer AMIK Riau (STMIK-AMIK) Riau yang telah :', $fontStyle);
$section->addText("");
foreach ($ket as $k) {
$section->addListItem($k->keterangan, 0, $fontStyle);
}
//End OfTable
foreach ($conf as $c) {
$section->addText('Demikian surat keterangan kelulusan ini dikeluarkan untuk dapat dipergunakan sebagaimana mestinya.', $fontStyle);
$section->addTitle('');
$section->addText("\tPekanbaru, " . tanggal(date('d-m-Y')), $fontStyle, 'pStyle_footer');
$section->addTitle('');
$section->addTitle('');
$section->addTitle('');
$section->addText("\t{$c->nama_puket}", 2, 'pStyle_footer');
$section->addText("\tPuket I Bid. Akademis", $fontStyle, 'pStyle_footer');
$section->addTitle('');
$section->addTitle('');
$section->addText("Tembusan disampaikan kepada Yth :", 'pStyle_tbs');
$section->addText("1. Ketua STMIK-AMIK Riau", 'pStyle_tbs');
$section->addText("2. Arsip ……", 'pStyle_tbs');
}
////open file////
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$filename = $d->npm . '-Ket_Lulusan.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
//.........这里部分代码省略.........