none
Using Microsoft.office.interop.excel.dll witout installing Office

    Question

  • Greetings,

    I need to open Excel 2007 files with over 2700 columns each. I tried using OLEDB and it only retrieves the first 255 columns on each query. Cannot seem to get them all at once. Then I tried Office Interop. I am able to transform the Used Range into a DataTable. Now the problem is that I cannot migrate my code and compile it if the target machine does not have Office Installed.

    Is there a way I can install the Interop assamblies without installing Office?
    Efrain Juarez


    Juarez
    Tuesday, November 17, 2009 4:52 PM

Answers

  • Hi Efrain,

    Thank you for your reply.

    To obtain the reference to interop with excel in your program, you have to install the PIA of excel (first install Excel). Thus, you need to install Office. Then install PIA.

    Hope this helps! If you have any concern, please feel free to let me know.l

    Have a great weekend.

    Best regards,
    Yichun Chen
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by YiChun Chen Wednesday, November 25, 2009 3:37 AM
    Friday, November 20, 2009 3:41 AM
  • Hi Efrain,

    Thank you for your post.

    I can understand the situation that you came across. However, as far as I know, I'm afraid that it's not possible. To refer to Interop, we have to install Excel before the PIA of excel.

    Hope this helps! If you have any concern, please feel free to let me know.

    Best regards,
    Yichun Chen
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Edited by YiChun Chen Saturday, November 21, 2009 3:46 PM typo
    • Marked as answer by YiChun Chen Wednesday, November 25, 2009 3:37 AM
    Saturday, November 21, 2009 3:42 PM

All replies

  • Hi Efrain,

    Thank you for your reply.

    To obtain the reference to interop with excel in your program, you have to install the PIA of excel (first install Excel). Thus, you need to install Office. Then install PIA.

    Hope this helps! If you have any concern, please feel free to let me know.l

    Have a great weekend.

    Best regards,
    Yichun Chen
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by YiChun Chen Wednesday, November 25, 2009 3:37 AM
    Friday, November 20, 2009 3:41 AM
  • Hi Yichun,

    Thanks for your response. I have another question though, is ti possible to reference to Interop without installing Excel at all? I would like to be able to develop my app with the Interop with Excel 2007 in it, but at the same time, I would like to run my app in other boxes without Excel, or any other Office product installed in it.

    Thanks, you have a nice weekend too.

    Efrian Juarez


    Juarez
    Friday, November 20, 2009 11:26 PM
  • Hi Efrain,

    Thank you for your post.

    I can understand the situation that you came across. However, as far as I know, I'm afraid that it's not possible. To refer to Interop, we have to install Excel before the PIA of excel.

    Hope this helps! If you have any concern, please feel free to let me know.

    Best regards,
    Yichun Chen
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Edited by YiChun Chen Saturday, November 21, 2009 3:46 PM typo
    • Marked as answer by YiChun Chen Wednesday, November 25, 2009 3:37 AM
    Saturday, November 21, 2009 3:42 PM
  • Hi,

     

    I've found you can actually get that dll from the Excel viewer, so if you want a lighter install try that.

     

    I keep Office tools off my dev machine, but had found it useful to have a viewer. I'm not sure how much smaller or lighter the viewer is, mind, so this may not help much.

     

    R

    Thursday, September 16, 2010 12:20 PM
  • Hi here is codes for you 

        

    using System; using System.Windows.Forms; using Excel = Microsoft.Office.Interop.Excel; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Excel.Application xlApp ; Excel.Workbook xlWorkBook ; Excel.Worksheet xlWorkSheet ; object misValue = System.Reflection.Missing.Value; xlApp = new Excel.ApplicationClass(); xlWorkBook = xlApp.Workbooks.Add(misValue); xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1); xlWorkSheet.Cells[1, 1] = "http://csharp.net-informations.com"; xlWorkBook.SaveAs("csharp-Excel.xls", Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue); xlWorkBook.Close(true, misValue, misValue); xlApp.Quit(); releaseObject(xlWorkSheet); releaseObject(xlWorkBook); releaseObject(xlApp); MessageBox.Show("Excel file created , you can find the file c:\\csharp-Excel.xls"); } private void releaseObject(object obj) { try { System.Runtime.InteropServices.Marshal.ReleaseComObject(obj); obj = null; } catch (Exception ex) { obj = null; MessageBox.Show("Exception Occured while releasing object " + ex.ToString()); } finally { GC.Collect(); } } } }

    If anyone interested in C# skills to control Excel, Please visit here: http://c-sharp-paradise.blogspot.com/2012/03/introduction-thisarticle-will.html

    Thursday, April 05, 2012 2:33 AM
  • Hi, you should try Open XML SDK for Excel, you can download it and see some great samples on that page.

    Also I prefer to use this .NET Excel component, it has a really great and easy-to-use API for importing Excel file to a DataTable in .NET.

    Friday, September 27, 2013 1:20 PM