c# - How to use Microsoft.Office.Interop.Excel on a machine without installed MS Office? -


I need a feature I am writing an application that works with Excel files I remove a sheet . . I'm having right

Developer machine to use an assembly Microsoft.Office.Interop.Excel.dll, but to deploy the server when I try I'm getting an error:

could not load file or assembly work, version = 14.0.0.0, Culture = neutral, PublicKeyToken = 71e9bce111e9429c 'or one of its dependencies

I think The problem that occurs when the MS Office is not installed on the machine and the customer is not installed I do not want to buy MS Office at a price at any cost.

As suggested here I installed "Redistribution primary interop gatherings" on the developer machine. And re-compile my project

Code sample:

  public bool DeleteSheet (string Talikanam) {Excel.Application app = null; Excel Workbooks wbks = null; Excel._Workbook _wbk = null; Excel.Sheets shs = null; Bull got = wrong; {App = New Excel.Application (try); App View = false; App DisplayLetter = False; App.AlertBeforeOverwriting = false; Wbks = app.Workbooks; _wbk = wbks.Add (xlsfile); Shs = _wbk.Sheets; Int nSheets = shs.Count; {Excel._Worksheet _iSheet = (Excel._Worksheet) shs.get_Item (i) for (Int i = 1; I & lt; = nSheets; i ++); If (_iSheet.Name == table name) {_iSheet.Delete (); Found = true; Marshal.ReleaseComObject (_iSheet); break; } Marshal. Release Com Object (_iSheet); } If ((found!) New exception throw (string.format ("table \" {0} \ "not found", tagname)); _wbk.SaveAs (Connect, _wbk.FileFormat, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Missing.Value, Missing.Value, Missing.Value, Missing, value, missing value); } Finally {_wbk.Close (empty, null, void); Wbks.Close (); App.Quit (); Marshal.ReleaseComObject (SHS); Marshal.ReleaseComObject (_wbk); Marshal.ReleaseComObject (wbks); Marshal.ReleaseComObject (app); } Back true; }   

exception

CLSID is gaining COM class factory for component with {00024500-0000-0000-C000-000000000046} following error Failed due to: 80040154 class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

on line

  application = new Excel.Application ();   

Can anyone give any advice about this feature to work successfully?

You can not use Microsoft Office.

  • (only xlsx)

    ul>

  • Comments

    Popular posts from this blog

    java - NullPointerException for a 2d Array -

    python - Assemble mpeg file unable to play in mediaplayer -

    c# - NameSpace Manager or XsltContent to parse aspx page -