Priti's Technical Corner

April 8, 2014

Download Excel Sheet in Zf2

Filed under: PHP, Zend framework, ZF2 — Tags: , — pritisolanki @ 5:05 pm

 

$response = new \Zend\Http\Response\Stream();
$response->setStream(fopen($myfile, ‘r’)); //read file which you want to download as xls
$response->setStatusCode(200);

$headers = new \Zend\Http\Headers();
$headers->addHeaderLine(“Content-Type: application/vnd.ms-excel; charset=UTF-8″)
->addHeaderLine(‘Content-Disposition’, ‘attachment; filename=my.xls’)
->addHeaderLine( “Content-Transfer-Encoding: binary” )
->addHeaderLine(‘Content-Length’, filesize($myfile));
$response->setHeaders($headers);

There are some cases when you will see extra row in downloaded sheet in header section. To remove those extra empty lines in the downloaded sheet add ob_end_clean();  In start of above code.

Hope this little trick help some of the needy one !

March 1, 2014

How to paginate mysql query output on mysql command line!


Today while working I came across a good trick for mysql command line user. How to paginate the query result. On mysql prompt

mysql> pager more
PAGER set to ‘more’

mysql>select * from products

mysql will start showing you results in paginated way! Small but a good trick in your command line skill kitty !

To reset the pager

mysql> nopager
PAGER set to stdout

Older Posts »

The Silver is the New Black Theme Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 28 other followers

%d bloggers like this: