Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 5th, 2012  |  syntax: None  |  size: 1.36 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. how to correctly display double quotations using PHPWord?
  2. include_once "../PHPWord.php";
  3. include_once "../debug.php";
  4.  
  5. $file_name = "filename.docx";
  6. header("Cache-Control: public");
  7. header("Content-Description: File Transfer");
  8. header("Content-Disposition: attachment; filename=$file_name");
  9. //header("Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document");
  10. header("Content-Type: application/vnd.ms-word; charset=utf-8");
  11. header("Content-Transfer-Encoding: binary");
  12.  
  13. $index = 1218;
  14. $mysqli = new mysqli("host","user","pass","database");
  15. $mysqli->set_charset("utf8");
  16. $qry1 = "SELECT * FROM table WHERE index = $index ORDER BY field DESC";
  17. $qry2 = "SELECT * FROM table2 WHERE index = $index";
  18.  
  19. $PHPWord = new PHPWord();
  20. $section = $PHPWord->createSection();
  21.  
  22. $section->addText("Connection Encoding: ".$mysqli->character_set_name());
  23. $section->addText("resuls");
  24.  
  25. $res1 = $mysqli->query($qry1);
  26. while($row = $res1->fetch_assoc()){
  27.     $section->addText($row[name]);
  28.     $section->addText(mb_detect_encoding($row['name']));
  29. }
  30.  
  31. $section->addText("results2");
  32.  
  33. $res2 = $mysqli->query($qry2);
  34. while($row = $res2->fetch_assoc()){
  35.     $section->addText(trim($row['title']));
  36.     $section->addText(mb_detect_encoding($row['title']));
  37. }
  38.  
  39. $objWriter = PHPWord_IOFactory::createWriter($PHPWord,'Word2007');
  40. $objWriter->save('php://output');
  41. exit;
  42.        
  43. book:"Book Title"