function exportWord($text, $font, $size, $bold) { $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); // // $section->addText($text); // // $section->addText('Hello world! I am formatted.', // array('name'=>'Tahoma', 'size'=>16, 'bold'=>true)); // $phpWord->addFontStyle('myOwnStyle', // array('name'=>'Verdana', 'size'=>14, 'color'=>'1B2232')); // $section->addText('Hello world! I am formatted by a user defined style', // 'myOwnStyle'); $fontStyle = new \PhpOffice\PhpWord\Style\Font(); $fontStyle->setBold($bold); $fontStyle->setName($font); $fontStyle->setSize($size); $myTextElement = $section->addText($text); $myTextElement->setFontStyle($fontStyle); $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); $objWriter->save('helloWorld.docx'); }
public function vytvorZiadostHlasovaniePostouNonSR($obec, $n2k) { $phpWord = new \PhpOffice\PhpWord\PhpWord(); /* Note: any element you append to a document must reside inside of a Section. */ $phpWord->addParagraphStyle('pStylel', array('spacing' => 5)); $phpWord->addParagraphStyle('pStylec', array('spacing' => 5, 'align' => 'center')); $phpWord->addParagraphStyle('pStyler', array('spacing' => 5, 'align' => 'right')); $section = $phpWord->addSection(); $textrun = $section->addTextRun('pStyler'); $textrun->addText(htmlspecialchars("ŽIADOSŤ VYPLŇTE VEĽKÝMI PÍSMENAMI."), array('bold' => true)); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun = $section->addTextRun('pStylec'); $textrun->addText(htmlspecialchars("Žiadosť\to voľbu poštou"), array("size" => "14")); $textrun->addTextBreak(); $textrun->addText(htmlspecialchars("pre voľby do Národnej rady Slovenskej republiky v roku 2016"), array("size" => "14")); $textrun = $section->addTextRun('pStylel'); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $this->spracujAdresuPrijemcu($textrun, $obec, $n2k); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addText(htmlspecialchars("Podľa § 59 ods. 1 zákona č. 180/2014 Z. z. o podmienkach výkonu volebného práva a o zmene a doplnení niektorých zákonov žiadam o voľbu poštou pre voľby do Národnej rady Slovenskej republiky v roku 2016 a o zaslanie hlasovacích lístkov a obálok na adresu:")); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addText(htmlspecialchars("Meno:\t\t\t\t")); $textrun->addText(htmlspecialchars("MENO"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW)); $textrun->addTextBreak(); $textrun->addText(htmlspecialchars("Priezvisko:\t\t\t")); $textrun->addText(htmlspecialchars("PRIEZVISKO"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW)); $textrun->addTextBreak(); $textrun->addText(htmlspecialchars("Rodné priezvisko:\t\t")); $textrun->addText(htmlspecialchars("RODNÉ PRIEZVISKO"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW)); $textrun->addTextBreak(); $textrun->addText(htmlspecialchars("Rodné číslo:\t\t\t")); $textrun->addText(htmlspecialchars("RODNÉ ČÍSLO"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW)); $textrun->addTextBreak(); $textrun->addText(htmlspecialchars("Ulica:\t\t\t\t")); $textrun->addText(htmlspecialchars("ULICA"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW)); $textrun->addTextBreak(); $textrun->addText(htmlspecialchars("Číslo domu:\t\t\t")); $textrun->addText(htmlspecialchars("ČÍSLO DOMU"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW)); $textrun->addTextBreak(); $textrun->addText(htmlspecialchars("Obec:\t\t\t\t")); $textrun->addText(htmlspecialchars("OBEC"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW)); $textrun->addTextBreak(); $textrun->addText(htmlspecialchars("PSČ:\t\t\t\t")); $textrun->addText(htmlspecialchars("PSČ"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW)); $textrun->addTextBreak(); $textrun->addText(htmlspecialchars("Štát:\t\t\t\t")); $textrun->addText(htmlspecialchars("ŠTÁT"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW)); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addText(htmlspecialchars("Prílohy:")); $textrun->addTextBreak(); $textrun->addText(htmlspecialchars("- čestné vyhlásenie voliča, že nemá trvalý pobyt na území Slovenskej republiky.")); $textrun->addTextBreak(); $textrun->addText(htmlspecialchars("- fotokópia časti cestovného dokladu Slovenskej republiky s osobnými údajmi voliča alebo fotokópia osvedčenia o štátnom občianstve Slovenskej republiky voliča.")); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addText(htmlspecialchars("V ")); $textrun->addText(htmlspecialchars("MIESTO KDE SA NACHÁDZATE"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW)); $textrun->addText(htmlspecialchars(", dňa ")); $textrun->addText(htmlspecialchars("DNEŠNÝ DÁTUM"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW)); $textrun->addTextBreak(); $textrun = $section->addTextRun('pStyler'); $textrun->addText(htmlspecialchars("MENO ALEBO PODPIS"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW)); $section = $phpWord->addSection(); $textrun = $section->addTextRun('pStylec'); $textrun->addText(htmlspecialchars("meno, priezvisko, rodné číslo alebo dátum narodenia, adresa trvalého pobytu v cudzine"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW)); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addText(htmlspecialchars("ČESTNÉ VYHLÁSENIE"), array('size' => 20)); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addText(htmlspecialchars("Na účely voľby poštou do Národnej rady Slovenskej republiky v roku 2016"), array('size' => 12)); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addText(htmlspecialchars("čestne vyhlasujem,"), array('size' => 12, 'bold' => true)); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addText(htmlspecialchars("že nemám trvalý pobyt na území Slovenskej republiky."), array('size' => 12)); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun->addTextBreak(); $textrun = $section->addTextRun('pStylel'); $textrun->addText(htmlspecialchars("V ")); $textrun->addText(htmlspecialchars("MIESTO KDE SA NACHÁDZATE"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW)); $textrun->addText(htmlspecialchars(", dňa ")); $textrun->addText(htmlspecialchars("DNEŠNÝ DÁTUM"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW)); $textrun->addTextBreak(); $textrun = $section->addTextRun('pStyler'); $textrun->addText(htmlspecialchars("MENO ALEBO PODPIS"), array('bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW)); $section = $phpWord->addSection(); $textrun = $section->addTextRun('pStylec'); $textrun->addText(htmlspecialchars("fotokópia časti cestovného dokladu Slovenskej republiky s osobnými údajmi voliča alebo fotokópia osvedčenia o štátnom občianstve Slovenskej republiky voliča"), array('size' => '30', 'bgColor' => \PhpOffice\PhpWord\Style\Font::FGCOLOR_YELLOW)); return $phpWord; }
/** * Test write styles */ public function testFontRTL() { $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); $textrun = $section->addTextRun(); $textrun->addText(htmlspecialchars('سلام این یک پاراگراف راست به چپ است', ENT_COMPAT, 'UTF-8'), array('rtl' => true)); $doc = TestHelperDOCX::getDocument($phpWord, 'Word2007'); $file = 'word/document.xml'; $path = '/w:document/w:body/w:p/w:r/w:rPr/w:rtl'; $this->assertTrue($doc->elementExists($path, $file)); }
/** * @param array $pages * @param string $fileName * @param array|int $format */ public static function html2doc($pages, $fileName, $format = array()) { if (is_array($format)) { // PDF Page Format parameters passed in - merge with defaults $format += CRM_Core_BAO_PdfFormat::getDefaultValues(); } else { // PDF Page Format ID passed in $format = CRM_Core_BAO_PdfFormat::getById($format); } $paperSize = CRM_Core_BAO_PaperSize::getByName($format['paper_size']); $metric = CRM_Core_BAO_PdfFormat::getValue('metric', $format); $pageStyle = array('orientation' => CRM_Core_BAO_PdfFormat::getValue('orientation', $format), 'pageSizeW' => self::toTwip($paperSize['width'], $paperSize['metric']), 'pageSizeH' => self::toTwip($paperSize['height'], $paperSize['metric']), 'marginTop' => self::toTwip(CRM_Core_BAO_PdfFormat::getValue('margin_top', $format), $metric), 'marginRight' => self::toTwip(CRM_Core_BAO_PdfFormat::getValue('margin_right', $format), $metric), 'marginBottom' => self::toTwip(CRM_Core_BAO_PdfFormat::getValue('margin_bottom', $format), $metric), 'marginLeft' => self::toTwip(CRM_Core_BAO_PdfFormat::getValue('margin_left', $format), $metric)); $ext = pathinfo($fileName, PATHINFO_EXTENSION); $phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord->getDocInfo()->setCreator(CRM_Core_DAO::getFieldValue('CRM_Contact_BAO_Contact', CRM_Core_Session::getLoggedInContactID(), 'display_name')); foreach ((array) $pages as $page => $html) { $section = $phpWord->addSection($pageStyle + array('breakType' => 'nextPage')); \PhpOffice\PhpWord\Shared\Html::addHtml($section, $html); } self::printDoc($phpWord, $ext, $fileName); }
function make_word_doc($doc, $dir) { /** * uses the $doc object to create a new word doc whose name is sent back to hte client where an <iframe> downloads it * * @since 1.0 * * @caller user action * @ingroup editor * * @param object $doc created in js - a big object w all the info needed * @param string $dir the directory name to add the .doc * @return echos the word doc's name */ // make the a new instance of a phpword // you will add all the info to this $phpWord = new \PhpOffice\PhpWord\PhpWord(); $i = 0; $l = count($doc) - 1; // loop through each page in the doc // each page is a 'section' for ($i; $i < $l; $i = $i + 1) { $Paragraphs = $doc['Page' . $i]; $ii = 0; $ll = count($Paragraphs) - 1; ${"page_" . $i} = $phpWord->addSection(); $Page = ${"page_" . $i}; // in each page loop through each paragraph // style the the paragraph's alignment for ($ii; $ii < $ll; $ii = $ii + 1) { $Spans = $Paragraphs['Paragraph' . $ii]; $iii = 0; $lll = count($Spans) - 1; ${"paragraph_" . $i . '_' . $ii} = $Page->addTextRun(array('align' => $Spans['align'])); $Paragraph = ${"paragraph_" . $i . '_' . $ii}; // loop through each text span for ($iii; $iii < $lll; $iii = $iii + 1) { $Span = $Spans['Span' . $iii]; // create the style info for the text span $Style = array('name' => $Span['Styles']['name'], 'size' => intval($Span['Styles']['size']), 'bold' => filter_var($Span['Styles']['bold'], FILTER_VALIDATE_BOOLEAN), 'italic' => filter_var($Span['Styles']['italic'], FILTER_VALIDATE_BOOLEAN), 'color' => $Span['Styles']['color'], 'fgColor' => $Span['Styles']['fgColor']); // add the text span with it's style to the paragraph $Paragraph->addText($Span['text'], $Style); } } } // assign it as a word doc $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); // create an empty word doc file w. the new file name $pathAndFile = $dir . '/' . $doc['title'] . '.docx'; // save the file with content included $objWriter->save($pathAndFile); // return the .doc's title so it can be downloaded echo $doc['title'] . '.docx'; die; }
} elseif ($exchangeId) { $identifier = $exchangeId; } if ($institution) { $invoiceArr = $loanManager->getToAddress($institution); } else { $invoiceArr = $loanManager->getInvoiceInfo($identifier, $loanType); } $addressArr = $loanManager->getFromAddress($collId); if ($export) { $phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord->addParagraphStyle('acctnum', array('align' => 'left', 'indent' => 5.5, 'lineHeight' => 1.0, 'spaceAfter' => 0, 'keepNext' => true, 'keepLines' => true)); $phpWord->addFontStyle('acctnumFont', array('size' => 8, 'name' => 'Arial')); $phpWord->addParagraphStyle('toAddress', array('align' => 'left', 'indent' => 6, 'lineHeight' => 1.0, 'spaceAfter' => 0, 'keepNext' => true, 'keepLines' => true)); $phpWord->addFontStyle('toAddressFont', array('size' => 12, 'name' => 'Arial')); $section = $phpWord->addSection(array('pageSizeW' => 13662.992125984, 'pageSizeH' => 5952.755905512, 'marginLeft' => 360, 'marginRight' => 360, 'marginTop' => 360, 'marginBottom' => 360, 'headerHeight' => 0, 'footerHeight' => 0)); $section->addTextBreak(5); if ($accountNum) { $section->addText(htmlspecialchars('Acct. #' . $accountNum), 'acctnumFont', 'acctnum'); } $section->addTextBreak(1); $textrun = $section->addTextRun('toAddress'); $textrun->addText(htmlspecialchars($invoiceArr['contact']), 'toAddressFont'); $textrun->addTextBreak(1); $textrun->addText(htmlspecialchars($invoiceArr['institutionname'] . ' (' . $invoiceArr['institutioncode'] . ')'), 'toAddressFont'); $textrun->addTextBreak(1); if ($invoiceArr['institutionname2']) { $textrun->addText(htmlspecialchars($invoiceArr['institutionname2']), 'toAddressFont'); $textrun->addTextBreak(1); } if ($invoiceArr['address1']) {
function ciniki_conferences_conferenceScheduleDownload($ciniki) { // // Find all the required and optional arguments // ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'prepareArgs'); $rc = ciniki_core_prepareArgs($ciniki, 'no', array('business_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Business'), 'conference_id' => array('required' => 'yes', 'blank' => 'no', 'name' => 'Conference'))); if ($rc['stat'] != 'ok') { return $rc; } $args = $rc['args']; // // Make sure this module is activated, and // check permission to run this function for this business // ciniki_core_loadMethod($ciniki, 'ciniki', 'conferences', 'private', 'checkAccess'); $rc = ciniki_conferences_checkAccess($ciniki, $args['business_id'], 'ciniki.conferences.conferenceScheduleDownload'); if ($rc['stat'] != 'ok') { return $rc; } ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQuery'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryArrayTree'); ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryIDTree'); // // Load business settings // ciniki_core_loadMethod($ciniki, 'ciniki', 'businesses', 'private', 'intlSettings'); $rc = ciniki_businesses_intlSettings($ciniki, $args['business_id']); if ($rc['stat'] != 'ok') { return $rc; } $intl_timezone = $rc['settings']['intl-default-timezone']; $intl_currency_fmt = numfmt_create($rc['settings']['intl-default-locale'], NumberFormatter::CURRENCY); $intl_currency = $rc['settings']['intl-default-currency']; ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'dateFormat'); ciniki_core_loadMethod($ciniki, 'ciniki', 'users', 'private', 'timeFormat'); $date_format = ciniki_users_dateFormat($ciniki, 'php'); $time_format = ciniki_users_timeFormat($ciniki, 'php'); $mysql_date_format = ciniki_users_dateFormat($ciniki, 'mysql'); // // Load conference maps // ciniki_core_loadMethod($ciniki, 'ciniki', 'conferences', 'private', 'maps'); $rc = ciniki_conferences_maps($ciniki); if ($rc['stat'] != 'ok') { return $rc; } $maps = $rc['maps']; $strsql = "SELECT ciniki_conferences.id, " . "ciniki_conferences.name, " . "ciniki_conferences.permalink, " . "ciniki_conferences.status, " . "ciniki_conferences.status AS status_text, " . "ciniki_conferences.flags, " . "DATE_FORMAT(ciniki_conferences.start_date, '" . ciniki_core_dbQuote($ciniki, $mysql_date_format) . "') AS start_date, " . "DATE_FORMAT(ciniki_conferences.end_date, '" . ciniki_core_dbQuote($ciniki, $mysql_date_format) . "') AS end_date, " . "ciniki_conferences.synopsis, " . "ciniki_conferences.description, " . "ciniki_conferences.imap_mailbox, " . "ciniki_conferences.imap_username, " . "ciniki_conferences.imap_password, " . "ciniki_conferences.imap_subject " . "FROM ciniki_conferences " . "WHERE ciniki_conferences.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences.id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . ""; $rc = ciniki_core_dbHashQuery($ciniki, $strsql, 'ciniki.conferences', 'conference'); if ($rc['stat'] != 'ok') { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3631', 'msg' => 'Conference not found', 'err' => $rc['err'])); } if (!isset($rc['conference'])) { return array('stat' => 'fail', 'err' => array('pkg' => 'ciniki', 'code' => '3632', 'msg' => 'Unable to find Conference')); } $conference = $rc['conference']; if (isset($maps['conference']['status'][$conference['status_text']])) { $conference['status_text'] = $maps['conference']['status'][$conference['status_text']]; } $strsql = "SELECT ciniki_conferences_sessions.id, " . "CONCAT_WS('-', ciniki_conferences_sessions.id, ciniki_conferences_presentations.id) AS rowid, " . "ciniki_conferences_sessions.conference_id, " . "ciniki_conferences_sessions.room_id, " . "ciniki_conferences_rooms.name AS room, " . "ciniki_conferences_rooms.sequence, " . "ciniki_conferences_sessions.name, " . "ciniki_conferences_sessions.session_start AS start_time, " . "ciniki_conferences_sessions.session_start AS start_date, " . "ciniki_conferences_sessions.session_end AS end_time, " . "IFNULL(ciniki_conferences_presentations.id, 0) AS presentation_id, " . "IFNULL(ciniki_conferences_presentations.customer_id, 0) AS customer_id, " . "IFNULL(ciniki_conferences_presentations.presentation_number, '') AS presentation_number, " . "IFNULL(ciniki_conferences_presentations.title, '') AS presentation_title, " . "IFNULL(ciniki_conferences_presentations.description, '') AS presentation_description, " . "IFNULL(ciniki_customers.display_name, '') AS display_name, " . "IFNULL(ciniki_conferences_presentations.status, 0) AS status, " . "IFNULL(ciniki_conferences_presentations.status, '') AS status_text, " . "IFNULL(ciniki_conferences_attendees.status, 0) AS registration, " . "IFNULL(ciniki_conferences_attendees.status, 0) AS registration_text " . "FROM ciniki_conferences_sessions " . "INNER JOIN ciniki_conferences_rooms ON (" . "ciniki_conferences_sessions.room_id = ciniki_conferences_rooms.id " . "AND ciniki_conferences_rooms.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "LEFT JOIN ciniki_conferences_presentations ON (" . "ciniki_conferences_sessions.id = ciniki_conferences_presentations.session_id " . "AND ciniki_conferences_presentations.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "LEFT JOIN ciniki_conferences_attendees ON (" . "ciniki_conferences_presentations.customer_id = ciniki_conferences_attendees.customer_id " . "AND ciniki_conferences_presentations.conference_id = ciniki_conferences_attendees.conference_id " . "AND ciniki_conferences_attendees.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "LEFT JOIN ciniki_customers ON (" . "ciniki_conferences_presentations.customer_id = ciniki_customers.id " . "AND ciniki_customers.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . ") " . "WHERE ciniki_conferences_sessions.business_id = '" . ciniki_core_dbQuote($ciniki, $args['business_id']) . "' " . "AND ciniki_conferences_sessions.conference_id = '" . ciniki_core_dbQuote($ciniki, $args['conference_id']) . "' " . "ORDER BY ciniki_conferences_sessions.session_start, " . "ciniki_conferences_rooms.name, " . "ciniki_conferences_rooms.sequence, " . "ciniki_conferences_presentations.title " . ""; ciniki_core_loadMethod($ciniki, 'ciniki', 'core', 'private', 'dbHashQueryArrayTree'); $rc = ciniki_core_dbHashQueryArrayTree($ciniki, $strsql, 'ciniki.conferences', array(array('container' => 'times', 'fname' => 'start_time', 'fields' => array('start_time', 'start_date', 'end_time'), 'utctotz' => array('start_time' => array('format' => $time_format, 'timezone' => $intl_timezone), 'start_date' => array('format' => $date_format, 'timezone' => $intl_timezone), 'end_time' => array('format' => $time_format, 'timezone' => $intl_timezone))), array('container' => 'rooms', 'fname' => 'room_id', 'fields' => array('id' => 'room_id', 'name' => 'room', 'session_name' => 'name', 'presentation_id')), array('container' => 'presentations', 'fname' => 'presentation_id', 'fields' => array('id', 'conference_id', 'room_id', 'room', 'sequence', 'name', 'start_time', 'start_date', 'end_time', 'presentation_id', 'customer_id', 'presentation_number', 'presentation_title', 'presentation_description', 'display_name', 'status', 'status_text', 'registration', 'registration_text'), 'utctotz' => array('start_time' => array('format' => $time_format, 'timezone' => $intl_timezone), 'start_date' => array('format' => $date_format, 'timezone' => $intl_timezone), 'end_time' => array('format' => $time_format, 'timezone' => $intl_timezone)), 'maps' => array('status_text' => $maps['presentation']['status'], 'registration_text' => $maps['attendee']['status'])))); if ($rc['stat'] != 'ok') { return $rc; } if (isset($rc['times'])) { $timeslots = $rc['times']; } else { $timeslots = array(); } // // Generate the word file // require_once $ciniki['config']['core']['lib_dir'] . '/PHPWord/src/PhpWord/Autoloader.php'; \PhpOffice\PhpWord\Autoloader::register(); require $ciniki['config']['core']['lib_dir'] . '/PHPWord/src/PhpWord/PhpWord.php'; $PHPWord = new \PhpOffice\PhpWord\PhpWord(); $PHPWord->addTitleStyle(1, array('bold' => true, 'size' => 18), array('spaceBefore' => 240, 'spaceAfter' => 120)); $PHPWord->addTitleStyle(2, array('bold' => true, 'size' => 16), array('spaceBefore' => 120, 'spaceAfter' => 120)); $PHPWord->addTitleStyle(3, array('bold' => false, 'size' => 14), array('spaceBefore' => 120, 'spaceAfter' => 120)); $style_table = array('cellMargin' => 80, 'borderColor' => 'aaaaaa', 'borderSize' => 6); $style_header = array('borderSize' => 6, 'borderColor' => 'aaaaaa', 'bgColor' => 'dddddd', 'valign' => 'center'); $style_cell = array('borderSize' => 6, 'borderColor' => 'aaaaaa', 'valign' => 'center', 'bgcolor' => 'ffffff'); $style_header_font = array('bold' => true, 'spaceAfter' => 20); $style_cell_font = array(); $style_header_pleft = array('align' => 'left'); $style_header_pright = array('align' => 'right'); $style_cell_pleft = array('align' => 'left'); $style_cell_pright = array('align' => 'right'); $section = $PHPWord->addSection(); $header = $section->addHeader(); $table = $header->addTable(); $table->addRow(); $cell = $table->addCell(9600); $cell->addText($conference['name'], array('size' => '16'), array('align' => 'center')); //print "<pre>" . print_r($timeslots, true) . "</pre>"; //exit; // // Create a table with a row for each time slot // $cur_date = ''; $table = $section->addTable($style_table); $session_number = 1; foreach ($timeslots as $timeslot) { // // Add the date as a header // if ($timeslot['start_date'] != $cur_date) { $table->addRow(); $cell = $table->addCell(1500, $style_cell); $cell->addText($timeslot['start_date']); $cell->setGridSpan(2); $cur_date = $timeslot['start_date']; // $session_number = 1; } // // Add the time slot // $table->addRow(); $cell = $table->addCell(1500, $style_cell); $cell->addText($timeslot['start_time'] . ' - ' . $timeslot['end_time'], $style_cell_font); $nonsession_info = array(); $session_info = array(); if (isset($timeslot['rooms']) && count($timeslot['rooms']) > 0) { foreach ($timeslot['rooms'] as $room) { if (!isset($room['presentations']) || $room['presentation_id'] == 0) { if (isset($room['presentations'][0])) { $session = $room['presentations'][0]; if ($session['name'] != '') { $nonsession_info[] = $session['name']; } } $nonsession_info[] = "Location: " . $room['name']; } else { $session_info[] = $session_number . ". " . $room['session_name'] . ": "; $presentation_number = 1; $presentation_info = ''; foreach ($room['presentations'] as $presentation) { if ($presentation_number > 1) { $presentation_info .= "; "; } $presentation_info .= $presentation_number . ") " . $presentation['display_name']; $presentation_number++; } $session_info[] = $presentation_info; $session_info[] = "Location: " . $room['name']; $session_info[] = ""; $session_number++; } } } $cell = $table->addCell(2500, $style_cell); foreach ($nonsession_info as $line) { $cell->addText($line, $style_cell_font); } $cell = $table->addCell(5500, $style_cell); foreach ($session_info as $line) { $cell->addText($line, $style_cell_font); } } $section = $PHPWord->addSection(); $header = $section->addHeader(); $table = $header->addTable(); $table->addRow(); $cell = $table->addCell(9600); $cell->addText($conference['name'], array('size' => '16'), array('align' => 'center')); $session_number = 1; foreach ($timeslots as $timeslot) { if (isset($timeslot['rooms']) && count($timeslot['rooms']) > 0) { foreach ($timeslot['rooms'] as $room) { if (!isset($room['presentations']) || $room['presentation_id'] == 0) { continue; } $section->addTitle($session_number . ". " . $room['session_name'], 1); if (isset($room['presentations']) && $room['presentation_id'] != 0) { foreach ($room['presentations'] as $pid => $presentation) { $section->addTitle($presentation['display_name'], 2); $section->addTitle(htmlspecialchars($presentation['presentation_title']), 3); $lines = explode("\n", $presentation['presentation_description']); foreach ($lines as $line) { $section->addText(htmlspecialchars($line), array()); } $section->addText(''); } } $session_number++; } } } // // Output the word file // header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document'); header('Content-Disposition: attachment;filename="' . preg_replace("/[^A-Za-z0-9]/", '', $conference['name']) . '.docx"'); header('Cache-Control: max-age=0'); $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($PHPWord, 'Word2007'); $objWriter->save('php://output'); return array('stat' => 'exit'); }
$code_programme = $info_plancadre["CodeProgramme"]; $programme_cours = $nom_programme . "(" . $code_programme . ")"; $ponderation_cours = "Pondération : " . $info_plancadre["Ponderation"]; $nombre_unites_cours = "Nombre d'unité(s) : " . $info_plancadre["NombreUnites"]; $prealable_cours = "Préalable(s) : " . "Aucun"; $type_enseignement = $info_plancadre['TypeCours']; $php_word = new \PhpOffice\PhpWord\PhpWord(); // ---------------------------------------------- // ajout des styles au document $php_word->addParagraphStyle("style_align_right", $GLOBALS["style_align_right"]); $php_word->addParagraphStyle("style_align_center", $GLOBALS["style_align_center"]); $php_word->addTableStyle('style_table', $GLOBALS["style_table"]); // ---------------------------------------------- // ---------------------------------------------- // Section de l'indentification du cours $section_template = $php_word->addSection(); // $nom_etablissement = "Collège Lionel-Groulx"; $section_template->addText($nom_etablissement); $section_template->addText($type_enseignement, null, "style_align_right"); $section_template->addText($programme_cours, null, "style_align_right"); switch ($info_plancadre["Etat"]) { case 'Adopté': if ($info_plancadre["Officiel"] > 0) { $titre_document = "Plan-cadre officiel"; } else { $titre_document = "Plan-cadre en archive"; } break; case 'Validé': case 'Élaboration':
$atData = $this->atData; $atTar = $this->atTar; require_once 'libraries/PHPWord-master/src/PhpWord/Autoloader.php'; \PhpOffice\PhpWord\Autoloader::register(); $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Baslik Style $phpWord->addFontStyle('rBasStyle', array('bold' => true, 'name' => 'Times New Roman', 'size' => 12)); $phpWord->addParagraphStyle('pBasStyle', array('align' => 'center', 'spaceAfter' => 100)); //İçerik Style $phpWord->addFontStyle('rIcStyle', array('name' => 'Times New Roman', 'size' => 12)); $phpWord->addParagraphStyle('pIcStyle', array('align' => 'center', 'spaceAfter' => 100)); //İçerikBas Style $phpWord->addFontStyle('rIcBasStyle', array('name' => 'Times New Roman', 'size' => 12, 'bold' => true)); $phpWord->addParagraphStyle('pIcStyle', array('align' => 'center', 'spaceAfter' => 100)); // New portrait section $section = $phpWord->addSection(array('orientation' => 'portrait')); $section->addText('EK-8', 'rBasStyle', array('align' => 'right')); $section->addText('Avrupa Topluluğu (AT) Yüklenicileri Tarafından 2.000 TL’nin Üstünde Yapılan Alımlara İlişkin Üçer Aylık Bildirim Tablosu', 'rBasStyle', array('align' => 'center')); $section->addText('(KDV İstisna Sertifikası alınan vergi idaresine gönderilecektir)', 'rIcStyle', array('align' => 'center')); $section->addTextBreak(1); $styleTable = array('borderSize' => 6, 'borderColor' => '000000', 'cellMarginLeft' => 20); $styleFirstRow = array('borderBottomSize' => 6, 'borderBottomColor' => '000000'); $styleCell = array('borderRightColor' => '000000', 'borderRightSize' => 6, 'valign' => 'center'); $fontStyleBold = array('bold' => true, 'name' => 'Times New Roman', 'size' => 12); $fontStyle = array('name' => 'Times New Roman', 'size' => 12); $phpWord->addTableStyle('Fancy Table', $styleTable, $styleFirstRow); $table = $section->addTable('Fancy Table'); $table->addRow(); $table->addCell(1500, $styleCell)->addText('Dönem', $fontStyleBold, array('spaceBefore' => 10, 'spaceAfter' => 10)); $table->addCell(8500, $styleCell)->addText($atTar['sBas'] . ' - ' . $atTar['sBit'], $fontStyle, array('spaceBefore' => 10, 'spaceAfter' => 10)); $table = $section->addTable('Fancy Table');
public function actionHtml() { $data = $this->getData(); $searchModel = $data['searchModel']; $dataProvider = $data['dataProvider']; $title = $data['title']; $modelName = $data['modelName']; $fields = $this->getFieldsKeys($searchModel->exportFields()); $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); $section->addTitle($title ? $title : $modelName); $table = $section->addTable(['name' => 'Tahoma', 'size' => 10, 'align' => 'center']); $table->addRow(300, ['exactHeight' => true]); foreach ($fields as $one) { $table->addCell(1500, ['bgColor' => 'eeeeee', 'valign' => 'center', 'borderTopSize' => 5, 'borderRightSize' => 5, 'borderBottomSize' => 5, 'borderLeftSize' => 5])->addText($searchModel->getAttributeLabel($one), ['bold' => true, 'size' => 10], ['align' => 'center']); } foreach ($dataProvider->getModels() as $model) { $table->addRow(300, ['exactHeight' => true]); foreach ($searchModel->exportFields() as $one) { if (is_string($one)) { $table->addCell(1500, ['valign' => 'center', 'borderTopSize' => 1, 'borderRightSize' => 1, 'borderBottomSize' => 1, 'borderLeftSize' => 1])->addText('<p style="margin-left: 10px;">' . $model[$one] . '</p>', ['bold' => false, 'size' => 10], ['align' => 'right']); } else { $table->addCell(1500, ['valign' => 'center', 'borderTopSize' => 1, 'borderRightSize' => 1, 'borderBottomSize' => 1, 'borderLeftSize' => 1])->addText('<p style="margin-left: 10px;">' . $one($model) . '</p>', ['bold' => false, 'size' => 10], ['align' => 'right']); } } } header('Content-Type: application/html'); $filename = $modelName . '_' . time() . ".html"; header('Content-Disposition: attachment;filename=' . $filename . ' '); header('Cache-Control: max-age=0'); $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'HTML'); $objWriter->save('php://output'); }
<?php include_once 'Sample_Header.php'; // New Word Document echo date('H:i:s'), " Create new PhpWord object", EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $filler = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' . 'Nulla fermentum, tortor id adipiscing adipiscing, tortor turpis commodo. ' . 'Donec vulputate iaculis metus, vel luctus dolor hendrerit ac. ' . 'Suspendisse congue congue leo sed pellentesque.'; // Normal $section = $phpWord->addSection(); $section->addText('Normal paragraph. ' . $filler); // Two columns $section = $phpWord->addSection(array('colsNum' => 2, 'colsSpace' => 1440, 'breakType' => 'continuous')); $section->addText('Two columns, one inch (1440 twips) spacing. ' . $filler); // Normal $section = $phpWord->addSection(array('breakType' => 'continuous')); $section->addText('Normal paragraph again. ' . $filler); // Three columns $section = $phpWord->addSection(array('colsNum' => 3, 'colsSpace' => 720, 'breakType' => 'continuous')); $section->addText('Three columns, half inch (720 twips) spacing. ' . $filler); // Normal $section = $phpWord->addSection(array('breakType' => 'continuous')); $section->addText('Normal paragraph again.'); // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); if (!CLI) { include_once 'Sample_Footer.php'; }
$nRowsEj = $rsEje->_numOfRows; $dataEje = array(); if ($nRowsEj > 0) { while (!$rsEje->EOF) { array_push($dataEje, array_map('utf8_encode', $rsEje->fields)); $rsEje->movenext(); } $dataEje = end($dataEje); } include_once 'Sample_Header.php'; // New Word document //echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord->setDefaultParagraphStyle(array('align' => 'both', 'spaceAfter' => \PhpOffice\PhpWord\Shared\Converter::pointToTwip(12), 'spacing' => 15, 'name' => 'Tahoma')); // Sample $section = $phpWord->addSection(array('breakType' => 'continuous')); $section->addText(htmlspecialchars($dataEje['Frase']), array('bold' => false), array('space' => array('before' => 600, 'after' => 250), 'align' => 'center')); $section->addText(htmlspecialchars('203200-' . $dataOfi['PfjOfi'] . '-' . substr($dataOfi['CveOfi'], 2, 4) . '/' . substr($ano, 2, 2)), array('bold' => false), array('space' => array('before' => 80, 'after' => 80), 'align' => 'right')); $section->addText(htmlspecialchars('Toluca de Lerdo, México;'), array('bold' => false), array('space' => array('before' => 80, 'after' => 80), 'align' => 'right')); $section->addText(htmlspecialchars($fechaOficio), array('bold' => false), array('space' => array('before' => 80, 'after' => 80), 'align' => 'right')); $table = $section->addTable('Table'); $table->addRow(300); $table->addCell(6000, array('valign' => 'center'))->addText(htmlspecialchars('Asunto:'), array('bold' => true), array('align' => 'right')); $table->addCell(4000, array('valign' => 'center'))->addText(htmlspecialchars(nl2br($dataOfi['AsuOfi'])), array('bold' => false), array('align' => 'right')); //Acentos $tit = nl2br($dataOfi['TitOfi']); $titular = explode("<br />", $tit); foreach ($titular as $tit) { $section = $phpWord->addSection(array('colsNum' => 2, 'colsSpace' => 100, 'breakType' => 'continuous')); $section->addText(htmlspecialchars(trim($tit)), array('name' => 'Tahoma', 'bold' => false), array('space' => array('before' => 50, 'after' => 50), 'align' => 'left')); }
/** * */ public function exportMemberProfile($id) { $user = User::find($id); if (!$user) { return Redirect::route('members')->with('mError', 'Cet utilisateur est introuvable !'); } $phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord->addTitleStyle(1, array('name' => 'Tahoma', 'size' => 30, 'bold' => true), array('align' => 'center', 'spaceBefore' => true, 'spaceAfter' => true)); $phpWord->addTitleStyle(2, array('name' => 'Tahoma', 'size' => 14, 'color' => '666666', 'bold' => true), array('align' => 'center', 'spaceBefore' => true, 'spaceAfter' => true)); $phpWord->addFontStyle('defaultText', array('name' => 'Tahoma', 'size' => 12, 'spaceBefore' => true, 'spaceAfter' => true)); $section = $phpWord->addSection(array('marginTop' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(1), 'marginLeft' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(1), 'marginRight' => \PhpOffice\PhpWord\Shared\Converter::cmToTwip(1))); $textrun = $section->addTextRun('Heading1'); $textrun->addText($user->fullname); $section->addTextBreak(); $textrun = $section->addTextRun('Heading2'); $textrun->addText(htmlspecialchars($user->bio_short)); $section->addTextBreak(); $table = $section->addTable(); $table->addRow(); $cell1 = $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(14)); foreach (explode("\n", htmlspecialchars($user->bio_long)) as $line) { $cell1->addText($line, 'defaultText'); } $cell1->addTextBreak(); if ($user->phone) { $cell1->addText(htmlspecialchars(sprintf('Tél: %s', $user->phoneFmt)), 'defaultText', array('align' => 'right')); } $cell1->addText(htmlspecialchars(sprintf('Email: %s', $user->email)), 'defaultText', array('align' => 'right')); if ($user->website) { $cell1->addText(htmlspecialchars($user->website), 'defaultText', array('align' => 'right')); } $cell2 = $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(5)); $image_url = $user->largeAvatarUrl; $image_url = preg_replace('!^(.+)\\?.+$!', '$1', $image_url); if (false === strpos($image_url, 'http')) { $image_url = public_path() . $image_url; } $cell2->addImage($image_url, array('width' => \PhpOffice\PhpWord\Shared\Converter::cmToPixel(5))); $filename = sprintf('%s.docx', Str::slug($user->fullname)); $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); $objWriter->save($filename); $content = file_get_contents($filename); unlink($filename); $headers = array("Content-Description" => "File Transfer", "Content-Transfer-Encoding" => "binary", "Content-type" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Content-Disposition" => "attachment; filename=" . $filename); return Response::make($content, 200, $headers); }
public function downloadWord() { // echo COMMON_PATH . 'Org/PhpWord/Autoloader.php';exit; require_once COMMON_PATH . 'Org/PhpWord/Autoloader.php'; \PhpOffice\PhpWord\Autoloader::register(); \PhpOffice\PhpWord\Settings::loadConfig(); echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); $header = array('size' => 16, 'bold' => true); $styleTable = array('borderSize' => 6, 'borderColor' => '000000', 'cellMargin' => 80, 'width' => '100%'); $styleFirstRow = array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF'); $styleCell = array('align' => 'center'); $fontStyle = array('bold' => true, 'align' => 'center'); $section->addText("用户相关", $header); $phpWord->addTableStyle('Table', $styleTable); $table = $section->addTable('Table'); $table->addRow(30); $table->addCell(2000, $styleCell)->addText("字段", $fontStyle); $table->addCell(1000, $styleCell)->addText("类型", $fontStyle); $table->addCell(800, $styleCell)->addText("必选", $fontStyle); $table->addCell()->addText("说明", $fontStyle); for ($i = 1; $i <= 8; $i++) { $table->addRow(); $table->addCell(2000)->addText("userTel"); $table->addCell(1000)->addText("字符串"); $table->addCell(800)->addText("是"); $table->addCell()->addText(htmlspecialchars("手机号码")); } $section->addPageBreak(); $fileName = "word报表" . date("YmdHis") . ".docx"; // header("Content-type: application/vnd.ms-word"); // header("Content-Disposition:attachment;filename=".$fileName.".docx"); // header('Cache-Control: max-age=0'); $phpWord->save($fileName, 'Word2007'); }
$json = file_get_contents($TAITAN . $_GET['path']); //$json = mb_convert_encoding($json , 'HTML-ENTITIES', "UTF-8"); $obj = json_decode($json); $file = $obj->title . '.docx'; header("Content-Description: File Transfer"); header('Content-Disposition: inline; filename="' . $file . '"'); header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document'); header('Content-Transfer-Encoding: binary'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Expires: 0'); #$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); #$xmlWriter->save("php://output"); \PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(true); // New Word document // New section $section = $phpWord->addSection(); // Define styles $phpWord->addTitleStyle(1, array('size' => 35, 'bold' => true, 'color' => '#e83d84')); // Adding Text element with font customized using named font style... $pStyle = 'p'; $phpWord->addFontStyle($pStyle, array('name' => 'Arial', 'size' => 16, 'color' => '757575', 'bold' => false)); // Arc $section->addTitle($obj->title, 1); //$section->addText(htmlspecialchars_decode(strip_tags($obj->body)), $pStyle); WaffleHtml::addHtml($section, $obj->body); if ($obj->sidebar) { $sidebar = $phpWord->addSection(); $sidebar->addTitle("Sidebar", 1); //$sidebar->addText(strip_tags($obj->sidebar), $pStyle); WaffleHtml::addHtml($sidebar, $obj->sidebar); }
<?php include_once 'Sample_Header.php'; use PhpOffice\PhpWord\Shared\Converter; // New Word document echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Define styles $phpWord->addTitleStyle(1, array('size' => 14, 'bold' => true), array('keepNext' => true, 'spaceBefore' => 240)); $phpWord->addTitleStyle(2, array('size' => 14, 'bold' => true), array('keepNext' => true, 'spaceBefore' => 240)); // 2D charts $section = $phpWord->addSection(); $section->addTitle('2D charts', 1); $section = $phpWord->addSection(array('colsNum' => 2, 'breakType' => 'continuous')); $chartTypes = array('pie', 'doughnut', 'bar', 'column', 'line', 'area', 'scatter', 'radar'); $twoSeries = array('bar', 'column', 'line', 'area', 'scatter', 'radar'); $threeSeries = array('bar', 'line'); $categories = array('A', 'B', 'C', 'D', 'E'); $series1 = array(1, 3, 2, 5, 4); $series2 = array(3, 1, 7, 2, 6); $series3 = array(8, 3, 2, 5, 4); foreach ($chartTypes as $chartType) { $section->addTitle(ucfirst($chartType), 2); $chart = $section->addChart($chartType, $categories, $series1); $chart->getStyle()->setWidth(Converter::inchToEmu(2.5))->setHeight(Converter::inchToEmu(2)); if (in_array($chartType, $twoSeries)) { $chart->addSeries($categories, $series2); } if (in_array($chartType, $threeSeries)) { $chart->addSeries($categories, $series3); }
/** * @Security("has_role('ROLE_USER')") */ private function downloadQRCodeFile(Rucher $rucher, $ruches) { //Création de l'objet phpWord pour le fichier word $phpWord = new \PhpOffice\PhpWord\PhpWord(); //Création du path pour gérer les fichiers temporaires $path = $this->get('kernel')->getRootDir() . "/../web/generate/"; //Ajout d'une section $section = $phpWord->addSection(); //Ajout d'un en-tête $phpWord->addFontStyle('eStyle', array('bold' => true, 'size' => 16)); $phpWord->addFontStyle('rStyle', array('size' => 14)); $header = $section->addHeader(); $headerTable = $header->addTable(); $headerTable->addRow(); $headerTable->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(5))->addImage('logo.png', array('height' => 80)); $cellText = $headerTable->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(11)); $cellText->addText(htmlspecialchars($rucher->getExploitation()->getNom()), 'eStyle', array('align' => 'right')); $cellText->addText(htmlspecialchars($rucher->getNom()), 'rStyle', array('align' => 'right')); //Ajout d'un pied de page $footer = $section->addFooter(); $footer->addPreserveText(htmlspecialchars('{PAGE}/{NUMPAGES}'), null, array('align' => 'right')); //Création du style des cellules $cellStyle = array('valign' => 'center'); $phpWord->addFontStyle('qStyle', array('size' => 12)); //Ajout de la table contenant les qr codes $table = $section->addTable(); //Nombre de ruches dans le fichier, utile pour créer une nouvelle ligne $nbRuches = 0; foreach ($ruches as $ruche) { //3 QRCodes par ligne if ($nbRuches % 3 === 0) { $table->addRow(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(5.5)); } $nbRuches++; //Construction de l'url pour accéder à la ruche $url = $this->generateUrl('kg_beekeeping_management_view_ruche', array('ruche_id' => $ruche->getId()), true); //Construction du QRCode pointant sur l'url de la ruche $options = array('code' => $url, 'type' => 'qrcode', 'format' => 'png'); $barcode = $this->get('sgk_barcode.generator')->generate($options); //Path du fichier avec le QRCode $filename = 'qrcode' . $ruche->getId() . '.png'; //Sauvegarde du fichier file_put_contents($path . $filename, base64_decode($barcode)); //Ajout du QRCode dans le fichier ODT $cell = $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(5.33), $cellStyle); $cell->addText(htmlspecialchars($ruche->getNom()), 'qStyle', array('align' => 'center')); $cell->addImage('generate/' . $filename, array('width' => 151.18, 'height' => 151.18, 'wrappingStyle' => 'behind', 'align' => 'center')); } //Ajout de cellules vides si ligne incomplète $reste = 3 - $nbRuches % 3; if ($reste < 3) { while ($reste > 0) { $cell = $table->addCell(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(5.33), $cellStyle); $reste--; } } //Sauvegarde du fichier ODT $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007'); $filename = $rucher->getId() . '_qr_codes_rucher_' . $rucher->getNom() . '.docx'; $objWriter->save($path . $filename, 'Word2007', true); //Récupération du contenu du fichier $content = file_get_contents($path . $filename); //Création de la réponse avec le contentu du fichier (pour le download) $response = new Response(); $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'); $response->headers->set('Content-Disposition', 'attachment;filename="' . $filename); $response->setContent($content); //Suppression des fichiers créés durant la création du fichier word unlink($path . $filename); foreach ($ruches as $ruche) { $filename = 'qrcode' . $ruche->getId() . '.png'; unlink($path . $filename); } //Retour de la réponse return $response; }
<?php include_once 'Sample_Header.php'; // New Word Document echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // New portrait section $section = $phpWord->addSection(array('borderColor' => '00FF00', 'borderSize' => 12)); $section->addText('I am placed on a default section.'); // New landscape section $section = $phpWord->addSection(array('orientation' => 'landscape')); $section->addText('I am placed on a landscape section. Every page starting from this section will be landscape style.'); $section->addPageBreak(); $section->addPageBreak(); // New portrait section $section = $phpWord->addSection(array('paperSize' => 'Folio', 'marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600)); $section->addText('This section uses other margins with folio papersize.'); // New portrait section with Header & Footer $section = $phpWord->addSection(array('marginLeft' => 200, 'marginRight' => 200, 'marginTop' => 200, 'marginBottom' => 200, 'headerHeight' => 50, 'footerHeight' => 50)); $section->addText('This section and we play with header/footer height.'); $section->addHeader()->addText('Header'); $section->addFooter()->addText('Footer'); // Save file echo write($phpWord, basename(__FILE__, '.php'), $writers); if (!CLI) { include_once 'Sample_Footer.php'; }
public function gera_word() { $this->load->library('word2'); // Set writers $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf', 'HTML' => 'html', 'PDF' => 'pdf'); // Set PDF renderer if (Settings::getPdfRendererPath() === null) { $writers['PDF'] = null; } // Return to the caller script when runs by CLI //if (CLI) { // return; //} // Set titles and names //$pageHeading = str_replace('_', ' ', SCRIPT_FILENAME); $pageHeading = "page heading"; //$pageTitle = IS_INDEX ? 'Welcome to ' : "{$pageHeading} - "; $pageTitle = "titulo da pagina"; //$pageTitle .= 'PHPWord'; //$pageHeading = IS_INDEX ? '' : "<h1>{$pageHeading}</h1>"; // Populate samples $files = ''; if ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if (preg_match('/^Sample_\\d+_/', $file)) { $name = str_replace('_', ' ', preg_replace('/(Sample_|\\.php)/', '', $file)); $files .= "<li><a href='{$file}'>{$name}</a></li>"; } } closedir($handle); } //include_once 'Sample_Header.php'; require_once APPPATH . "third_party/PHPWord2/PhpWord.php"; // New Word Document echo date('H:i:s'), " Create new PhpWord object"; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord->addFontStyle('rStyle', array('bold' => true, 'italic' => true, 'size' => 16, 'allCaps' => true, 'doubleStrikethrough' => true)); $phpWord->addParagraphStyle('pStyle', array('align' => 'center', 'spaceAfter' => 100)); $phpWord->addTitleStyle(1, array('bold' => true), array('spaceAfter' => 240)); // New portrait section $section = $phpWord->addSection(); // Simple text $section->addTitle('Welcome to PhpWord', 1); $section->addText('Hello World!'); // Two text break $section->addTextBreak(2); // Defined style $section->addText('I am styled by a font style definition.', 'rStyle'); $section->addText('I am styled by a paragraph style definition.', null, 'pStyle'); $section->addText('I am styled by both font and paragraph style.', 'rStyle', 'pStyle'); $section->addPageBreak(); // Inline font style $fontStyle['name'] = 'Times New Roman'; $fontStyle['size'] = 20; $fontStyle['bold'] = true; $fontStyle['italic'] = true; $fontStyle['underline'] = 'dash'; $fontStyle['strikethrough'] = true; $fontStyle['superScript'] = true; $fontStyle['color'] = 'FF0000'; $fontStyle['fgColor'] = 'yellow'; $fontStyle['smallCaps'] = true; $section->addText('I am inline styled.', $fontStyle); $section->addTextBreak(); // Link $section->addLink('http://www.google.com', 'Google'); $section->addTextBreak(); // Image //$section->addImage('resources/_earth.jpg', array('width'=>18, 'height'=>18)); // Save file //echo write($phpWord, basename(__FILE__, '.php'), $writers); //if (!CLI) { //include_once 'Sample_Footer.php'; // } // Save file echo $this->write($phpWord, basename(__FILE__, '.php'), $writers); if (!CLI) { //include_once 'Sample_Footer.php'; } }
/** * just an example * */ public static function Report($cid) { $m = InvoicePallet::model()->findByAttributes(array('id' => $cid)); $n = Supplier::model()->findByAttributes(array('number' => $m->supplier_no)); $i = Pallet::model()->findByAttributes(array('id' => $m->pid)); spl_autoload_unregister(array('YiiBase', 'autoload')); require_once Yii::getPathOfAlias('webroot') . '/assets/phpword/samples/Sample_Header.php'; spl_autoload_register(array('YiiBase', 'autoload')); $phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord->setDefaultFontName('新宋体'); $phpWord->setDefaultFontSize(12); $phpWord->setDefaultParagraphStyle(array('align' => 'both', 'lineHeight' => '2')); $section = $phpWord->addSection(); $section->addText('开票通知', array('bold' => true, 'size' => 24), array('align' => 'center', 'space' => array('before' => 200, 'after' => 100))); $section->addText('注意:请收到立即开票!谢谢!', array('bold' => true, 'size' => 20), array('align' => 'center', 'space' => array('before' => 200, 'after' => 200))); $section->addText('TO:' . ' ' . $n->name . ' 传真:', null, array('align' => 'left')); $section->addText('公司名称:拓泓贸易(上海)有限公司', null, array('align' => 'left')); $section->addText('纳税人识别号:310112690186868', null, array('align' => 'left')); $section->addText('开票地址电话:上海市闵行区元江路5500号D1幢869室(021-54846073)', null, array('align' => 'left')); $section->addText('开户行及账号:上海浦东发展银行闵行支行 98280154740006293', null, array('align' => 'left')); $section->addTextBreak(1); $section->addText('开票资料如下:', array('bold' => true, 'size' => 16), array('align' => 'left')); $styleTable = array('borderSize' => 2, 'borderColor' => '686868', 'align' => 'center'); $styleFirstRow = array('borderBottomSize' => 18, 'borderBottomColor' => '0000FF', 'bgColor' => '66BBFF'); $styleCell = array('valign' => 'center', 'halign' => 'center'); $fontStyle = array('bold' => false, 'size' => 11, 'borderSize' => 2); $center = array('spaceBefore' => 10, 'spaceAfter' => 0, 'align' => 'center', 'valign' => 'center'); $phpWord->addTableStyle('table1', $styleTable, array('align' => 'center')); $table = $section->addTable('table1'); $table->addRow(); $table->addCell(1800)->addText('开票品名', $fontStyle, $center); $table->addCell(1000)->addText('型号', $fontStyle, $center); $table->addCell(800)->addText('数量', $fontStyle, $center); $table->addCell(800)->addText('单位', $fontStyle, $center); $table->addCell(1000)->addText('单价', $fontStyle, $center); $table->addCell(1800)->addText('总价', $fontStyle, $center); $table->addCell(2500)->addText('合同号', $fontStyle, $center); $table->addRow(); $table->addCell(1800)->addText($m->type, $fontStyle, $center); $table->addCell(1000)->addText($m->model, $fontStyle, $center); $table->addCell(800)->addText($m->num, $fontStyle, $center); $table->addCell(800)->addText($m->unit, $fontStyle, $center); $table->addCell(800)->addText($m->unit_price, $fontStyle, $center); $table->addCell(1800)->addText($m->unit_price * $m->num, $fontStyle, $center); $table->addCell(2500)->addText($i->purchase_contract_no, $fontStyle, $center); $table->addRow(); $table->addCell(1800)->addText('合计', $fontStyle, $center); $table->addCell(1000)->addText('', $fontStyle, $center); $table->addCell(800)->addText('', $fontStyle, $center); $table->addCell(800)->addText('', $fontStyle, $center); $table->addCell(800)->addText('', $fontStyle, $center); $table->addCell(1800)->addText('¥' . $m->unit_price * $m->num, $fontStyle, $center); $table->addCell(2500)->addText($i->purchase_contract_no, $fontStyle, $center); $section->addText('请开票后,全套发票寄至以下地址:', array('bold' => true, 'size' => 12), array('align' => 'left')); $section->addText('上海市闵行区曲吴路589号9号楼205', null, array('align' => 'left')); $section->addText('拓泓贸易(上海)有限公司', null, array('align' => 'left')); $section->addText('电话:021-54846073 13661561440', null, array('align' => 'left')); $section->addText('联系人:叶建伟', null, array('align' => 'left')); $section->addText('如有疑问,请今日联系!', null, array('align' => 'left')); $section->addText('日期:' . date('Y-m-d'), null, array('align' => 'left')); $fileName = "{$n->name}.doc"; // $fileName = iconv ( "utf-8", "gb2312", $fileName); // $fileName = mb_convert_encoding($fileName, "utf-8", "auto"); $absPath = Yii::getPathOfAlias('webroot'); $relPath = '/uploads/files/'; $file = $absPath . $relPath . $fileName; $fPath = $relPath . $fileName; $fName = '开票通知 - ' . date("Ymd"); $res = array('name' => $fName, 'url' => $fPath); write($phpWord, $file, $writers); return $res; }
$phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord->addParagraphStyle('header', array('align' => 'left', 'lineHeight' => 1.0, 'spaceAfter' => 0, 'keepNext' => true, 'keepLines' => true)); $phpWord->addFontStyle('headerFont', array('size' => 14, 'name' => 'Arial')); $phpWord->addParagraphStyle('info', array('align' => 'left', 'lineHeight' => 1.0, 'spaceAfter' => 0, 'keepNext' => true, 'keepLines' => true)); $phpWord->addFontStyle('infoFont', array('size' => 11, 'name' => 'Arial')); $phpWord->addFontStyle('colHeaderFont', array('size' => 8, 'bold' => true, 'name' => 'Arial')); $phpWord->addFontStyle('colFont', array('size' => 8, 'name' => 'Arial')); $phpWord->addParagraphStyle('colHeadSpace', array('lineHeight' => 1.5, 'spaceAfter' => 0)); $phpWord->addParagraphStyle('colSpace', array('lineHeight' => 1.3, 'spaceAfter' => 0)); $tableHeadStyle = array('borderBottomSize' => 10, 'borderBottomColor' => '000000', 'width' => 100); $tableStyle = array('width' => 100); $colRowStyle = array('cantSplit' => true); $phpWord->addTableStyle('headerTable', $tableHeadStyle, $colRowStyle); $phpWord->addTableStyle('listTable', $tableStyle, $colRowStyle); $cellStyle = array('valign' => 'bottom'); $section = $phpWord->addSection(array('pageSizeW' => 12240, 'pageSizeH' => 15840, 'marginLeft' => 1080, 'marginRight' => 1080, 'marginTop' => 1080, 'marginBottom' => 1080, 'headerHeight' => 0, 'footerHeight' => 0)); $textrun = $section->addTextRun('header'); $textrun->addText(htmlspecialchars('List of specimens loaned to: ' . $invoiceArr['institutioncode']), 'headerFont'); $section->addTextBreak(1); $textrun = $section->addTextRun('info'); $textrun->addText(htmlspecialchars($addressArr['institutioncode'] . ' Loan ID: ' . $invoiceArr['loanidentifierown']), 'infoFont'); $textrun->addTextBreak(1); $textrun->addText(htmlspecialchars('Date sent: ' . $invoiceArr['datesent']), 'infoFont'); $textrun->addTextBreak(1); $textrun->addText(htmlspecialchars('Total specimens: ' . ($specTotal ? $specTotal['speccount'] : 0)), 'infoFont'); $section->addTextBreak(1); $table = $section->addTable('headerTable'); $table->addRow(); $table->addCell(2250, $cellStyle)->addText(htmlspecialchars('Catalog #'), 'colHeaderFont', 'colHeadSpace'); $table->addCell(4500, $cellStyle)->addText(htmlspecialchars('Collector + Number'), 'colHeaderFont', 'colHeadSpace'); $table->addCell(6000, $cellStyle)->addText(htmlspecialchars('Current Determination'), 'colHeaderFont', 'colHeadSpace');
$phpWord->addFontStyle('scientificnameFont', array('bold' => true, 'italic' => true, 'size' => 11, 'name' => 'Arial')); $phpWord->addFontStyle('scientificnameinterFont', array('bold' => true, 'size' => 11, 'name' => 'Arial')); $phpWord->addFontStyle('scientificnameauthFont', array('size' => 11, 'name' => 'Arial')); $phpWord->addParagraphStyle('identified', array('align' => 'left', 'lineHeight' => 1.0, 'spaceAfter' => 0, 'indent' => 0.3125, 'keepNext' => true, 'keepLines' => true)); $phpWord->addFontStyle('identifiedFont', array('size' => 10, 'name' => 'Arial')); $phpWord->addParagraphStyle('loc1', array('spaceBefore' => 150, 'lineHeight' => 1.0, 'spaceAfter' => 0, 'align' => 'left', 'keepNext' => true, 'keepLines' => true)); $phpWord->addFontStyle('countrystateFont', array('size' => 11, 'bold' => true, 'name' => 'Arial')); $phpWord->addFontStyle('localityFont', array('size' => 11, 'name' => 'Arial')); $phpWord->addParagraphStyle('other', array('align' => 'left', 'lineHeight' => 1.0, 'spaceAfter' => 0, 'keepNext' => true, 'keepLines' => true)); $phpWord->addFontStyle('otherFont', array('size' => 10, 'name' => 'Arial')); $phpWord->addFontStyle('associatedtaxaFont', array('size' => 10, 'italic' => true, 'name' => 'Arial')); $phpWord->addParagraphStyle('collector', array('spaceBefore' => 150, 'lineHeight' => 1.0, 'spaceAfter' => 0, 'align' => 'left', 'keepNext' => true, 'keepLines' => true)); $phpWord->addParagraphStyle('cnbarcode', array('align' => 'center', 'lineHeight' => 1.0, 'spaceAfter' => 0, 'spaceBefore' => 150, 'keepNext' => true, 'keepLines' => true)); $phpWord->addParagraphStyle('lfooter', array('align' => 'center', 'lineHeight' => 1.0, 'spaceAfter' => 0, 'spaceBefore' => 150, 'keepNext' => true, 'keepLines' => true)); $phpWord->addFontStyle('lfooterFont', array('bold' => true, 'size' => 12, 'name' => 'Arial')); $section = $phpWord->addSection($sectionStyle); foreach ($labelArr as $occid => $occArr) { if ($barcodeOnly) { if ($occArr['catalognumber']) { $textrun = $section->addTextRun('cnbarcode'); $bc = $bcObj->draw(strtoupper($occArr['catalognumber']), "Code39", "png", false, 40); imagepng($bc, $serverRoot . '/temp/report/' . $ses_id . $occArr['catalognumber'] . '.png'); $textrun->addImage($serverRoot . '/temp/report/' . $ses_id . $occArr['catalognumber'] . '.png', array('align' => 'center')); imagedestroy($bc); } } else { $midStr = ''; if ($hMid == 1) { $midStr = $occArr['country']; } elseif ($hMid == 2) { $midStr = $occArr['stateprovince'];
$style_align_center = array("align" => "center"); $php_word->addParagraphStyle("style_align_center", $style_align_center); $style_table = array('width' => 50000, 'borderSize' => 6, 'cellMargin' => 100, 'align' => 'center'); $php_word->addTableStyle('style_table', $style_table); //$style_first_row = array('bgcolor'=>'66BBFF'); $style_cellule_titre = array('valign' => 'center', 'gridspan' => 3); $style_row = array('cantSplit' => true, 'exactHeight' => 500); $style_row_titre = array('tblHeader' => false, 'cantSplit' => true, 'exactHeight' => 500); $table_width = 10000; // variable avec nom significatif pour son utilisation $saut_ligne = ""; // Fin de la définiton des styles // ---------------------------------------------- // ---------------------------------------------- // Section de l'indentification du cours $section_template = $php_word->addSection(); // $nom_etablissement = "Collège Lionel-Groulx"; $section_template->addText($nom_etablissement); $section_template->addText($type_enseignement, null, "style_align_right"); $section_template->addText($programme_cours, null, "style_align_right"); // espace avant et après le titre du document $section_template->addText($saut_ligne); $section_template->addText("Plan-cadre en élaboration", $style_font_titre, $style_align_center); $section_template->addText($saut_ligne); $table_identification = $section_template->addTable('style_table'); $nombre_colonnes = 3; $cell_width = $table_width / $nombre_colonnes; $table_identification->addRow($style_row); $table_identification->addCell($cell_width, $style_cellule_titre)->addText("Identification du cours", $style_font_titre, $style_align_center); $table_identification->addRow($style_row);
} $a_class = $this->template == 'panel/em-cartaz' ? 'active' : ''; $url = $app->createUrl('panel', 'em-cartaz'); echo "<li><a class='{$a_class}' href='{$url}'><span class='icon icon-em-cartaz'></span> Em Cartaz</a></li>"; }); $app->hook('GET(panel.em-cartaz-<<download|preview>>)', function () use($app, $defaultFrom, $defaultTo) { if (!$app->user->is('admin') && !$app->user->is('staff')) { //throw new MapasCulturais\Exceptions\PermissionDenied; $app->pass(); } $from = isset($this->getData['from']) ? new DateTime($this->getData['from']) : $defaultFrom; $to = isset($this->getData['to']) ? new DateTime($this->getData['to']) : $defaultTo; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Every element you want to append to the word document is placed in a section. // To create a basic section: $section = $phpWord->addSection(); $defaultFont = $phpWord->addFontStyle('defaultFont', array('name' => 'Arial', 'size' => 12)); $documentHead = $phpWord->addFontStyle('documentHead', array('name' => 'Arial', 'size' => 18, 'color' => '44AA88', 'bold' => true)); $eventTitleFont = $phpWord->addFontStyle('eventTitle', array('name' => 'Arial', 'size' => 12, 'color' => '880000', 'bold' => true)); $linguagemStyle = $phpWord->addFontStyle('linguagemStyle', array('name' => 'Arial', 'size' => 12, 'color' => 'FF0000', 'bold' => true)); $linguagens = array('Cinema', 'Dança', 'Teatro', 'Música Popular', 'Música Erudita', 'Exposição', 'Curso ou Oficina', 'Palestra, Debate ou Encontro'); $section->addText('ROTEIRO GERAL (SITE) REVISTA', $documentHead); $getEventTextBlock = function ($event) use($app) { // return "TEXT {$event->name}"; $eventText = trim($event->shortDescription); if (!empty($event->classificacaoEtaria)) { $eventText .= $event->classificacaoEtaria; } $eventText .= '. '; // Group occurrences by space $spaces = array();
function buildPlanCadre($id_plancadre) { $result = fetchAllInfoPlanCadre($id_plancadre); $info_plancadre = $result[0]; $etat = $info_plancadre["Etat"]; $nom_cours = "Titre du cours : " . $info_plancadre["NomCours"]; $code_cours = "Numéro du cours : " . $info_plancadre["CodeCours"]; $nom_programme = $info_plancadre["NomProgramme"]; $code_programme = $info_plancadre["CodeProgramme"]; $programme_cours = $nom_programme . "(" . $code_programme . ")"; $ponderation_cours = "Pondération : " . $info_plancadre["Ponderation"]; $nombre_unites_cours = "Nombre d'unité(s) : " . $info_plancadre["NombreUnites"]; $prealable_cours = "Préalable(s) : " . "Aucun"; $type_enseignement = $info_plancadre['TypeCours']; // le nom des fichiers textes serra : // clé primaire du plancadre + code ou le nom du cours + le nom de la section // exemple : 2_420-EDA-05_PresentationCours.txt $path_presentation = "../plancadre/" . $id_plancadre . "_" . $code_cours . "_" . "presentation" . ".txt"; $path_integration = "../plancadre/" . $id_plancadre . "_" . $code_cours . "_" . "integration" . ".txt"; $path_evalutation = "../plancadre/" . $id_plancadre . "_" . $code_cours . "_" . "evaluation" . ".txt"; $path_competences = "../plancadre/" . $id_plancadre . "_" . $code_cours . "_" . "competences" . ".txt"; $path_apprentissage = "../plancadre/" . $id_plancadre . "_" . $code_cours . "_" . "apprentissage" . ".txt"; $presentation = ReadFrom($path_presentation); $integration = ReadFrom($path_integration); $evaluation = ReadFrom($path_evalutation); $competences = ReadFrom($path_competences); $apprentissage = ReadFrom($path_apprentissage); /* ---------------------------------------------- Début de la création du document. Le code qui suit pourrait être considéré comme un template si on arrive à le paramétrer correctement. ---------------------------------------------- */ $php_word = new \PhpOffice\PhpWord\PhpWord(); // ---------------------------------------------- // ajout des styles au document $php_word->addParagraphStyle("style_align_right", $GLOBALS["style_align_right"]); $php_word->addParagraphStyle("style_align_center", $GLOBALS["style_align_center"]); $php_word->addTableStyle('style_table', $GLOBALS["style_table"]); // ---------------------------------------------- // ---------------------------------------------- // Section de l'indentification du cours $section_template = $php_word->addSection(); // $nom_etablissement = "Collège Lionel-Groulx"; $section_template->addText($nom_etablissement); $section_template->addText($type_enseignement, null, "style_align_right"); $section_template->addText($programme_cours, null, "style_align_right"); switch ($info_plancadre["Etat"]) { case 'Adopté': if ($info_plancadre["Officiel"] > 0) { $titre_document = "Plan-cadre officiel"; } else { $titre_document = "Plan-cadre en archive"; } break; case 'Validé': case 'Élaboration': default: $titre_document = "Plan-cadre en élaboration"; break; } // espace avant et après le titre du document $section_template->addText($GLOBALS["saut_ligne"]); $section_template->addText($titre_document, $GLOBALS["style_font_titre"], $GLOBALS["style_align_center"]); $section_template->addText($GLOBALS["saut_ligne"]); $table_identification = $section_template->addTable('style_table'); $nombre_colonnes = 3; $cell_width = $GLOBALS["table_width"] / $nombre_colonnes; $table_identification->addRow($GLOBALS["style_row"]); $table_identification->addCell($cell_width, $GLOBALS["style_cellule_titre"])->addText("Identification du cours", $GLOBALS["style_font_titre"], $GLOBALS["style_align_center"]); $table_identification->addRow($GLOBALS["style_row"]); $table_identification->addCell($cell_width)->addText("Discipline", null, $GLOBALS["style_align_center"]); $table_identification->addCell($cell_width)->addText($nom_cours, null, $GLOBALS["style_align_center"]); $table_identification->addCell($cell_width)->addText($code_cours, null, $GLOBALS["style_align_center"]); $table_identification->addRow($GLOBALS["style_row"]); $table_identification->addCell($cell_width)->addText($ponderation_cours, null, $GLOBALS["style_align_center"]); $table_identification->addCell($cell_width)->addText($nombre_unites_cours, null, $GLOBALS["style_align_center"]); $table_identification->addCell($cell_width)->addText("test", null, $GLOBALS["style_align_center"]); // Fin de la section de l'indentification du cours // ---------------------------------------------- // ---------------------------------------------- // Section de la présentation du cours $titre = "Présentation du cours"; addSection($php_word, $titre, $presentation); // Fin de la section de la présentation du cours // ---------------------------------------------- // ---------------------------------------------- // Section de l'objectif d'intégration $titre = "Objectif d'intégration"; addSection($php_word, $titre, $integration); // Fin de la section de l'objectif d'intégration // ---------------------------------------------- // ---------------------------------------------- // Section de l'évaluation des apprentissages $titre = 'Évaluation des apprentissages'; addSection($php_word, $titre, $evaluation); // Fin de la section de l'évaluation des apprentissages // ---------------------------------------------- // ---------------------------------------------- // Section de l'énoncé des compétences $titre_section = "Énoncé des compétences"; addSection($php_word, $titre, $competences); // Fin de la section de l'énoncé des compétences // ---------------------------------------------- // ---------------------------------------------- // Section des objectifs d'apprentissage $titre = "Objectifs d'apprentissage"; addSection($php_word, $titre, $apprentissage); // Fin de la section des objectifs d'apprentissage // ---------------------------------------------- $path_docx = "../plancadre/" . $id_plancadre . "_" . $code_cours . ".docx"; $php_word->save($path_docx); }