使用php excel将徽标添加到Excel工作表

前端之家收集整理的这篇文章主要介绍了使用php excel将徽标添加到Excel工作表前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用下面的代码列表在生成的Excel工作表上添加徽标图像,但由于某种原因它什么都不做
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
    $objPHPExcel = $objReader->load("workbooks/" . $labref . "/" . $labref . ".xlsx");
    $objPHPExcel->getActiveSheet(2);
    $objWorkSheet = $objPHPExcel->createSheet();
    $objWorkSheet->setTitle("Sample Summary");        
    $dir1 = "exclusive_image";

       $objDrawing = new PHPExcel_Worksheet_Drawing();
                $objDrawing->setName("name");
                $objDrawing->setDescription("Description");
                $objDrawing->setPath(base_url().'exclusive_image/nqcl.png');
                $objDrawing->setCoordinates('A1');
                $objDrawing->setWorksheet($objWorkSheet->getActiveSheet(2));
        $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
        $objWriter->save("workbooks/" . $labref . "/" . $labref . ".xlsx");
添加徽标非常简单,请尝试以下代码.
$objPHPExcel = new PHPExcel();
$sheet = $objPHPExcel->setSheetIndexAndTitle(1,"YOUR_SHEET_TITLE"); // first sheet
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('logo');
$objDrawing->setDescription('logo');
$logo = base_path() . '/images/logo.png'; // Provide path to your logo file
$objDrawing->setPath($logo);
$objDrawing->setOffsetX(8);    // setOffsetX works properly
$objDrawing->setOffsetY(300);  //setOffsetY has no effect
$objDrawing->setCoordinates('B1');
$objDrawing->setHeight(75); // logo height
$objDrawing->setWorksheet($sheet);
原文链接:https://www.f2er.com/php/133170.html

猜你在找的PHP相关文章