symfony 使用excel方法
来源:互联网 发布:ubuntu全中文包 编辑:程序博客网 时间:2024/06/05 22:44
ctually, to do it right you need to follow next steps:
- Edit your deps file and add dependency from the PHPExcel
[PHPExcel]git=http://github.com/PHPOffice/PHPExcel.gittarget=/phpexcelversion=origin/master
Run php bin/vendors install in order to install all missing dependencies (PHPExcel in our case)
Update prefixes section in app/autoload.php:
$loader->registerPrefixes(array( // ... 'PHPExcel' => __DIR__.'/../vendor/phpexcel/Classes',));
- Done. Now, you can use it in your bundle's controller (code based on PHPExcel example from Tests/01simple-download-xls.php):
<?phpnamespace Demo\MyBundle\Controller;use Symfony\Bundle\FrameworkBundle\Controller\Controller;use Symfony\Component\HttpFoundation\Response;use PHPExcel;use PHPExcel_IOFactory;class DemoController extends Controller{ public function demoAction() { $response = new Response(); // Create new PHPExcel object $objPHPExcel = new PHPExcel(); // Set document properties $objPHPExcel->getProperties()->setCreator("Me") ->setLastModifiedBy("Someone") ->setTitle("My first demo") ->setSubject("Demo Document"); // Add some data $objPHPExcel->setActiveSheetIndex(0) ->setCellValue('A1', 'Hello') ->setCellValue('B2', 'world!') ->setCellValue('C1', 'Hello') ->setCellValue('D2', 'world!'); // Set active sheet index to the first sheet $objPHPExcel->setActiveSheetIndex(0); // Redirect output to a client’s web browser (Excel5) $response->headers->set('Content-Type', 'application/vnd.ms-excel'); $response->headers->set('Content-Disposition', 'attachment;filename="demo.xls"'); $response->headers->set('Cache-Control', 'max-age=0'); $response->prepare(); $response->sendHeaders(); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save('php://output'); exit(); }}
0 0
- symfony 使用excel方法
- symfony中的forword方法
- symfony 加载插件方法
- symfony分页实现方法
- PHP框架symfony使用
- symfony安装使用
- symfony使用oauth
- symfony安装使用
- symfony使用过程
- symfony
- symfony
- Symfony
- symfony
- symfony
- symfony
- symfony
- Symfony
- Symfony
- SELinux/SEAndroid -- 基础知识介绍
- InstallShield使用——几个技术问题介绍
- 大数阶乘
- 修改rabbitmq Web UI 监控页面的端口
- LoadRunner获取登录验证码
- symfony 使用excel方法
- swift 快速奔跑的兔几 本节的内容是:animations
- 黑马程序员——Foundation框架—NSArray
- 【SHELL】使用ps如何准确地打印出某个用户的进程
- php错误屏蔽
- symfony 加载插件方法
- ArcGIS开发权威指南 上架
- 5个数求最值
- 关于java.sql.SQLException: Incorrect string value的解决方法