01simple local test does not issue file dowload window

Topics: Developer Forum, User Forum
Aug 31, 2009 at 5:13 AM

As title, my local testing can dowload 01simple.xlsx as well.

but in executing, it does not similar as online test as  small file dowloa windown prompt?

So the 01simple.xlsx save to test/01simple.xlsx

I am not sure this function provide windown prompt to operate file path ans name to be saved?

$objWriter->save(str_replace('.php', '.xlsx', __FILE__));

Kind Regards

Julia

New to PHPExcel

 

  

Coordinator
Aug 31, 2009 at 9:15 AM

Correct. The scripts in the test directory all write their files to the server rather than offering them for download.

The simple way to download the file instead is to use

$objWriter->save('php://output');

Sep 1, 2009 at 1:12 AM
Thanks MarkBaker,

$objWriter->save('php://output'); // does not pop out windown prompt

Are they as same file as 01simple.php online test or dowload test?

Kind Regards

On Mon, Aug 31, 2009 at 7:15 PM, MarkBaker <notifications@codeplex.com> wrote:

From: MarkBaker

Correct. The scripts in the test directory all write their files to the server rather than offering them for download.

The simple way to download the file instead is to use

$objWriter->save('php://output');

Read the full discussion online.

To add a post to this discussion, reply to this email (PHPExcel@discussions.codeplex.com)

To start a new discussion for this project, email PHPExcel@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Sep 1, 2009 at 1:20 AM
PS, here is screen cut for online and local teat

 
On Tue, Sep 1, 2009 at 11:13 AM, juliayan <notifications@codeplex.com> wrote:

From: juliayan

Thanks MarkBaker,

$objWriter->save('php://output'); // does not pop out windown prompt

Are they as same file as 01simple.php online test or dowload test?

Kind Regards

On Mon, Aug 31, 2009 at 7:15 PM, MarkBaker <notifications@codeplex.com> wrote:

From: MarkBaker

Correct. The scripts in the test directory all write their files to the server rather than offering them for download.

The simple way to download the file instead is to use

$objWriter->save('php://output');

Read the full discussion online.

To add a post to this discussion, reply to this email (PHPExcel@discussions.codeplex.com)

To start a new discussion for this project, email PHPExcel@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Read the full discussion online.

To add a post to this discussion, reply to this email (PHPExcel@discussions.codeplex.com)

To start a new discussion for this project, email PHPExcel@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Sep 1, 2009 at 1:35 AM
c
George Zheng


On Tue, Sep 1, 2009 at 9:20 AM, juliayan <notifications@codeplex.com> wrote:

From: juliayan

PS, here is screen cut for online and local teat

 
On Tue, Sep 1, 2009 at 11:13 AM, juliayan <notifications@codeplex.com> wrote:

From: juliayan

Thanks MarkBaker,

$objWriter->save('php://output'); // does not pop out windown prompt

Are they as same file as 01simple.php online test or dowload test?

Kind Regards

On Mon, Aug 31, 2009 at 7:15 PM, MarkBaker <notifications@codeplex.com> wrote:

From: MarkBaker

Correct. The scripts in the test directory all write their files to the server rather than offering them for download.

The simple way to download the file instead is to use

$objWriter->save('php://output');

Read the full discussion online.

To add a post to this discussion, reply to this email (PHPExcel@discussions.codeplex.com)

To start a new discussion for this project, email PHPExcel@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Read the full discussion online.

To add a post to this discussion, reply to this email (PHPExcel@discussions.codeplex.com)

To start a new discussion for this project, email PHPExcel@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Read the full discussion online.

To add a post to this discussion, reply to this email (PHPExcel@discussions.codeplex.com)

To start a new discussion for this project, email PHPExcel@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Developer
Sep 1, 2009 at 2:57 AM

juliayan, can you post your complete code so we can inspect?

Sep 1, 2009 at 3:15 AM
code as same as 01simple.php
but it test with Zend Framework, does it effect?

On Tue, Sep 1, 2009 at 12:57 PM, koyama <notifications@codeplex.com> wrote:

From: koyama

juliayan, can you post your complete code so we can inspect?

Read the full discussion online.

To add a post to this discussion, reply to this email (PHPExcel@discussions.codeplex.com)

To start a new discussion for this project, email PHPExcel@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Developer
Sep 1, 2009 at 3:42 AM

Can you try to run this script:

<?php
error_reporting(E_ALL);

require_once '../Classes/PHPExcel.php';
require_once '../Classes/PHPExcel/IOFactory.php';

$excel = new PHPExcel();
$writer = PHPExcel_IOFactory::createWriter($excel, 'Excel2007');

header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="myfile.xlsx"');
header('Cache-Control: max-age=0');
$writer->save('php://output');
exit;

?>

Sep 3, 2009 at 2:07 AM

Hi koyama

Thanks for your help, but still in same probelm

it test with Zend Framework, does it effect?

--------- 3 ways to try in the same probelm

// Save Excel 2007 file
$number =1;
echo date('H:i:s') . " Write to Excel2007 format\n";
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');

// way 1
//$objWriter->save(str_replace('.php', '.xlsx', __FILE__));

// way 2
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="myfile.xlsx"');
header('Cache-Control: max-age=0');

//way 3
/*
header("Pragma: public");
header("Expires: 0");
header("Cache-Control:must-revalidate, post-check=0, pre-check=0");
header("Content-Type:application/force-download");
header("Content-Type:application/vnd.ms-execl");
header("Content-Type:application/octet-stream");
header("Content-Type:application/download");
header('Content-Disposition:attachment;filename="order_'.$number.'.xls"');
header("Content-Transfer-Encoding:binary");
*/
$objWriter->save('php://output');

Developer
Sep 3, 2009 at 2:19 AM

>> it test with Zend Framework, does it effect?

Sorry, I have not tried Zend Framework so I don't know. When you say that you don't get the file download prompt, what do you get instead. Can you describe exactly what you see in the browser? For example, do you get any error messages?

Sep 3, 2009 at 5:22 AM
Well, here 2 images for results as you see
1, online test
2, local test
 
Thanks
On Thu, Sep 3, 2009 at 12:19 PM, koyama <notifications@codeplex.com> wrote:

From: koyama

>> it test with Zend Framework, does it effect?

Sorry, I have not tried Zend Framework so I don't know. When you say that you don't get the file download prompt, what do you get instead. Can you describe exactly what you see in the browser? For example, do you get any error messages?

Read the full discussion online.

To add a post to this discussion, reply to this email (PHPExcel@discussions.codeplex.com)

To start a new discussion for this project, email PHPExcel@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Developer
Sep 3, 2009 at 1:33 PM

Ugg... The images in your forum post were lost. Can you try to put the images online somewhere and link to them?

Sep 4, 2009 at 1:21 AM

01simple test online
 
01simple test local

 
On Thu, Sep 3, 2009 at 11:34 PM, koyama <notifications@codeplex.com> wrote:

From: koyama

Ugg... The images in your forum post were lost. Can you try to put the images online somewhere and link to them?

Read the full discussion online.

To add a post to this discussion, reply to this email (PHPExcel@discussions.codeplex.com)

To start a new discussion for this project, email PHPExcel@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Developer
Sep 4, 2009 at 1:50 AM

Ok, I understand. The examples on this website are not running the actual scripts. They are just static links to Excel files.

Try to run this script instead of 01simple.php on you local server:

 

<?php
// 01simple.php -- Send output to client browser instead of saving to disk

error_reporting(E_ALL); ini_set('display_errors', '1'); require_once '../Classes/PHPExcel.php'; require_once '../Classes/PHPExcel/IOFactory.php'; $objPHPExcel = new PHPExcel(); $objPHPExcel->getProperties()->setCreator("Maarten Balliauw") ->setLastModifiedBy("Maarten Balliauw") ->setTitle("Office 2007 XLSX Test Document") ->setSubject("Office 2007 XLSX Test Document") ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.") ->setKeywords("office 2007 openxml php") ->setCategory("Test result file"); $objPHPExcel->setActiveSheetIndex(0) ->setCellValue('A1', 'Hello') ->setCellValue('B2', 'world!') ->setCellValue('C1', 'Hello') ->setCellValue('D2', 'world!'); $objPHPExcel->getActiveSheet()->setTitle('Simple'); $objPHPExcel->setActiveSheetIndex(0); header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="01simple.xlsx"'); header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007'); $objWriter->save('php://output'); exit; ?>

Notice that I have included headers and removed all echo statements. There must be no echo statements when you output directly to client browser.

Let us know if it is working for you. If it is not working, post screen shot of what you get.

Sep 4, 2009 at 3:35 AM

Thanks lots Koyama, I got it ^_*

PS, why the same message above send from gmail where fail note from  notifications@codeplex.com

error: Your email contained no postable message text.

Sep 11, 2009 at 12:30 PM

Hello Koyama/Juliayan,

I am able to run the code successfully shared by Koyama (Thanks Koyama for that). But I am facing issues in opening the xlsx file in Excel 2007. I am getting following error message:

Excel found unreadable content in "01simple.xlsx". Do you want to recover the contents of this workbook? If you trust the source of this workbook, click Yes.

On click of yes, it gives me another error message:

Excel cannot open the file "01simple.xlsx" because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.

 

I am running Excel 2007 on Windows Vista platform.

Can you guys please help me with this issue urgently.


Thanks a lot

Rajeev

Sep 11, 2009 at 1:00 PM

Please note that I have tried this on my local system with PHP 5.2.0 and also on my windows hosting server with PHP 5.2.5

 

Coordinator
Sep 11, 2009 at 1:43 PM
Edited Sep 11, 2009 at 1:44 PM

@mkrajeev

From the FAQ

Excel 2007 can not open the file generated by PHPExcelWriter2007 on Windows

Excel found unreadable content in '*.xlsx'. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click Yes.

The php_zip extension on Windows coming with PHP 5.2.8 contains an error when creating ZIP files. The version that can be found on http://snaps.php.net/win32/php5.2-win32-latest.zip should work at all times.

Alternatively, upgrading to at least PHP 5.2.9 should solve the problem.

 

I know you're running earlier versions of PHP, but it may still be the same corrupt php_zip

Sep 11, 2009 at 1:55 PM

Thanks Mark for your prompt response to the problem.

I can upgrade the php version in my local system but not sure if my hosting provider will do that for me.

Can you please advise if there are any alternatives?

 

Thanks

Rajeev

 

Coordinator
Sep 11, 2009 at 4:38 PM

I'd suggest simply updating the php_zip.dll on your local server first, and testing there to see if it works

Developer
Sep 11, 2009 at 11:32 PM

@mkrajeev: If upgrading PHP does not work, try to upload the file somewhere so we can inspect it. There could be an error in your code. For example, if you have spaces before your opening <?php tag, this will cause the file to be corrupt.

Nov 6, 2009 at 11:08 AM

look here if this answer your question http://phpexcel.codeplex.com/Thread/View.aspx?ThreadId=38992