use PhpOffice\PhpPowerpoint\Shape\Chart\Type\Scatter;
use PhpOffice\PhpPowerpoint\Shape\Chart\Series;
use PhpOffice\PhpPowerpoint\Style\Alignment;
use PhpOffice\PhpPowerpoint\Style\Border;
use PhpOffice\PhpPowerpoint\Style\Color;
use PhpOffice\PhpPowerpoint\Style\Fill;
use PhpOffice\PhpPowerpoint\Style\Shadow;
// Create new PHPPowerPoint object
echo date('H:i:s') . ' Create new PHPPowerPoint object' . EOL;
$objPHPPowerPoint = new PhpPowerpoint();
// Set properties
echo date('H:i:s') . ' Set properties' . EOL;
$objPHPPowerPoint->getProperties()->setCreator('PHPOffice')->setLastModifiedBy('PHPPowerPoint Team')->setTitle('Sample 07 Title')->setSubject('Sample 07 Subject')->setDescription('Sample 07 Description')->setKeywords('office 2007 openxml libreoffice odt php')->setCategory('Sample Category');
// Remove first slide
echo date('H:i:s') . ' Remove first slide' . EOL;
$objPHPPowerPoint->removeSlideByIndex(0);
// Set Style
$oFill = new Fill();
$oFill->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFE06B20'));
$oShadow = new Shadow();
$oShadow->setVisible(true)->setDirection(45)->setDistance(10);
// Generate sample data for chart
echo date('H:i:s') . ' Generate sample data for chart' . EOL;
$seriesData = array('Monday' => 12, 'Tuesday' => 15, 'Wednesday' => 13, 'Thursday' => 17, 'Friday' => 14, 'Saturday' => 9, 'Sunday' => 7);
// Create templated slide
echo EOL . date('H:i:s') . ' Create templated slide' . EOL;
$currentSlide = createTemplatedSlide($objPHPPowerPoint);
// Create a line chart (that should be inserted in a shape)
echo date('H:i:s') . ' Create a line chart (that should be inserted in a chart shape)' . EOL;
$lineChart = new Line();
$series = new Series('Downloads', $seriesData);
 /**
  * Test remove slide by index exception
  *
  * @expectedException Exception
  * @expectedExceptionMessage Slide index is out of bounds.
  */
 public function testRemoveSlideByIndexException()
 {
     $object = new PhpPowerpoint();
     $object->removeSlideByIndex(1);
 }
 public function postFinalpresentation()
 {
     $id_result = Input::get('id_result');
     $resulted = AutomateModel::where('id', $id_result)->first();
     //        $range_name_id = Input::get('range_name_id');
     $result = LogChartModel::where('id_result', $id_result)->get();
     $objPHPPowerPoint = new PhpPowerpoint();
     // Set properties
     //        echo date('H:i:s') . ' Set properties' . EOL;
     $objPHPPowerPoint->getProperties()->setCreator('HAT Developer')->setLastModifiedBy('HAT Developer')->setTitle('Sample 07 Title')->setSubject('Sample 07 Subject')->setDescription('Sample 07 Description')->setKeywords('office 2007 openxml libreoffice odt php')->setCategory('Sample Category');
     // Remove first slide
     //        echo date('H:i:s') . ' Remove first slide' . EOL;
     $objPHPPowerPoint->removeSlideByIndex(0);
     // Set Style
     $oFill = new Fill();
     //        $oFill->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('FFE06B20'));
     $oShadow = new Shadow();
     $oShadow->setVisible(true)->setDirection(45)->setDistance(10);
     //FIRST SLIDE
     $currentSlide = $this->createTemplatedSlide($objPHPPowerPoint);
     // local function
     // Create a shape (text)
     // Create a shape (text)
     $shape = $currentSlide->createRichTextShape();
     $shape->setHeight(600)->setWidth(930)->setOffsetX(40)->setOffsetY(300);
     $shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT)->setMarginLeft(25)->setIndent(-25);
     $shape->getActiveParagraph()->getFont()->setSize(18)->setColor(new Color('E07116'));
     //        $shape->getActiveParagraph()->getBulletStyle()->setBulletType(Bullet::TYPE_BULLET);
     $shape->createTextRun($resulted->info);
     //END OF FIRST SLIDE
     $index = 0;
     //        print_r('here'); exit();
     foreach ($result as $file) {
         //            echo $file->filename.'<br>';
         $currentSlide = $this->createTemplatedSlide($objPHPPowerPoint);
         $shape = $currentSlide->createDrawingShape();
         $shape->setName('Result Chart')->setDescription('PHPPowerPoint logo')->setPath(public_path($file->filename))->setHeight(450)->setWidth(650)->setOffsetX(100)->setOffsetY(160);
         $shape->getShadow()->setVisible(true)->setDirection(45)->setDistance(10);
         $shape = $currentSlide->createRichTextShape();
         $shape->setHeight(50)->setWidth(930)->setOffsetX(20)->setOffsetY(45);
         $shape->getActiveParagraph()->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER)->setMarginLeft(25)->setIndent(-25);
         $shape->getActiveParagraph()->getFont()->setSize(23)->setColor(new Color('D66204'));
         //        $shape->getActiveParagraph()->getBulletStyle()->setBulletType(Bullet::TYPE_BULLET);
         $title = explode(',', $file->title);
         $plot_data = PlotDataModel::where('id_plot', $file->id_plot)->get();
         $plot_name = PlotModel::where('id', $file->id_plot)->first();
         $technya = TechnologyModel::where('id', $plot_name->id_tech)->first();
         if ($technya->name == 'UMTS') {
             $shape->createTextRun(str_ireplace('ch', 'UARFCN', $title[1]) . ' Histogram');
         } else {
             if ($technya->name == 'LTE') {
                 $shape->createTextRun(str_ireplace('ch', 'LARFCN', $title[1]) . ' Histogram');
             } else {
                 $shape->createTextRun(str_ireplace('ch', 'ARFCN', $title[1]) . ' Histogram');
             }
         }
         $co = count($plot_data);
         $shape = $currentSlide->createTableShape(1);
         $shape->setWidth(150);
         $shape->setOffsetX(760);
         $shape->setOffsetY(200);
         $row = $shape->createRow();
         $row->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('EEF0EB'))->setEndColor(new Color('EEF0EB'));
         $row->nextCell()->createTextRun($plot_name->name);
         $i = 2;
         foreach ($plot_data as $rw) {
             $row = $shape->createRow();
             if ($i % 2 == 0) {
                 $row->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('DCEBCA'))->setEndColor(new Color('DCEBCA'));
             } else {
                 $row->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor(new Color('EEF0EB'))->setEndColor(new Color('EEF0EB'));
             }
             $row->nextCell()->createTextRun($rw->start . ' to ' . $rw->end);
             $i++;
         }
         $index++;
     }
     // Save file
     $named = date('Ymdhis_') . $this->toAscii($resulted->info);
     $this->write($objPHPPowerPoint, $named, $this->writers);
     $resultsave = AutomateModel::find($id_result);
     $resultsave->file_result = date('Y-m-d') . '/' . $named;
     $resultsave->save();
     Session::flash('message', SiteHelpers::alert('success', Lang::get('Process has completed, check the result on table bellow')));
     return Redirect::to('/automate');
 }
Esempio n. 4
0
 /**
  * Load PHPPowerPoint Serialized file
  *
  * @param  string        $pFilename
  * @return \PhpOffice\PhpPowerpoint\PhpPowerpoint
  */
 private function loadFile($pFilename)
 {
     $this->oPhpPowerpoint = new PhpPowerpoint();
     $this->oPhpPowerpoint->removeSlideByIndex();
     // Read OLE Blocks
     $this->loadOLE($pFilename);
     // Read pictures in the Pictures Stream
     $this->loadPicturesStream();
     // Read information in the Current User Stream
     $this->loadCurrentUserStream();
     // Read information in the PowerPoint Document Stream
     $this->loadPowerpointDocumentStream();
     return $this->oPhpPowerpoint;
 }