Office dosyalarını PHP ile oluşturma

php logo1 Office dosyalarını PHP ile oluşturma  netHayırlı günler =)

Bu aralar dersler ile fazla yoğunum bu yüzden aksamalar olabilir :) Aşağıda verdiğim kodlar ile .doc .xls .ppt formatında Office dosyalarını oluşturabilirsiniz, bunlar sadece dosyayı belirlediğiniz dizine kaydeder, ufak değişiklik ile kullanıcının bilgisayarınada kaydetmesine izin verebilirsiniz, kodlar;

<?php
$word = new COM(‘word.application’);

$word->Visible = 0;
$word->Documents->Add();
$word->Selection->PageSetup->LeftMargin = ’2′;
$word->Selection->PageSetup->RightMargin = ’2′;

//Font Biçimi
$word->Selection->Font->Name = ‘Verdana’;
$word->Selection->Font->Size = 8;

//Word dosyasının içeriğini girin
$word->Selection->TypeText(‘<a href=http://nurullah.us>Nurullah</a>’);
//.Doc dosyası şeklinde kayıt edilsin
$word->Documents[1]->SaveAs(‘c:\\docs\\test1.doc’);

//Çıkış
$word->quit();
$word->Release();
$word = null;
?>

<?php
$excel = new COM(‘excel.application’);
$excel->Visible = 0;

//Yeni sayfa oluşturur
$wkb = $excel->Workbooks->Add();
$sheet = $wkb->Worksheets(1);

//Bu kod bloğu ‘www.nurullah.us’ değerini 2. satır,  4. kolona ekler
$sheet->activate;
$cell = $sheet->Cells(2,4);
$cell->Activate;
$cell->value = ‘www.nurullah.us’;

$wkb->SaveAs(‘C:\docs\test.xls’);

//çıkış
$wkb->Close(false);
$excel->Workbooks->Close();
$excel->Quit();
?>

<?php
$powerpnt = new COM(‘powerpoint.application’);
//Yeni bir sunu oluşturur
$pres=$powerpnt->Presentations->Add();
//İlk sunumu ekler. ’12′ boş slayttır
$pres->Slides->Add(1,12);
//Başka bir slay ekler, ’10′ clipart ve yazı şeklinde olduğunu ifade eder
$pres->Slides->Add(2,10);
//Yeni bir yazı bloğu ekler
$pres->Slides[1]->Shapes->AddTextbox(1,20,50,300,40);
//Dosyayı .ppt olarak kaydeder
$powerpnt->Presentations[1]->SaveAs(‘C:\Docs\test1.ppt’);

//Çıkış
$powerpnt->quit();
?>

kaynak: rawseo.com

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Yorum yaz

XHTML: Kullanabileceğiniz taglar : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>