Author: jdyoumans | Posted on: 11/24/2008 12:06:08 PM | Views : 320

I am trying to save a datagrid to excel but when I run it, it pops up the "save file" window and then when you fill in the location and hit OK it give me the error "Cannot copy file: Cannot read from source file or disk".

 I assume it is a permissions error but not sure since I have not worked with this in a long while.

 Here is the code I am using..
private void ExportToExcel(string strFileName, DataGrid dg)
{
     Response.ClearContent();
     Response.AddHeader("content-disposition", "attachment; filename=" + strFileName);
     Response.ContentType = "application/excel";
     System.IO.StringWriter sw = new System.IO.StringW ...

Go to the complete details ...