Problem generating Excel

Feb 10, 2010 at 9:57 AM
Edited Feb 10, 2010 at 9:58 AM

What happens is that i cannot open excel with other code readers until i open and save the excel again.

The file increases few KB after save it with excel and everything works fine, so i thing must be a problem.

I used ExcelPackage Project DLL and the excel works fine but i need to generate files without saving on disk.

Editor
Feb 10, 2010 at 10:08 AM
Edited Feb 10, 2010 at 11:27 AM

Try to open the file with a text processor like notepad++, if u see any html code inside your generate excel file....try to save it with code below:

 

                    Response.Clear();
                    Response.AddHeader("content-disposition", "attachment;  filename=file.xlsx");
                    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";                    
                    Response.BinaryWrite(pck.GetAsByteArray());
                    Response.End();
Feb 10, 2010 at 10:44 AM

Not working.

My previous code was similar but i had  at the end.

 

Response.Flush();

Responde.Close();

I opened the file with notepad++ and i don't have html inside, so it outputs well.

For example, the excel file i generate have 68KB, when i open with MS Excel 2007 and just click on save button it increases to 71KB.

After save with excel i can import correctly the excel file generated to my application.

 

 

Editor
Feb 10, 2010 at 11:17 AM

When u open with excel, did u see any warning about recover or something like that?

Feb 10, 2010 at 11:20 AM

No warning. 

Feb 10, 2010 at 12:04 PM

I was testing and i can read excel with oledb, so perhaps there is no problem.

But it's strange that i only can import files ( i am using http://exceldatareader.codeplex.com/)  that are saved in MS Excel 2007 or original ExcelPackage, with epplus are failing.

Thanks for helping.

Coordinator
Feb 10, 2010 at 12:56 PM

I had a quick look at it and exceldatareader reads the dimension-tag from sheet xml files inside the package.  (looks somthing like this... <dimension ref="A1:U85"/>)

I don't update it since Excel figure out the dimensions without this tag, but I guess I should add it to a future release.