EDN Admin
Well-known member
Hi,<br/><br/>I need to create an excel file from the database records. I fetched and put the data in an excel file and tried to save that file as follows.<br/><br/><span style="font-size:x-small <font size=2>
</font>
<span style="font-size:x-small;color:#0000ff <span style="font-size:x-small;color:#0000ff string<span style="font-size:x-small SavedFileName = Server.MapPath(<span style="font-size:x-small;color:#800000 <span style="font-size:x-small;color:#800000 "../NLR/WIP/WIP_"<span style="font-size:x-small + toDay + <span style="font-size:x-small;color:#800000 <span style="font-size:x-small;color:#800000 ".xls"<span style="font-size:x-small );<font size=2>
excelWorkbook.SaveAs(SavedFileName, Excel.
</font>
<span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 XlFileFormat<span style="font-size:x-small .xlWorkbookNormal, <span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 Type<span style="font-size:x-small .Missing, <span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 Type<span style="font-size:x-small .Missing, <span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 Type<span style="font-size:x-small .Missing, <span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 Type<span style="font-size:x-small .Missing, Excel.<span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 XlSaveAsAccessMode<span style="font-size:x-small .xlNoChange, <span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 Type<span style="font-size:x-small .Missing, <span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 Type<span style="font-size:x-small .Missing, <span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 Type<span style="font-size:x-small .Missing, <span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 Type<span style="font-size:x-small .Missing);
killExcelProc();<br/><br/>//@@ and released the excell process withthe following function<br/><br/><span style="font-size:x-small;color:#0000ff <span style="font-size:x-small;color:#0000ff <font size=2 color="#0000ff <font size=2 color="#0000ff
protected
</font></font><font size=2 color="#0000ff
</font>
<span style="font-size:x-small <span style="font-size:x-small;color:#0000ff <span style="font-size:x-small;color:#0000ff void<span style="font-size:x-small killExcelProc()<br/>{<font size=2>
</font>
<span style="font-size:x-small;color:#0000ff <span style="font-size:x-small;color:#0000ff foreach<span style="font-size:x-small (System.Diagnostics.<span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 Process<span style="font-size:x-small Proc <span style="font-size:x-small;color:#0000ff <span style="font-size:x-small;color:#0000ff in<span style="font-size:x-small System.Diagnostics.<span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 Process<span style="font-size:x-small .GetProcessesByName(<span style="font-size:x-small;color:#800000 <span style="font-size:x-small;color:#800000 "EXCEL"<span style="font-size:x-small ))
{
Proc.Kill();
}
}<br/><br/><br/>** Now in my XP machine IIS server it is running fine with out any problem. But in windows 2003 Server I am getting the following error<br/>"<br/> System.Runtime.InteropServices.COMException (0x800A03EC): Microsoft Office Excel cannot access the file D:RadioSQANLRWIP. There are several possible reasons: â The file name or path does not exist. â The file is being used by another program. â The workbook you are trying to save has the same name as a currently open workbook. at Excel.WorkbookClass.SaveAs(Object Filename, Object FileFormat, Object Password, Object WriteResPassword, Object ReadOnlyRecommended, Object CreateBackup, XlSaveAsAccessMode AccessMode, Object ConflictResolution, Object AddToMru, Object TextCodepage, Object TextVisualLayout) at Reports_WIP.btnWIP_Click(Object sender, EventArgs e) <br/> "<br/><br/>When I opened task manager I didnt find any excel process running. I have given the full permission to the virtual directory (Deployed folder) for ASPNET user. I modified the DCOMConfig configeration (For XP it is ASPNET and for 2003 it is NETWORK SERVICE). I think my application is not being able to save the excel file in the application. But I dont know why.. Please give me light and also tell me what I will have to do.
View the full article
</font>
<span style="font-size:x-small;color:#0000ff <span style="font-size:x-small;color:#0000ff string<span style="font-size:x-small SavedFileName = Server.MapPath(<span style="font-size:x-small;color:#800000 <span style="font-size:x-small;color:#800000 "../NLR/WIP/WIP_"<span style="font-size:x-small + toDay + <span style="font-size:x-small;color:#800000 <span style="font-size:x-small;color:#800000 ".xls"<span style="font-size:x-small );<font size=2>
excelWorkbook.SaveAs(SavedFileName, Excel.
</font>
<span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 XlFileFormat<span style="font-size:x-small .xlWorkbookNormal, <span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 Type<span style="font-size:x-small .Missing, <span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 Type<span style="font-size:x-small .Missing, <span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 Type<span style="font-size:x-small .Missing, <span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 Type<span style="font-size:x-small .Missing, Excel.<span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 XlSaveAsAccessMode<span style="font-size:x-small .xlNoChange, <span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 Type<span style="font-size:x-small .Missing, <span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 Type<span style="font-size:x-small .Missing, <span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 Type<span style="font-size:x-small .Missing, <span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 Type<span style="font-size:x-small .Missing);
killExcelProc();<br/><br/>//@@ and released the excell process withthe following function<br/><br/><span style="font-size:x-small;color:#0000ff <span style="font-size:x-small;color:#0000ff <font size=2 color="#0000ff <font size=2 color="#0000ff
protected
</font></font><font size=2 color="#0000ff
</font>
<span style="font-size:x-small <span style="font-size:x-small;color:#0000ff <span style="font-size:x-small;color:#0000ff void<span style="font-size:x-small killExcelProc()<br/>{<font size=2>
</font>
<span style="font-size:x-small;color:#0000ff <span style="font-size:x-small;color:#0000ff foreach<span style="font-size:x-small (System.Diagnostics.<span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 Process<span style="font-size:x-small Proc <span style="font-size:x-small;color:#0000ff <span style="font-size:x-small;color:#0000ff in<span style="font-size:x-small System.Diagnostics.<span style="font-size:x-small;color:#008080 <span style="font-size:x-small;color:#008080 Process<span style="font-size:x-small .GetProcessesByName(<span style="font-size:x-small;color:#800000 <span style="font-size:x-small;color:#800000 "EXCEL"<span style="font-size:x-small ))
{
Proc.Kill();
}
}<br/><br/><br/>** Now in my XP machine IIS server it is running fine with out any problem. But in windows 2003 Server I am getting the following error<br/>"<br/> System.Runtime.InteropServices.COMException (0x800A03EC): Microsoft Office Excel cannot access the file D:RadioSQANLRWIP. There are several possible reasons: â The file name or path does not exist. â The file is being used by another program. â The workbook you are trying to save has the same name as a currently open workbook. at Excel.WorkbookClass.SaveAs(Object Filename, Object FileFormat, Object Password, Object WriteResPassword, Object ReadOnlyRecommended, Object CreateBackup, XlSaveAsAccessMode AccessMode, Object ConflictResolution, Object AddToMru, Object TextCodepage, Object TextVisualLayout) at Reports_WIP.btnWIP_Click(Object sender, EventArgs e) <br/> "<br/><br/>When I opened task manager I didnt find any excel process running. I have given the full permission to the virtual directory (Deployed folder) for ASPNET user. I modified the DCOMConfig configeration (For XP it is ASPNET and for 2003 it is NETWORK SERVICE). I think my application is not being able to save the excel file in the application. But I dont know why.. Please give me light and also tell me what I will have to do.
View the full article