Question

I need to compose some xls(x) files, but don't know a good extension (module) for Kohana 3.2.2 framework, I know about PHPExcel ( a lot of links and repos I found ), but the most of them based on a PEAR library, that I'm not supporting in my project, maybe someone knows a good solution for that?

So I need a link with good documentation and module for that. Thanks.

UPD.

I made a first test for PHPExcel Library through this code:

$objPHPExcel = new PHPExcel();
            $objPHPExcel->setActiveSheetIndex(0)
                ->setCellValue('A1', 'Hello')
                ->setCellValue('B1', 'world!');

            // header("Content-Type:application/vnd.ms-excel");
            // header("Content-Disposition:attachment;filename='simple.xls'");

            $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel,'Excel2007');    
            $name = $objWriter->save('docs/MyExcel12.xlsx');

            $file = $_SERVER['DOCUMENT_ROOT']."/docs/MyExcel12.xlsx";
            /*      
            if (file_exists($file))
            {
                header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
                header('Content-Disposition: attachment; filename='.basename($file));
                header('Content-Length: '.filesize($file));
                readfile($file);                
            }*/

            if (file_exists($file))
            {
                header('Content-Type: application/octet-stream');
                header('Content-Disposition: attachment; filename='.basename($file));
                header('Content-Length: '.filesize($file));
                readfile($file);
            }

I see a file that was created after this code apply, but browser not forcing download it, as u can see I've used different headers, but do not have my file out. Help!?

UPD Also I have used:

            header("Content-Type:application/vnd.ms-excel");
            header("Content-Disposition:attachment;filename='simple.xls'");

            $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel,'Excel5');   
            $objWriter->save('php://output');

But have error (instead of file):

net::ERR_FILE_NOT_FOUND

I made a redirect, but as I think it is not a solution anyway:

    $this->request->redirect('docs/new.xlsx');
Was it helpful?

Solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top