ดาวโหลดไฟล์ php class - html2doc.php คลิก
https://www.ninenik.com/download/html2doc.zip
ทดสอบสร้างไฟล์ word จาก html tag
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <?php include 'html2doc.php' ; $htmltodoc = new HTML_TO_DOC(); $html = "<font size=2>Hello World</font>" ; $htmltodoc ->createDoc( $html , 'test' ); // กำหนดชื่อไฟล์ว่า test // ผลลัพธ์ code จะทำการสร้างไฟล์ชื่อ test.doc ที่มีข้อความว่า Hello World // ไว้ใน path เดียวกับไฟล์ code // การใช้งานใน server จำเป็นต้องเปิด permission โฟลเดอร์ที่มีการเรียกใช้เพื่อ ให้สามารถสร้างไฟล์ได้ // หากต้องการให้ทำการดาวน์โหลดไฟล์หลังจากสร้างไฟล์แล้ว // สามารถกำหนดเป็นดังนี้ // $htmltodoc->createDoc($html,'test',true); // การกำหนดขนาดตัวอักษรใน html ให้เหมาะกับเอกสาร word ควรกำหนดเป็น html tag เป็น <font size="2"></font> // เหมาะกับ html ไฟล์ที่มีลักษณะเป็นตาราง // ยังมีข้อจำกัดเกี่ยวกับการแทรกรูปภาพ // หากจะใช้รูปภาพ จะต้องกำหนดตำ path ของรูปภาพ เช่น http://www.example.com/image/test.jpg ?> |
การใช้งาน สร้างไฟล์ word จาก url
1 2 3 4 5 | <?php include 'html2doc.php' ; $htmltodoc = new HTML_TO_DOC(); ?> |
การใช้งาน สร้างไฟล์ word จาก html ไฟล์
1 2 3 4 5 6 | <?php include 'html2doc.php' ; $htmltodoc = new HTML_TO_DOC(); $html = file_get_contents ( "form.html" ); $htmltodoc ->createDoc( $html , 'test' ); ?> |
ตัวอย่างไฟล์ ที่สร้างจาก html2doc class
Test.doc