This project has moved. For the latest updates, please go here.

How Can I Make The OpenExcel File Save As .xlsx instead of .zip?

Dec 15, 2011 at 3:49 PM

The title says it all.  For some back story, I am working in a VS 2008 project that is using .Net 2.0.  However, there is a .Net 3.5 project within the solution where I am putting the code.  It seems to work, but saves as .zip instead of an .xlsx file. 

 

Report report = new Report(Result.RawData.ToReportSource());
report.TextFields.Title =
"Cardiac Surgery Pending Surgeries Report";
DoddleReport.OpenXml.ExcelReportWriter writer = new DoddleReport.OpenXml.ExcelReportWriter();
writer.WriteReport(report, Context.Response.OutputStream); 

 

So in the website I have created a link to a new .aspx page that has no code in the Html outside of the @Page declarative.  The code behind only has the above code.  Like I said, it seems to work, however, I would like it to default to an .xlsx extension and thus when I do an Open as opposed to a Save it will open in Excel.

I almost assume there is a property on the Report or Writer objects that I can set but it is not standing out.  Or is it in metadata within the .aspx page?

Great tool by the way!

Kevin

Coordinator
Dec 15, 2011 at 3:53 PM

I can't say I've ever seen anything like this, but if you're using DoddleReport in asp.net webforms you should use a .ashx file (not .aspx) and inherit from the WebReport class, described here

http://doddlereport.codeplex.com/wikipage?title=Web%20Reporting

 

Dec 15, 2011 at 4:00 PM

I would love to use the .ashx but this 3.5 project I have is class library and thus not setup to where I can create one within it.  I will attempt to create an .ashx file in the 2.0 website and see if it can call the 3.5 project to gather the data and such.