$table1->addCell()->addText("Costo"); $total = 0; foreach ($alumns as $al) { $medic = $al->getMedic(); $pacient = $al->getPacient(); $table1->addRow(); $table1->addCell(3000)->addText($al->title); $table1->addCell(3000)->addText($pacient->name . " " . $pacient->lastname); $table1->addCell(3000)->addText($medic->name . " " . $medic->lastname); $table1->addCell(3000)->addText($al->date_at . " " . $al->time_at); $table1->addCell(3000)->addText($al->getStatus()->name); $table1->addCell(3000)->addText($al->getPayment()->name); $table1->addCell(3000)->addText("\$ " . number_format($al->price, 2, ".", ",")); $total += $al->price; } $section1->addText("TOTAL: \$ " . number_format($total, 2, ".", ","), array("size" => 18)); $word->addTableStyle('table1', $styleTable, $styleFirstRow); /// datos bancarios $section1->addText(""); $section1->addText(""); $section1->addText(""); $section1->addText("Generado por BookMedik v2.0"); $filename = "report-" . time() . ".docx"; #$word->setReadDataOnly(true); $word->save($filename, "Word2007"); //chmod($filename,0444); header("Content-Disposition: attachment; filename='{$filename}'"); readfile($filename); // or echo file_get_contents($filename); unlink($filename); // remove temp file
$textrun->addLine(array('weight' => 2, 'width' => $lineWidth, 'height' => 0, 'dash' => 'dash')); $textrun->addTextBreak(1); $bc = $bcObj->draw(strtoupper($occid), "Code39", "png", false, 40); imagepng($bc, $serverRoot . '/temp/report/' . $ses_id . $occid . '.png'); $textrun->addImage($serverRoot . '/temp/report/' . $ses_id . $occid . '.png', array('align' => 'center', 'marginTop' => 0.104166667)); if ($occArr['catalognumber']) { $textrun->addTextBreak(1); $textrun->addText(htmlspecialchars($occArr['catalognumber']), 'otherFont'); } imagedestroy($bc); } $section->addText(htmlspecialchars(' '), 'dividerFont', 'lastLine'); } } } $targetFile = $serverRoot . '/temp/report/' . $paramsArr['un'] . '_' . date('Ymd') . '_labels_' . $ses_id . '.' . $exportExtension; $phpWord->save($targetFile, $exportEngine); header('Content-Description: File Transfer'); header('Content-type: application/force-download'); header('Content-Disposition: attachment; filename=' . basename($targetFile)); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . filesize($targetFile)); readfile($targetFile); $files = glob($serverRoot . '/temp/report/*'); foreach ($files as $file) { if (is_file($file)) { if (strpos($file, $ses_id) !== false) { unlink($file); } } }
$cell->addText(htmlspecialchars("当日未完成工作或本人不能解决的问题:"), $fontSizeStyle); $cell->addTextBreak(2); $cell->getStyle()->setGridSpan(9); $table->addRow(); $cell = $table->addCell(11500); $cell->addText(htmlspecialchars("明天工作计划"), $fontSizeStyle); $cell->addTextBreak(2); $cell->getStyle()->setGridSpan(9); $table->addRow(); $cell = $table->addCell(11500); $cell->addText(htmlspecialchars("前一天未完成的工作处理结果:"), $fontSizeStyle); $cell->addTextBreak(2); $cell->getStyle()->setGridSpan(9); $table->addRow(); $cell = $table->addCell(11500); $cell->addText(htmlspecialchars("当天计划完成情况:"), $fontSizeStyle); $cell->addTextBreak(1); $cell->addText(htmlspecialchars("完成 "), $fontSizeStyle); $cell->getStyle()->setGridSpan(9); $section->addTextBreak(1); $section->addText(htmlspecialchars('直接主管签名:'), $fontSizeStyle); $dir = "./word/" . $data->date; if (!is_dir($dir)) { mkdir($dir); } $path = '/word/' . $data->date . '/workplan-' . $data->uid . "-" . $data->date . '.docx'; $phpWord->save("." . $path, 'Word2007', false); echo './downWord' . $path; } else { echo "-1"; }
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'); }
// Section des objectifs d'apprentissage $section_apprentissage = $php_word->addSection(); $titre = "Objectifs d'apprentissage"; $table_apprentissage = $section_apprentissage->addTable('style_table'); $nombre_colonnes = 1; $cell_width = $table_width / $nombre_colonnes; $table_apprentissage->addRow($style_row_titre); $cellule_titre = $table_apprentissage->addCell($cell_width)->addText($titre, $style_font_titre, $style_align_center); $table_apprentissage->addRow($style_row); $cellule_contenu = $table_apprentissage->addCell($cell_width); \PhpOffice\PhpWord\Shared\Html::addHtml($cellule_contenu, $apprentissage); // Fin de la section des objectifs d'apprentissage // ---------------------------------------------- $plancadre = fetchPlanCadreElaboration_PlanCadre($_POST['id_plancadre']); $path_docx = "../plancadre/" . $plancadre[0]['No_PlanCadre'] . "_" . $plancadre[0]['CodeCours'] . ".docx"; $php_word->save($path_docx); //header('Location: ../view/view_create_plancadre.php'); } else { if (isset($_POST['open'])) { header('Location: ../view/view_elaboration_plancadre.php'); } } function getPlanCadre($id_plancadre) { return fetchPlanCadreElaboration_PlanCadre($id_plancadre); } function getPrealableCours($id_cours) { return fetchPrealableCours_Id($id_cours); } // convert html to docx