Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect excel response with doctrine select #29

Closed
Munsio opened this issue Oct 31, 2012 · 11 comments
Closed

Incorrect excel response with doctrine select #29

Munsio opened this issue Oct 31, 2012 · 11 comments

Comments

@Munsio
Copy link

Munsio commented Oct 31, 2012

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

@liuggio
Copy link
Owner

liuggio commented Oct 31, 2012

Hi, I think that there are some missing information between the findOneById and the way you create xls.
IMHO there's a bug in your code, try to add some try and catch or log line by line.
Let me know

@Munsio
Copy link
Author

Munsio commented Oct 31, 2012

Hi, i wrapped the repository call into an try/catch block but there are no errors or warnings.

I pulled my code to pastebin:
http://pastebin.com/7E0WbJXP

I don't do anything with the Object i retrieved from Database.
But if i comment the try/catch block everything work as expected.

@liuggio
Copy link
Owner

liuggio commented Oct 31, 2012

You paste the code, without Exception,
echo the exception

@liuggio
Copy link
Owner

liuggio commented Oct 31, 2012

I'm going to close this ticket because is not related to ExcelBundle

@liuggio liuggio closed this as completed Oct 31, 2012
@Munsio
Copy link
Author

Munsio commented Oct 31, 2012

Hi

"You paste the code, without Exception,
echo the exception"

  • pelase look in pastebin on line 9

I think it is related to your ExcelBundle because if i use the StreamWriter to Save the File to the Filesystem and Download it with Filezilla or direct Link everything is alright.

This Problem only appears with the direct Response.

@liuggio
Copy link
Owner

liuggio commented Oct 31, 2012

hi, please could you pastebin the exception please.

@Munsio
Copy link
Author

Munsio commented Oct 31, 2012

The Strange thing is that there is no Exception!

i get the correct result object back from Doctrine but the Excel Response is damaged (Image from 1 Post).

If i comment the doctrine action the Excel Response works perfect.

My problem is that i don't know if it is an Doctrine problem or an ExcelBundle problem, cause everything else works fine i thought it could be an ExcelBundle problem.

I uploaded one of the damaged excel files to my googl drive with following link you can download it:
https://docs.google.com/open?id=0B-ePhomTc6A2WmNKS2Z0Wklqd3M

@liuggio
Copy link
Owner

liuggio commented Oct 31, 2012

I think that you don't see the exc because your Response is redirect into the xls file.
put a die() and you'll see the problem.

Divide et impera.
First split the function in different functionS.
Then, remove the Excel part and go there with debug = true.

@Munsio
Copy link
Author

Munsio commented Oct 31, 2012

The only Exception i get wenn i remove the direct response is that i had to return a Response Object instead of null.
The WebProfiler shows no other exceptions or anything else.

@Munsio
Copy link
Author

Munsio commented Nov 5, 2012

I solved my problem with saving the excel file to disk, create an redirect response to another route where i read this excel file with the file class, generate response headers and return the content via fpassthru().

It seems that my doctrine connection modifies the response object in a way that i couldn't change the response headers manualy. Maybe its cause i use multiple doctrine managers, i had no idea.

But at all thank you for this bundle and your time to help me.

@liuggio
Copy link
Owner

liuggio commented Nov 5, 2012

wow thanks this is still really strange ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants