예제 #1
0
 /**
  * Re-bind parent
  *
  * @param PHPPowerPoint $parent
  * @return PHPPowerPoint_Slide
  */
 public function rebindParent(PHPPowerPoint $parent)
 {
     $this->_parent->removeSlideByIndex($this->_parent->getIndex($this));
     $this->_parent = $parent;
     return $this;
 }
예제 #2
0
 */
/** Error reporting */
error_reporting(E_ALL);
/** Include path **/
set_include_path(get_include_path() . PATH_SEPARATOR . '../Classes/');
/** PHPPowerPoint */
include 'PHPPowerPoint.php';
// Create new PHPPowerPoint object
echo date('H:i:s') . " Create new PHPPowerPoint object\n";
$objPHPPowerPoint = new PHPPowerPoint();
// Set properties
echo date('H:i:s') . " Set properties\n";
$objPHPPowerPoint->getProperties()->setCreator("Maarten Balliauw")->setLastModifiedBy("Maarten Balliauw")->setTitle("Office 2007 PPTX Test Document")->setSubject("Office 2007 PPTX Test Document")->setDescription("Test document for Office 2007 PPTX, generated using PHP classes.")->setKeywords("office 2007 openxml php")->setCategory("Test result file");
// Remove first slide
echo date('H:i:s') . " Remove first slide\n";
$objPHPPowerPoint->removeSlideByIndex(0);
// Create templated slide
echo date('H:i:s') . " Create templated slide\n";
$currentSlide = createTemplatedSlide($objPHPPowerPoint);
// local function
// Generate sample data for first chart
echo date('H:i:s') . " Generate sample data for first chart\n";
$series1Data = array('Jan' => 133, 'Feb' => 99, 'Mar' => 191, 'Apr' => 205, 'May' => 167, 'Jun' => 201, 'Jul' => 240, 'Aug' => 226, 'Sep' => 255, 'Oct' => 264, 'Nov' => 283, 'Dec' => 293);
$series2Data = array('Jan' => 266, 'Feb' => 198, 'Mar' => 271, 'Apr' => 305, 'May' => 267, 'Jun' => 301, 'Jul' => 340, 'Aug' => 326, 'Sep' => 344, 'Oct' => 364, 'Nov' => 383, 'Dec' => 379);
// Create a bar chart (that should be inserted in a shape)
echo date('H:i:s') . " Create a bar chart (that should be inserted in a chart shape)\n";
$bar3DChart = new PHPPowerPoint_Shape_Chart_Type_Bar3D();
$series1 = new PHPPowerPoint_Shape_Chart_Series('2009', $series1Data);
$series1->setShowSeriesName(true);
$series1->getFont()->getColor()->setRGB('00FF00');
$series1->getDataPointFill(2)->setFillType(PHPPowerPoint_Style_Fill::FILL_SOLID)->setStartColor(new PHPPowerPoint_Style_Color('FF00FF00'));
예제 #3
0
function ppt_export_dots(&$dots, &$more)
{
    $maps = array();
    $w = 960;
    $h = 720;
    $ppt = new PHPPowerPoint();
    $ppt->getProperties()->setTitle($more['title']);
    $ppt->getProperties()->setCreator("Dotspotting");
    # set title here
    # $slide = $ppt->getActiveSlide();
    $ppt->removeSlideByIndex(0);
    # draw the maps
    $dot_per_slide = 1;
    $img_more = array('width' => $w, 'height' => $h, 'dot_size' => 20);
    if (!$dot_per_slide || count($dots) == 0) {
        $maps[] = maps_png_for_dots($dots, $img_more);
    } else {
        $img_more['dot_size'] = 25;
        $img_more['width'] = $img_more['height'];
        $img_more['img_prefix'] = 'ppt';
        # remember: 1 dot per slide
        $_dots = array();
        foreach ($dots as $dot) {
            $_dots[] = array($dot);
        }
        # See this? It's to prevent Dotspoting from accidentally
        # DOS-ing itself.
        $enable_multigets = $GLOBALS['cfg']['wscompose_enable_multigets'];
        if ($dot_per_slide && count($dots) > $GLOBALS['cfg']['wscompose_max_dots_for_multigets']) {
            $GLOBALS['cfg']['wscompose_enable_multigets'] = 0;
        }
        $maps = maps_png_for_dots_multi($_dots, $img_more);
        $GLOBALS['cfg']['wscompose_enable_multigets'] = $enable_multigets;
    }
    # now draw all the maps...
    $count_maps = count($maps);
    for ($i = 0; $i < $count_maps; $i++) {
        $map = $maps[$i];
        $slide = $ppt->createSlide();
        $shape = $slide->createDrawingShape();
        $shape->setName('map');
        $shape->setDescription('');
        $shape->setPath($map);
        $shape->setWidth($w);
        $shape->setHeight($h);
        $shape->setOffsetX(0);
        $shape->setOffsetY(0);
        if ($dot_per_slide) {
            $dot = $dots[$i];
            if (!$dot['id']) {
                continue;
            }
            $_dot = dots_get_dot($dot['id'], $more['viewer_id']);
            if (!$_dot['id']) {
                continue;
            }
            $shape = $slide->createDrawingShape();
            $shape->setName('map');
            $shape->setDescription('');
            $shape->setPath($map);
            $text = $slide->createRichTextShape();
            $text->setHeight($h);
            $text->setWidth($w - $h);
            $text->setOffsetX($h + 20);
            $text->setOffsetY(0 + 20);
            $align = $text->getAlignment();
            $align->setHorizontal(PHPPowerPoint_Style_Alignment::HORIZONTAL_LEFT);
            $cols = array_merge($_dot['index_on'], array('latitude', 'longitude', 'created', 'id'));
            foreach ($cols as $col) {
                $value = trim($dot[$col]);
                if (!$value) {
                    continue;
                }
                $body = $text->createTextRun("{$col}:\n");
                $body->getFont()->setSize(18);
                $body->getFont()->setBold(false);
                # default bold font is not what do say "pretty"
                $body = $text->createTextRun("{$dot[$col]}\n\n");
                $body->getFont()->setSize(14);
                $body->getFont()->setBold(false);
            }
        }
    }
    #
    $writer = PHPPowerPoint_IOFactory::createWriter($ppt, 'PowerPoint2007');
    $writer->save($more['path']);
    $writer = null;
    foreach ($maps as $path) {
        if ($path && !file_exists($path) && !unlink($path)) {
            error_log("[EXPORT] (ppt) failed to unlink {$path}");
        }
    }
    return $more['path'];
}