I have problem in my project.I want to write data into exist excel file in Asp.NET C# on Windows 2008 server . I created project on my local computer and it is working properly but When I published on server I get this error: The Error
:System.Runtime.InteropServices.COMException (0x800A03EC):
Exception from HRESULT: 0x800A03EC at Microsoft.Office.Interop.Excel._Workbook.SaveAs(Object Filename,Object FileFormat, Object Password, Object WriteResPassword, Object ReadOnlyRecommended, Object CreateBackup, XlSaveAsAccessMode AccessMode, Object ConflictResolution, Object AddToMru, Object TextCodepage, Object TextVisualLayout, Object Local)
at Stock.EService.ReadExistingExcel()
Here is save file code:
mWorkBook.SaveAs(path3, Excel.XlFileFormat.xlWorkbookNormal, Missing.Value, Missing.Value, false, false, Excel.XlSaveAsAccessMode.xlNoChange,Excel.XlSaveConflictResolution.xlUserResolution, true,Missing.Value, Missing.Value, Missing.Value);
mWorkBook.Close(true, Missing.Value,Missing.Value);
How can solve my problem.I create a file in server and gave full control but my project does not work. Please help me.
我认为这可能是由于您的本地机器和服务器之间的Excel版本不同引起的。
This problem plagued me for quite a while. I had Excel 14.0 in the dev environment and Excel 15.0 in the production environment.
Here are a list of most things I tried to resolve the issue, however please keep in mind that it may have been one, all, or a combination of these things that resolved it for me.
Start -> Run -> lusrmgr.msc -> Add service account to Administrators group.
Component Services -> Computers -> My Computer -> Properties -> COM Security -> Add user to all permissions.
Component Services -> Computers -> My Computer -> DCOM Config -> Microsoft Excel Application -> Properties -> Security -> Add user to all permissions.
Component Services -> Computers -> My Computer -> DCOM Config -> Windows Management and Instrumentation -> Properties -> Security -> Add user to all permissions.
Excel -> File -> Options -> Trust Center -> Protected View -> Uncheck all 3 boxes.
Excel -> File -> Options -> Trust Center -> ActiveX Settings -> Enable all controls & uncheck safe mode.
Excel -> File -> Options -> Trust Center -> Macro Settings -> Enable all macros -> Trust access to the VBA project object model.
Excel -> File -> Options -> Trust Center -> File Block Settings -> Select Open selected file types in Protected View.
Excel -> File -> Options -> Trust Center -> File Block Settings -> Uncheck everything.
Excel -> File -> Options -> Trust Center -> External Content -> Enable all Data Connections; Enable automatic update for all Workbook links.
Excel -> File -> Options -> Trust Center -> Trusted Locations -> Check Allow Trusted Locations + Add C:\\ and any UNC paths + subdirectories.
Excel -> File -> Options -> Advanced -> Check "Ignore other applications that use Dynamic Data Exchange (DDE)"
In code, instead of using .SaveCopyAs, use .SaveAs with Excel.XlFileFormat.xlWorkbookDefault for xlsx files and Excel.XlFileFormat.xlOpenXMLWorkbookMacroEnabled for macro-enabled workbooks.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.