liuggio / excelbundle Goto Github PK
View Code? Open in Web Editor NEWExcel integration in Symfony2 thanks to https://github.com/PHPOffice/PHPExcel library
Home Page: www.welcometothebundle.com
License: MIT License
Excel integration in Symfony2 thanks to https://github.com/PHPOffice/PHPExcel library
Home Page: www.welcometothebundle.com
License: MIT License
Hello,
I made the install like describ in this readme :
https://github.com/liuggio/ExcelBundle/tree/dc2d489ab5caaa138b9d5777039d760231bf8379
I've this isue:
You have requested a non-existent service "xls.service_xls5".
it was the case ... "L" of Liuggio
Running the test,
\Liuggio\ExcelBundle\Tests\Controller\FakeControllerTest::testStreamAction
the response is flushed showing the content in the output see:
https://travis-ci.org/liuggio/ExcelBundle/jobs/16097353
Please see the following error:
php composer.phar update liuggio/excelbundle
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for liuggio/excelbundle >=1.0.0 -> satisfiable by liuggio/ExcelBundle v1.0.0.
- liuggio/ExcelBundle v1.0.0 requires n3bstreamresponse >=1.0.0 -> no matching package found.
Potential causes:
Read http://getcomposer.org/doc/articles/troubleshooting.md for further common problems.
can you help me?
Thanks :)
When i try to add "liuggio/ExcelBundle" to my composer file, i have this error :
$ php composer.phar update
Updating dependencies
Your requirements could not be solved to an installable set of packages.
Problem 1
- Installation request for liuggio/excelbundle dev-master -> satisfiable by liuggio/ExcelBundle dev-master.
- liuggio/ExcelBundle dev-master requires n3bstreamresponse master -> no matching package found.
would be a great idea to my opinion
regards
Hello,
Your bundle is a great tool, but unfortunatly i have an unexplained bug.
Symfony 2
Call to undefined method PHPExcel_Worksheet::getStyleByColumnAndRow()
here is my code
$phpExcelObject->getActiveSheet()->setCellValueByColumnAndRow(0, $rowStart,$theme->getCode()); //OK
$phpExcelObject->getActiveSheet()->setCellValueByColumnAndRow(1, $rowStart,$theme->getName()); //OK
$phpExcelObject->getActiveSheet()->getStyleByColumnAndRow(1,1); //undefined
the reader is an Excel 2007 reader, and the instance is a PHPExcel_Worksheet.
without this method, all works fine.
Do you have an idea?
i've trie to call another method in debug as setConditionalStyles of the worksheet.php and it works well.
My PHPEXCEL is v1.7.9
Thanks for your support.
Hi,
I'm trying to modify an existing excel using your bundle but I don't get to make it work. I load an existing file which I want to use as a template, and try to modify it filling it with some data, but when I check the generated file, it's empty. What am I making wrong? Could you help me?
This is my controller:
public function modifyExcel()
{
$excel_loader_service = $this->get( 'xls.load_xls5' );
$excel_template_obj = $excel_loader_service->load( DIR. '/../Resources/public/excel/template.xls' );
$excel_service = $this->get( 'xls.service_xls5' );
$excel_service->setExcelObj( $excel_template_obj );
$excel_service->excelObj->setActiveSheetIndex(0)
->setCellValue( 'C6', 'some text' )
->setCellValue( 'D6', 'some text2' )
$response = $excel_service->getResponse();
$response->headers->set( 'Content-Type' , 'application/vnd.ms-excel; charset=utf-8' );
$response->headers->set( 'Content-Disposition', 'attachment;filename=file.xls' );
return $response;
}
Thanks a lot
Hi,
First, great job with this bundle.
I have a question, when i generate a file this
$this->excelService->getStreamWriter()->write($this->dir.$fileName.$this->extension);
the generated file has www-data permissions, is it possible to change it ? Because I need everytime to chmod in cli the file to allow edit.
Hi liuggio i'm using your bundle to make a Symfony2 app, and i'm trying to autogenarate a PDF document from a Excel base.
Here is my code:
public function writePDFAction(){
//Base file
$filename = $this->get('kernel')->getRootDir()."/base.xls";
//Loading of file
$excelLoader = $this->get('xls.load_xls5');
$objPHPExcel = $excelLoader->load( $filename);
/* Some code to fill the excel with data*/
/* Some code to change response file*/
//PDF render Name
$rendererName = \PHPExcel_Settings::PDF_RENDERER_TCPDF;
//Renderer Library Path
$rendererLibraryPath = (dirname(__FILE__) . '../../../../tecnick.com/tcpdf/');
\PHPExcel_Settings::setPdfRenderer(
$rendererName, $rendererLibraryPath
);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
$objWriter->writeAllSheets();
$objWriter->save('php://output');
exit(0);
}
This is my composer file:
"require": {
/* Some bundles */
"liuggio/excelbundle":">=1.0.4",
"tecnick.com/tcpdf": "dev-master" <-- This one is the official bundle for TCPDF,
and is installed on vendor/tecnick.com/tcpdf folder.
}
When i call writePDFAction() i only obtain an error for response:
Unable to load PDF Rendering library
500 Internal Server Error - Exception
What I'm doing wrong, could you help me?
When I try to read an ODS-file, exported from Google Docs , I get the following error:
FatalErrorException: Error: Call to a member function getNamespaces() on a non-object in /var/www/mybundle/vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/OOCalc.php line 341
In the README, for the deps file in the INSTALLATION part, you have
[phpExcel]
git=https://github.com/liuggio/PHPExcel.git
target=phpexcel/lib/
I had to change target to
[phpExcel]
git=https://github.com/liuggio/PHPExcel.git
target=phpexcel
in order to get it working.
Regards,
Mikael
Hello,
I try this usage with a XLS97 format
//create the response
$response = $excelService->getResponse();
$response->headers->set('Content-Type', 'text/vnd.ms-excel; charset=utf-8');
$response->headers->set('Content-Disposition', 'attachment;filename=stdream2.xls');
And it works perfectly with many browsers except with Firefox. When the controller return the response, the client get a blank page without any file attached. What can I do? Thx.
Hello,
I'm using Symfony2 2.0.16. I install your bundle with deps like this:
[n3bStreamresponse]
git=https://github.com/liuggio/Symfony2-StreamResponse.git
target=n3b/src/n3b/Bundle/Util/HttpFoundation/
[phpExcel]
git=https://github.com/liuggio/PHPExcel.git
target=phpexcel/lib/
[liuggioExcelBundle]
git=http://github.com/liuggio/ExcelBundle.git
target=/bundles/liuggio/ExcelBundle
AppKernel:
...
new liuggio\ExcelBundle\liuggioExcelBundle(),
Autoloader:
'liuggio' => DIR.'/../vendor/bundles',
...
'PHPExcel' => DIR.'/../vendor/phpexcel/lib/PHPExcel/Classes',
Then in controller when i try:
$xls_service = $this->get('xls.service_xls5');
I catch this error:
You have requested a non-existent service "xls.service_xls5".
Can you help me, what i'm doing wrong?!
Thanks in advance,
Paulo
You might want to clean up the file structure of the streamwriter repo. The namespace doesn't look terribly pretty in the autoloader.
I also tried with OpenDocument, but I receive about the same error. Then I went to look for the PHP class and I couldn't find any for Open Office documents. Am I missing something here?
I use the latest 2.0 version and I installed it with composer.
We are waiting that PHPExcel will use composer
Hello,
I'm using the extension with Excel generation, and we want now to generate PDF file also.
We di the same kind of script, but as soon as we put :
$excelService = $this->get('xls.service_pdf');
in the code, we get this error :
PDF Rendering library has not been defined.
500 Internal Server Error - Exception
i'm totally ok to define this library, but where should I do that ?
Is there any documentation about that ?
I think we have to add something in config.php, but what and under which title, that's a good question.
I think an example of configuration would be great.
Thank you,
Pierre
PS : I went on PHP Excel website, but I got no explanation I was able to understand enough to apply them on the Symfony Bundle.
Hi,
I tried to install your bundle but after complete installation/configuration, I get this error :
Fatal error: Class 'n3b\Bundle\Util\HttpFoundation\StreamResponse\StreamWriterWrapper' not found in
Question: how did symfony will autoload these specific libraries ? I don't see them in the autoload and also I think that lowercase are not supported by the symfony2 class autoloader..
Regards
I tried to following code to activate caching but it did not seem to make any difference:
// Instruct PHPExcel to cache to APC
$cacheMethod = \PHPExcel_CachedObjectStorageFactory::cache_to_apc;
$cacheSettings = array( 'cacheTime' => 600);
$response = \PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
// ask the service for a Excel object
$phpExcelObject = $this->phpexcel->createPHPExcelObject();
Any help will be highly appreciated.
Best,
Andreas
I have a problem with this Bundle, All seems that works correctly , the excel file is generated correctly but when i try to import to another website that needs this file, seems that the file have no data.
If I open the excel file generated, with Excel all is correct. Then, if I save the same file with excel manually, then I have a correct file and I can import to the other website.
$writer = $this->get('phpexcel')->createWriter($phpExcelObject, 'Excel5');
$filename = 'enviaments/fitxers_codificats/'.$identificador.'_codificat.xls';
$writer->save($filename);
It seems that is a problem with BOM
Downloading XLS files does not work with IE8 (9 works fine), it says that the site cannot be opened.
I currently don't have a clue where the error is ...
Hi, how read .ods files via this bundle?
I use Symfony 2.4 and ExcelBundle 2.0. Installes in local wamp server works like a charm but when moved to production server I get:
"ClassNotFoundException: Attempted to load class "PHPExcel" from the global namespace in /home1/clickapp/public_html/lliga/src/Liuggio/ExcelBundle/Factory.php line 32. Did you forget a use statement for this class?"
I installed the Bundle via composer ("liuggio/ExcelBundle": "v2.0.0"), the services file shows:
parameters:
phpexcel.class: Liuggio\ExcelBundle\Factory
services:
phpexcel:
class: %phpexcel.class%
and, as I said, works fine in local. I don't know what else to check. I hand would be really appreciated.
Many thanks in advance
Hi,
why does this bundle require Symfony 2.4?
"require": {
...
"symfony/framework-bundle": "~2.4",
}
Is it really necessary? I prefer to use Symfony 2.3.x with long term support (LTS) so I'm not able to add ExcelBundle to my project.
Thank you for your work!
How I can read exel file? ExelContainer have only createWriter function.
I have some trouble when trying to install the bundle with composer. I add the dependency according to the instructions, then I run update:
$ composer update
Loading composer repositories with package information
Updating dependencies
- Installing codeplex/phpexcel (1.7.7)
Downloading: connection...
[Composer\Downloader\TransportException]
The "http://nodeload.github.com/markushausammann/PHPExcel/zipball/1.7.7" fi
le could not be downloaded (HTTP/1.1 404 Not Found)
Am I doing something wrong or is this a problem with this bundle's composer.json
or with PHPExcel
?
Thanks
Hi,
there is an error in the usage example, you shouldn't call $response->sendHeaders();
in the controller but just return the response.
Thank you for the bundle!
I need to know how to add new sheet.
I'm trying with setActiveSheetIndex(1) but i have an error.
The wiki is needed to faq
Sorry for my english, my natural language is spanish.
Thank's.
Hello,
I'm trying to check if a cell has a date in it, reading the docs in PHPOffice / PHPExcel they do it like this:
PHPExcel_Shared_Date::isDateTime($objWorksheet->getCellByColumnAndRow($numColumnas,1)->getValue())
is it possible to access that class via this bundle?
thanks in advance
How to read a xls file which is in temporary uploading and not yet stored in file system ?
Following this tips:
We should move to the official PHPExcel repo.
Sorry, if my question is stupid, however I am newbie and I am really Struggle! (even it is a similar to issue13, I could not fix it)
Steps I did:
install bundle at:
..\vendor\bundles\Liuggio
run composer
\vendor\bundles\Liuggio\ExcelBundle>php composer.phar install
error:
Loading composer repositories with package information
Installing dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package n3bstreamresponse master could not be found.
Problem 2
- The requested package phpexcel master could not be found.
Potential causes:
my composer.json
{
"name": "liuggio/excelbundle",
"description": "This is a Symfony2 Bundle helps you to read and write Excel files (including pdf, xlsx, odt), thanks to the PHPExcel library",
"authors": [
{
"name": "Giulio De Donato",
"email": "[email protected]"
},
{
"name": "ExcelBundle Contributors",
"homepage": "https://github.com/liuggio/ExcelBundle#contributors"
}
],
"keywords": ["xls","Excel", "symfony2", "bundle"],
"homepage": "http://www.welcometothebundle.com",
"license": "MIT",
"repositories": {
"n3bStreamresponse": {
"type": "package",
"package": {
"name": "n3bStreamresponse",
"version": "master",
"source": {
"url": "git://github.com/liuggio/Symfony2-StreamResponse.git",
"type": "git",
"reference": "master"
},
"autoload": {
"psr-0": { "n3b\Bundle\Util\HttpFoundation\StreamResponse": "n3b/src" }
},
"target-dir": "n3b/src/n3b/Bundle/Util/HttpFoundation/StreamResponse"
}
},
"phpExcel": {
"type": "package",
"package": {
"name": "phpExcel",
"version": "master",
"source": {
"url": "git://github.com/liuggio/PHPExcel.git",
"type": "git",
"reference": "master"
},
"autoload": {
"classmap": ["lib/"]
}
}
}
},
"require": {
"php": ">=5.3.2",
"symfony/framework-bundle": "2.*",
"n3bStreamresponse": "master",
"phpExcel": "master"
},
"autoload": {
"psr-0": {
"Liuggio\\ExcelBundle": ""
}
},
"target-dir": "Liuggio/ExcelBundle"
}
\MyApp\composer.json
{
"name": "symfony/framework-standard-edition",
"description": "The "Symfony Standard Edition" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.1.",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "dev-master",
"twig/extensions": "dev-master",
"symfony/assetic-bundle": "2.1.",
"symfony/swiftmailer-bundle": "2.1.",
"symfony/monolog-bundle": "2.1.",
"sensio/distribution-bundle": "2.1.",
"sensio/framework-extra-bundle": "2.1.",
"sensio/generator-bundle": "2.1.",
"jms/security-extra-bundle": "1.2.",
"jms/di-extra-bundle": "1.1.*",
"liuggio/excelbundle": "dev-master"
},
"scripts": {
"post-install-cmd": [
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile"
],
"post-update-cmd": [
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
"Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile"
]
},
"config": {
"bin-dir": "bin"
},
"minimum-stability": "dev",
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web"
}
}
Thanks in advanced for the help and patient!
Removing streamed response in favor of symfony StreamedResponse, we have to remove also the composer dependency.
I'm currently having problems with a bug in PHPExcel v1.7.7 that is apparently fixed in 1.7.8. I have requested that Marcus creates a 1.7.8 release in his mirror of the PHPExcel library (which he has agreed to do).
Would you be able to update the dependencies in the bundle to v1.7.8?
Hi there,
I am using Sf 2.1.2 and followed ur steps about installing bundle via composer. Unfortunetely i got some issue with PHPExcel class that my sf doesnt see it when i try to use any service like xls.service_xls5 ( i get "Fatal error: Class 'PHPExcel' not found in..."). I got repositories properly installed in my vendor.
Is there anything more i should do about namespaces/prefixes (like in the deps install way)?
is 'n3b/src/n3b/Bundle/Util/HttpFoundation/StreamResponse' in place or or conjunction with PHPExcel
Hi,
Hope you can help right now Im stuck with this.
When I'm trying to export an excel file created from my controller my app show me this
You have requested a non-existent service "xls.service_xls5".
This is my composer.json
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.3.",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "1.2.",
"twig/extensions": "1.0.",
"symfony/assetic-bundle": "2.3.",
"symfony/swiftmailer-bundle": "2.3.",
"symfony/monolog-bundle": "2.3.",
"sensio/distribution-bundle": "2.3.",
"sensio/framework-extra-bundle": "2.3.",
"sensio/generator-bundle": "2.3.*",
"incenteev/composer-parameter-handler": "~2.0",
"apy/datagrid-bundle": "dev-master",
"friendsofsymfony/user-bundle": "~2.0@dev",
"liuggio/excelbundle": ">=1.0.4",
"mbence/opentbs-bundle": "dev-master"
},
This is a picture of my vendors luiggio route " \vendor\liuggio\ExcelBundle\Liuggio\ExcelBundle "
this is the part of the code I'm getting the error
public function xcelAction(Request $request)
{
if($request->query->get('contrato')){
$contrato = $request->query->get('contrato');
$myTable = $this->Genera_MatrizTipoA($contrato);
}else{
$anio = $request->query->get('anio');
$myTable = $this->Genera_MatrizTipoB($anio);
}
// ask the service for a Excel5
$excelService = $this->get('xls.service_xls5');
Hi,
I got an problem with returning an .xls file if i perform a doctrine repository call in the action where i generate this excel.
i took your example who work fine, but if i call following repository function
"$promotion = $em->getRepository('PromotionCoreBundle:Promotion')->findOneById(22);"
the excel look like this:
http://www.imagebanana.com/view/675r45lg/excel.PNG
I hope you could help me.
If you need anything please ask!
INFO:
Symfony 2.1.3-DEV with Doctrine to an MySQL-DB
Is there a simple way of dynamically changing the filename when using one of the default services (e.g. xls.service_xls5)?
I want to write something like this in my action:
$xlsService = $this->get('xls.service_xls5');
...
$xlsService->getStreamWriter->write( time().'_foo.xls' );
If not, where would be the right place to add this functionality, in the StreamWriterWrapper?
Have an error with that : "$phpExcelObject = $this->get('phpexcel')->createPHPExcelObject($file);"
Notice: Undefined variable: fileHandle
It's this issue : PHPOffice/PHPExcel#199
Change require "phpoffice/phpexcel": "1.7.9" to "phpoffice/phpexcel": "1.7.9-dev" explain here https://phpexcel.codeplex.com/workitem/19830
Could be great to have a functional test.
Hi,
I know you should add the Pragma:public and Cache-Control: max-age=1 headers for downloads to work in IE8, but it seems that if your site uses ssl, there is another error.
I am unable to download any excel generated with the excel bundle over https in IE8. Firefox and Chrome work fine.
Any ideas?
Hi, i have the following issue. Please help me. My Symfony project version is 2.3.19.
I'm using ExcelBundle ~2.1
When trying to integrate the Bundle into Symfony 2.1.7 the composer prints out following error:
liuggio/ExcelBundle v1.0.2 requires irongit/symfony2-stream-response dev-master -> no matching package found.
liuggio/ExcelBundle v1.0.0 requires n3bstreamresponse >=1.0.0 -> no matching package found.
I'm looking for an easy way to get all entities in one Excel file, with all fields added to it automatically.
I think I've found the functions for the job, but maybe someone did this before and wants to share it's code?
$rows = $em->getRepository('AcmeBundle:Users')->findAll();
$columns = $em->getClassMetadata('AcmeBundle:Users')->getFieldNames();
Hello,
I need to create more than one Excel file in one request (They are then bundled in a .zip which is then sent for download).
Sub-requests are not that cool since I don't need them (plus I'm not sure the container will be re-instantiated even with a sub-request) and short from reinitializing the service myself, it's impossible to generate more than one excel at a time.
If the possibility is here (The services.yml is a bit huge a hard to read to me... I may have missed something) could it be possible to document it please?
Thanks for your help and Kudo for the bundle!
Can you add a tag for the last commit that still works with symfony2.0 for those of us stuck in 2.0 land?
Hi!
I had installation problem. It was wrong path to namespaces. Please check all path to files and namespaces. And it will be amazing if you add comments in you code.
autoload.php
In your code
'n3b\Bundle\Util\HttpFoundation\StreamResponse' => DIR.'/../vendor/n3b/src',
'liuggio' => DIR.'/../vendor/bundles',
'PHPExcel' => DIR.'/../vendor/phpexcel/lib/PHPExcel/Classes',
working copy in my code
'n3b' => __DIR__.'/../vendor/n3b/src',
'liuggio' => __DIR__.'/../vendor/bundles',
'PHPExcel' => __DIR__.'/../vendor/phpexcel/lib/lib/PHPExcel/Classes',
And in directory vendor\n3b\src\n3b\Bundle\Util\HttpFoundation in all files need change namespaces, need to remove '\StreamResponse'
If I'm not right please, let me know.
I'm currently using Excel5 to create a PHPExcel writer, and everything works perfectly. However, when I change the parameter from Excel5 to Excel2007 for the writer, I get the following error: "Could not close zip file php://output."
My code inside my controller looks like this:
$phpExcelObject = $this->get('phpexcel')->createPHPExcelObject();
.
.
.
// create the writer
$writer = $this->get('phpexcel')->createWriter($phpExcelObject, 'Excel2007');
// create the response
$response = $this->get('phpexcel')->createStreamedResponse($writer);
// code continues to add response headers
.
.
return $response;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.