Giter Club home page Giter Club logo

Comments (5)

liuggio avatar liuggio commented on August 22, 2024

Hi jochenhilgers
you should create a new StreamWriter the most silimar is FileWriter
https://github.com/liuggio/Symfony2-StreamResponse/blob/master/FileWriter.php

<?php

namespace n3b\Bundle\Util\HttpFoundation\StreamResponse;

use Symfony\Component\HttpFoundation\File\File;

/**
* Description of FileWriter
*
* @author neb
*/
class FileWriter implements StreamWriterInterface
{
    protected $file;

    public function __construct($path = null)
    {
        $this->file = new File($path);
    }

    public function write()
    {
        $this->file->openFile()->fpassthru();
    }

    public function getFile()
    {
        return $this->file;
    }
}

from excelbundle.

liuggio avatar liuggio commented on August 22, 2024

Hi jochenhilgers

you should modify the FileWriter, adding a setFile
https://github.com/liuggio/Symfony2-StreamResponse/blob/master/FileWriter.php
something like:

<?php

namespace n3b\Bundle\Util\HttpFoundation\StreamResponse;

use Symfony\Component\HttpFoundation\File\File;

/**
* Description of FileWriter
*
* @author neb
*/
class FileWriter implements StreamWriterInterface
{
    protected $file;

    public function __construct($path = null)
    {
        if !null ...
           $this->file = new File($path);
    }

    function setPath ...

}

Then you should modify the
https://github.com/liuggio/ExcelBundle/blob/master/Resources/config/services.yml

adding 2 new services

xls.stream_writer_file_xls5:
  #similar to   xls.stream_writer_output_xls5:

#service to call
    xls.service_xls5_to_file:
        class: %xls.service.class%
        arguments: [@xls.phpexcel, @xls.stream_writer_file_xls5, %xls.stream_response.class%]

What do you think?

from excelbundle.

jochil avatar jochil commented on August 22, 2024

In the action this would look like this?

$xlsService =  $this->get('xls.service_xls5');
...
$xlsService->getStreamWriter()->setPath( time().'_foo.xls' );
$xlsService->getStreamWriter->write();

Alternatively we could extend the StreamWriterInterface->write() and StreamWriterWrapper->write() with some conditonal parameter:

public function write( $stream=null );

For me this seems to be more intuitive...what do you think?

from excelbundle.

liuggio avatar liuggio commented on August 22, 2024

good option as well!

from excelbundle.

jochil avatar jochil commented on August 22, 2024

I added the parameter: liuggio/Symfony2-StreamResponse#1

from excelbundle.

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.