Hello all of you !
I am suffering from a crucial problem here. I have a project in which we give users functionality to eider download or email the data in .xls format. The .xls sheet is highly modified using watermarks, cell widths, etc etc. The problem is the code is running amazingly on local host but not on live. I tried removing try-catch to se wats the error still I am not even getting any error. When I go for download it starts downloading and then stops in between. I save the file first on server in the folder name downloads which has full permissions. I first write the sheet from datatable to xls. than using com objects of interop excel I pick this file maodify it save it with a diff name in the same folder and than delete the older one. This is how It all works. But all in vain on live. Plz I need serious help. This is about to gulp my job today. I am really tensed. I have tried everything. here is some code that I am using :
private static string Recreating_Ecxel_WorkSheet(string strWorkOrder, string strDwnload_file_name)
{
object oMissing = System.Reflection.Missing.Value;
Excel.ApplicationClass xl = new Microsoft.Office.Interop.Excel.ApplicationClass();
Excel.Workbook xlBook;
Excel.Worksheet xlSheet;
Excel.Range range;
string laPath = HttpContext.Current.Server.MapPath("~//download//" + strDwnload_file_name + ".xls");
xlBook = (Workbook)xl.Workbooks.Open(laPath, oMissing,
oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, oMissing);
xlSheet = (Worksheet)xlBook.Worksheets.get_Item(1);
xlSheet.Cells.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
xlSheet.SetBackgroundPicture(HttpContext.Current.Server.MapPath("~//images//cybex-punchline_half.jpg"));
xlSheet.Cells.WrapText = false;
xlBook.Worksheets.get_Item(1);
((Range)xlSheet.Columns["A", Type.Missing]).ColumnWidth = 13;
((Range)xlSheet.Columns["B", Type.Missing]).ColumnWidth = 09;
((Range)xlSheet.Columns["C", Type.Missing]).ColumnWidth = 65;
((Range)xlSheet.Columns["D", Type.Missing]).ColumnWidth = 13;
((Range)xlSheet.Columns["E", Type.Missing]).ColumnWidth = 10;
((Range)xlSheet.Columns["F", Type.Missing]).ColumnWidth = 22;
((Range)xlSheet.Columns["G", Type.Missing]).ColumnWidth = 10;
((Range)xlSheet.Columns["H", Type.Missing]).ColumnWidth = 30;
((Range)xlSheet.Columns["I", Type.Missing]).ColumnWidth = 12;
((Range)xlSheet.Columns["J", Type.Missing]).ColumnWidth = 25;
string str_modified_file_download_name = dwnlod_file_name(strWorkOrder);
xlBook.SaveAs(HttpContext.Current.Server.MapPath("~//download//" + str_modified_file_download_name + ".xls"), XlFileFormat.xlWorkbookDefault, Type.Missing, Type.Missing,
false, false, XlSaveAsAccessMode.xlNoChange,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
xl.Application.Workbooks.Close();
FileInfo fi1 = new FileInfo(laPath);
if (fi1.Exists)
fi1.Delete();
releaseObject(xlBook);
releaseObject(xlSheet);
releaseObject(xl);
return str_modified_file_download_name;
}
Pls does anyone know something about it ? Please help me