Suppose I have a report Name as :
string reportName = "Facebook Network Performance Summary Report (By Region, By Content)";
and I would like to display that file name as excel
the below is my code to export the file
Response.AddHeader("Content-Disposition", "attachment; filename=" reportName + ".xls");
Response.AddHeader("Content-Length", l.ToString());
Response.ContentType = "application/vnd.ms-excel";
Response.BinaryWrite(f);
Unluckily, thewhen reading the first space of my reportName, it only shows Facebook and no else.
Is there any wexisting API for ASP.NET or other methods to handle the spaces of fileNAme ?
Try wrapping the filename in double quotes.
string filename = reportName + ".xls";
Response.AddHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
You need to wrap the filename in quotes:
Response.AddHeader("Content-Disposition", "attachment; filename=\"" + reportName + "\".xls");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With