コード例 #1
0
 function __construct($testResultsHandler)
 {
     Autoloader::register();
     Settings::loadConfig();
     $this->testResultsHandler = $testResultsHandler;
     $this->phpWord = new PhpWord();
 }
コード例 #2
0
ファイル: PhpWord.php プロジェクト: williamamed/Raptor2
 /**
  * Create new instance
  *
  * Collections are created dynamically
  */
 public function __construct()
 {
     // Collection
     Settings::loadConfig();
     $collections = array('Bookmarks', 'Titles', 'Footnotes', 'Endnotes', 'Charts');
     foreach ($collections as $collection) {
         $class = 'PhpOffice\\PhpWord\\Collection\\' . $collection;
         $this->collections[$collection] = new $class();
     }
     // Metadata
     $metadata = array('DocInfo', 'Protection', 'Compatibility');
     foreach ($metadata as $meta) {
         $class = 'PhpOffice\\PhpWord\\Metadata\\' . $meta;
         $this->metadata[$meta] = new $class();
     }
 }
コード例 #3
0
ファイル: Word.php プロジェクト: nhatlang19/elearningONL
 function __construct()
 {
     parent::__construct();
     Autoloader::register();
     Settings::loadConfig();
     Settings::setTempDir(getcwd() . TMPDIR_WORD);
     // 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 (PHP_SAPI == 'cli') {
         return;
     }
 }
コード例 #4
0
@(include_once "Image/Barcode2.php");
require_once $serverRoot . '/classes/PhpWord/Autoloader.php';
header("Content-Type: text/html; charset=" . $charset);
ini_set('max_execution_time', 180);
//180 seconds = 3 minutes
$ses_id = session_id();
if (class_exists('Image_Barcode2')) {
    $bcObj = new Image_Barcode2();
} elseif (class_exists('Image_Barcode')) {
    $bcObj = new Image_Barcode();
}
$labelManager = new OccurrenceLabel();
use PhpOffice\PhpWord\Autoloader;
use PhpOffice\PhpWord\Settings;
Autoloader::register();
Settings::loadConfig();
$collid = $_POST["collid"];
$hPrefix = $_POST['lhprefix'];
$hMid = $_POST['lhmid'];
$hSuffix = $_POST['lhsuffix'];
$lFooter = $_POST['lfooter'];
$occIdArr = $_POST['occid'];
$rowsPerPage = $_POST['rpp'];
$speciesAuthors = array_key_exists('speciesauthors', $_POST) && $_POST['speciesauthors'] ? 1 : 0;
$showcatalognumbers = array_key_exists('catalognumbers', $_POST) && $_POST['catalognumbers'] ? 1 : 0;
$useBarcode = array_key_exists('bc', $_POST) ? $_POST['bc'] : 0;
$useSymbBarcode = array_key_exists('symbbc', $_POST) ? $_POST['symbbc'] : 0;
$barcodeOnly = array_key_exists('bconly', $_POST) ? $_POST['bconly'] : 0;
$action = array_key_exists('submitaction', $_POST) ? $_POST['submitaction'] : '';
$exportEngine = '';
$exportExtension = '';
コード例 #5
0
 /**
  * Test load config
  */
 public function testLoadConfig()
 {
     $expected = array('compatibility' => true, 'zipClass' => 'ZipArchive', 'pdfRendererName' => 'DomPDF', 'pdfRendererPath' => '', 'defaultFontName' => 'Arial', 'defaultFontSize' => 10);
     // Test default value
     $this->assertEquals($expected, Settings::loadConfig());
     // Test with valid file
     $this->assertEquals($expected, Settings::loadConfig(__DIR__ . '/../../../phpword.ini.dist'));
     // Test with invalid file
     $this->assertEmpty(Settings::loadConfig(__DIR__ . '/../../../phpunit.xml.dist'));
 }
コード例 #6
0
ファイル: IndexController.class.php プロジェクト: Orchild/mt
 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');
 }