Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > บทความจากสมาชิก > Using PHPWord library to create microsoft word by PlaKrirM



 
Clound SSD Virtual Server

Using PHPWord library to create microsoft word by PlaKrirM

สร้างเอกสาร MS Word ด้วย PHP Library ที่ชื่อว่า PHPWord จาก http://phpword.codeplex.com อาจจะยังมีบั๊กอยู่บ้าง แต่ถ้าไม่ใช้อะไรที่ Advance มากไป ก็คงไม่เจอหรอก

phpword_logo

ก่อนกลับบ้านปีใหม่ จัดบทความไว้ให้อ่านเล่นกันสักบท

อีกทางเลือกสำหรับการสร้างเอกสาร MS Word คือ
PHP Library ที่ชื่อว่า PHPWord เป็น library จาก codeplex.com

PHPWord ต้องการระบบดังนี้
- php 5.2 ขึ้นไป
- zip extension
- xml extension
- ถ้าจะเปิดไฟล์ที่สร้างขึ้นด้วย PHPWord ใน MS Word ที่ต่ำว่า 2007 ต้องลง Microsoft Office Compatibility Pack ด้วย โหลดได้จาก www.microsoft.com

วิธีลงง่ายๆ โหลดมาแล้ว แตกไฟล์แล้ว copy ไปวางที่ folder งานของคุณ ซึ่งจะมีโฟลเดอร์และไฟล์ดังนี้
1. Folder Examples
2. Folder PHPWord
3. File PHPWord.php

จากนั้น มาเริ่มสร้างไฟล์ .docx ไฟล์แรกกันเลย

Text_PHPWord.php (Save ไว้ในระดับเดียวกันกับ PHPWord.php)
require_once 'PHPWord.php';
$PHPWord = new PHPWord();
$SectionStyle1 = array(
	'orientation' => null,
	'marginLeft' => 900,
	'marginRight' => 900,
	'marginTop' => 900,
	'marginBottom' => 900
);
$Section1 = $PHPWord->createSection($SectionStyle1);
$FontStyle1 = array('color'=>'FF0000', 'size'=>18, 'bold'=>true);
$Section1->addText('Portrait Oriented Section', $FontStyle1);

$Section2 = $PHPWord->createSection();
$SectionStyle2 = $Section2->getSettings();
$SectionStyle2->setLandscape();
$SectionStyle2->setMarginLeft(900);
$SectionStyle2->setMarginRight(900);
$SectionStyle2->setMarginTop(900);
$SectionStyle2->setMarginBottom(900);

$FontStyle2 = array('color'=>'000000', 'size'=>18, 'bold'=>true);
$Section2->addText('Landscape Oriented Section', $FontStyle2);
$Section2->addTextBreak();
$FontStyle3 = array('color'=>'AAAAAA', 'size'=>15);
$Section2->addText('Text 1', $FontStyle3);
$Section2->addTextBreak();
$FontStyle4 = array('color'=>'CCCCCC', 'size'=>13);
$Section2->addText('Text 2', $FontStyle4);

$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('Text_PHPWord.docx');


จากนั้นก็ดูเองนะครับ อิอิ ดาวน์โหลด Docs ตรงนี้ตามรูปด้านล่างนี้นะ

load_doc

ขอได้รับความปราถนาดีจาก PlaKriM



บทความอื่น ๆ เกี่บวกับ PHP & Word

Go to : PHPWord Library สร้างไฟล์ Word Document ด้วย PHP (Word 2003 , Word 2007)
Go to : PHP Word (Word.Application) : การใช้งาน PHP กับ Word : การเรียกใช้งาน Microsoft Word


Reference : http://phpword.codeplex.com/





   
Share
Bookmark.   

  By : PlaKriM
  Article : บทความเป็นการเขียนโดยสมาชิก หากมีปัญหาเรื่องลิขสิทธิ์ กรุณาแจ้งให้ทาง webmaster ทราบด้วยครับ
  Score Rating :
  Create Date : 2010-12-28
  Download : No files
Sponsored Links
ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่