Giter Club home page Giter Club logo

Comments (4)

PowerKiKi avatar PowerKiKi commented on May 9, 2024

I confirm that the following code wil output an xlsx with an image, but an xls without an image (assuming a test.jpg beside the script) as seen in LibreOffice 5:

<?php

require __DIR__ . '/vendor/autoload.php';

$spreadsheet = new PhpOffice\PhpSpreadsheet\Spreadsheet();

$drawing = new PhpOffice\PhpSpreadsheet\Worksheet\Drawing(); 
$drawing->setPath('test.jpg');
$drawing->setWorksheet($spreadsheet->getActiveSheet());

$writer = new PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
$writer->save('test.xlsx');

$writer = new PhpOffice\PhpSpreadsheet\Writer\Xls($spreadsheet);
$writer->save('test.xls');

Unfortunately I won't have time to investigate further. But if you could determine exactly what commit broke the feature, it would be very helpful.

from phpspreadsheet.

korvinko avatar korvinko commented on May 9, 2024

I found strange place when debug this problem in PhpOffice\PhpSpreadsheet\Writer\Excel5:
image

Switch never execute any switch block because expected that class will start with "\" in but class name start from latin character. I guess it can be reason of this issue but not check it.

from phpspreadsheet.

korvinko avatar korvinko commented on May 9, 2024

I checked it, drawing now attached.
Submited PR with fix: #61

from phpspreadsheet.

atiqShafi avatar atiqShafi commented on May 9, 2024

My need is same, I have tried from view with html img tag but it does not worked. then I have tried below methods :

public static function beforeSheet(BeforeSheet $event) {
    
    $drawing = new Drawing();
    $drawing->setPath(public_path('sent_files/35/100_1521622088/35_final_card.png'));
    $drawing->setCoordinates('A3');
    $drawing->setWidth(150);
    $drawing->setHeight(100);
    $drawing->setWorksheet($event->sheet);
}

I am getting bellow error :

Type error: Argument 1 passed to PhpOffice\\PhpSpreadsheet\\Worksheet\\BaseDrawing::setWorksheet() must be an instance of PhpOffice\\PhpSpreadsheet\\Worksheet\\Worksheet or null, instance of Maatwebsite\\Excel\\Sheet given, called in /php_projects/my-details/app/Exports/ReportDataFromSbExport.php on line 113

from phpspreadsheet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.