Opening excel file usign ActiveX

Hi,
Is it possible to open an excel file using LabVIEW with ActiveX controls and display it on the screen, edit some cells, save it and close? I am new to this ActiveX stuff. Please help me. Thanx.

The quickest way would be to use the NI LabVIEW Report Generation Toolkit for Midrosoft Office that is available at this URL:
http://sine.ni.com/apps/we/nioc.vp?cid=5769〈=US
You can also do it yourself through ActiveX like you said. Open excel._application, from that get a reference to the workbook, then the worksheet, then the cell. Add the data, change cells, add the data, etc. Invoke a save when you are done. I don't remember if it normally opens Excel for the user to see or if you have to command that and then command the closing (if desired).
Be sure to close all of the references that you opened.
I hope that this helps!
Bob Young - Test Engineer - Lapsed Certified LabVIEW Developer
DISTek Integration, Inc. - NI Alliance Member
mailto:[email protected]

Similar Messages

  • How to list all currently open Excel files with ActiveX?

    Hello all!
    I would like to program with ActiveX a way to retrieve a list (array of strings) of the filenames of the currently opened Excel files in windows. However, I am fairly new to the ActiveX/Excel business in LV and after hours looking at the "millions" of objects in the property nodes I give up and hope some kind soul here can help me. I couldn't find any information in this forum regarding the same issue, although some were close
    I am using LV 7.1 without the Report Generation Toolkit.
    Thanks!
    /Goran

    Hi KC,
    thanks for your reply. I have in fact been able to find the desired things in the ActiveX properties/methods for Excel in LabView. It took me some looong work going through the functions which I suspected to be the ones. Anyway, I post a little jpeg here of the code if someone ever needs the same functionality. What it does is that it checks how many Excel workbooks are open and controls if each of them matches the searched Excel filename, if one does, it is closed.
    Enjoy
    /Goran
    Attachments:
    List open excel sheets and close open ones.jpg ‏104 KB

  • Is there a way to open Excell file from the server and display in the UI and save it back on to the

    Hello there,
    Is there a way to open Excell file from the server and display in the UI and save it back on to the server? (like showing xell file as a datagrid - add rows, columns etc.)

    Hi Mike,
    Welcome you to the forum.
    You may try:
    SELECT * FROM MyDBNameHere.dbo.OUSR T0
    Thanks,
    Gordon

  • Some users can't open Excel files. It is trying to open it in Internet Explorer "An error has occurred. Please try again."

    I have some users in my company that can't open Excel files from any document libraries on SharePoint 2010. The receive the error message "An error occurred. Please try again."  We don't currently use the Excel calculations services. When
    a user opens an excel file they are prompted to either Read Only or Edit.
    This affects less than 5 people in a large company.  They have the Full Control permissions and have been able to open the files previously.  There has been no changes made to the server either.  I can't find anything that points to this in the
    event viewer. 
    It doesn't matter if which computer that they try to open this up from either.   All computers are Windows 7 Professional with IE 9 and Office 2010 x64.   
    I can't find anything that points specifically to this exact error. None of the excel files contain pivot tables.    This one has me stumped.

    I would make sure no one has open on machine / locked on machine (Would assume you checked this, but wanted to add)
    Also would have assumed you restarted the machines (:))
    Make sure the file security did not change (check to ensure no one changed the sercuity of the excel)
    Make sure the version of excel is the same (Changing from 2010 back to 2007 affects the file, etc.. on convert) that no one converted and saved thus causing error in file.
    Can they open other excel files?
    It sounds like the excel file it self has changed if you cannot see issue in SharePoint logs.
    If it is all SharePoint excel files - try deleting one persons access and readding them to see if that helps.
    SharePoint has issues ;)

  • Problem in opening excel file in different window

    hi
    i want to open excel file in different window it open in same window properly on the bases of condition but when i try to open in different with window.open( )
    it give error that file has already used or path not exist OR requisted site either unavailable
    how can i rectified

    Hi.
    I am too facing the same problem. I am using Jakarta Poi to display my resultset in an excel sheet directly(and not into a jsp)
    The browser opens a window showing Open Save Cancel. If i click and save the excel sheet and then open, it opens. But clicking on Open directly doesnt open the excel sheet. Rather it gives the same error
    The file name or path name does not exist.
    The file you are trying to open is being used by another progrtam . close the document in other program and try again
    The name of the work book your tring to save is the same as name of another document that is readonly .try saving workbook with different name
    Can somebody please help me fix this problem, since its an urgent requirement. Mail me at [email protected]
    Thanks
    Hitesh

  • Cannot open Excel files on Windows share and ONLY Excel files

    I'm browsing a Windows share and for whatever reason it will not let me open Excel files directly from the network location. If I view the Coverflow, I can see a a preview of the actual file as well as copy it to the desktop and open it.
    I receive an error message that says "filename.xls could not be found."
    I can open up any other file from the network location, but not Excel files.
    I checked the file permissions and they mirror the other file types, it may be worth mentioning that I utilize network synchronization and view these files from a PC as well. I also noticed when I create a new file in that location, it will only appear in OS X and not Windows, but is still completely accessible.
    Any help is appreciated!
    Thanks

    Re:  Windows 8 vs. Excel problem
    Does your new Dell computer have MS Office installed?
    Jim Cone
    Portland, Oregon USA
    https://jumpshare.com/b/O5FC6LaBQ6U3UPXjOmX2

  • Can't open Excel files from Sharepoint 2013

    I am having an issue with opening Excel files from SharePoint 2013. If I click on an excel file it comes up with the error below.
    If I click Try again I get the message below also:
    If I try to open Word or PDF files they open correctly in the appropriate client and I have the option of checking them out and editing them. Any ideas why this would only be happening to Excel files?
    Thanks,
    Shaun

    Hi Shaun,
    I understand that the Excel files cannot be opened from SharePoint in Microsoft Excel.
    Can these files be viewed in the browser?
    I recommend to download a copy of the files with issue and then open them in Excel to see if the issue still occurs.
    If above cannot work, I recommend to repair Office.
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • When Opening Excel file, there is a message

    Dear BPC Experts:
       When I open excel files in BPC NW 7.0, there is a warning message saying "Programmatic access to Visual Project in not trusted"
    Does anyone have suggestion for this message? Thanks in advance.
    -Fred
    Edited by: Fred Cheng on Jul 22, 2009 10:47 AM

    From MS Excel 2003 goto Tools > Macro > Trusted Publishers > check on the option Trust access to Visual Basic Project.  From the Security Level tab - click on the Medium option.
    From MS Excel 2007 click on Office button in the top-left corner, then click on the Excel options from the pop-up window.  Click on the Trust Center option > Trust Center Settings > Check on the option Trust access to the VBA project object model.  Also check the option Disable all macros except digitally signed macros.
    Best regards,
    [Jeffrey Holdeman|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/profile/jeffrey+holdeman]
    SAP BusinessObjects
    Enterprise Performance Management
    Regional Implementation Group

  • Opening Excel file in HTML

    Hi All,
    Does anyone know how to launch Excel file in HTML or jsp?
    Wait...i know one method to open Excel fiel using
    Window.open(blah...blah..)
    In this case we can specify toolbar option..
    But in my application i am loading excel file in frame.But frame doesnt have any option to set toolbar.....
    Please let me know if you have soln for this....
    Regards,
    Surya

    Hi,
    I can open excel file using window.open...but my requirement is forcing me to open it in frame....And i m able to open it properly in frame...but i want toolbar to come along with that frame...
    according to folowing lin they say it is not possible have scenario like this...
    http://support.microsoft.com/kb/157353/EN-US/
    Please see whether you can help in this regard...

  • Cannot Open Excel File after exporting from Disco Plus

    Hi there,
    I got a question from one user having issue with opening Excel file after exporting from Disco Plus.
    The report has been using for a while and he is using Excel 2003 version and Discoverer 10g(10.1.2.2), he never got this kind of error before, just recently got error.
    After exporting from Disco Plus he saved file on his desktop and when he tries to open the excel it says "Cannot be Accessed, can be corrupted...." but this is not from network drive since he saved file on local desktop or C drive.
    Also not for all reports, only this particular report and only specific parameter, for example for parameter 2008 Feb opened successfully, but for2009 Feb he gets this error when trying to open excel.
    i tried in excel 2007 also , i dont think this is Excel version error, am not sure.
    Also after go live last week (we upgraded database from 9i to 10g) but i am not sure this causes ,since for one parameter working, for other parameter not working.
    Actually we should get one window for Macro when we try to open excel, but he is not getting it seems.
    Any ideas/thoughts on this would be greatly appreciated.
    Thanks for your help
    --skat                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Rod,
    Thanks for your quick response on this.
    Yes, we can export to other formats as well, but actually exporting is working, after saving the file on our local desktop/drive and when we try to open we get this kind messages or we cannot open the file, we should get message window for Macro to enable/disable but for this report we are not getting this either,
    Also this happens only for specific parameters,like i mentioned above it works I mean excel file opens for one set of parameters but for some other set of parameters cannot open.
    For example :- when we enter FEB 2008 it works, if we enter FEB 2009 it won't open the file.
    This is weird
    I am still working on this issue, may be better to recreate the report again might be helpful,
    Any ideas/comments/thoughts would be great
    Thanks
    Skat

  • Is there way to have Numbers open excel files automatically

    Is there way to have Numbers open excel files automatically when I click on my old excel files rather than opening numbers and then opening file?

    Try this: from Finder, select an Excel file. Hit Apple-i to get the file info. You'll see a section labeled *Open with:* Use the dropdown to select Numbers and click the *Change All* button.

  • Spreadsheet app that opens Excel files?

    I should have asked this in my last post about word processors in OS X. If I'm just a casual user who rarely needs to open Excel files (e.g. friends email me some spreadsheet about who knows what), should I just plan on using NeoOffice (OpenOffice), or is there some other option out there if I don't want to buy MS Office? It seems that iWork doesn't even come with a spreadsheet app. However, even if it did, I'm wondering if there'd be another alternative sufficient for a casual user like myself.
      Mac OS X (10.4.6)  

    NeoOffice handles multiple sheets and has loaded my Excel files with no problems. I have not used NeoOffice extensively as I downloaded it to become familiar with what it can do, so I have not come up against its limitations yet. NeoOffice is a large program (338 mb on my external hard disk) which contains all the modules in one (rather than separate programs like Word, Excel and PowerPoint), so it takes a while to initially open but once open it switches between the modules with little delay.

  • I cannot Open EXCEL files transferred from my old HP laptop.

    I am unable to open EXCEL files transferred from my HP LapTop. How to resolve?

    The forum for MBP:
    MacBook Pro
    As for Excel, checked microsoft office community?
    Maybe if you try export first....?
    Vista has its own ownership permission flags. Maybe if you modify the file or a copy first, and then copy.

  • Error opening excel files in browser

               
    Okai I am currently facing an error when i try to open excel files in browser .  it gives the prompt "The workbook can not be opened".
    Upon checking the logs I found the following entries in the log file . recently we tried to move our site over https but later the idea was scrapped and we retracted to the old iis settings furthermore sharepoint forefront protection is also installed on our
    farm . 
    When i check the event viewer I see the following error every time i try to open excel workbook on sharepoint browser
    1719104822: #960013: Antivirus scanner timed out.
    ULS LOGS :
    m   MossHostFileLoader.GetCloseUri: parent folder/list url = /CorporatePlanning/Tasweeq QAS/9 - Functional Procedures and Standards/Corporate Planning/Standards/Master documents for file = Tasweeq QAS/9 - Functional
    Procedures and Standards/Corporate Planning/Standards/Master documents/PLS-06A Sample Economic Template A (Condensates) 14 Aug 2013.xlsx
    3f0aca0b-b7df-4ef2-8983-2ab3b35c9932
    0x1868
    Excel Services Application     Excel Calculation Services    
    5pam Medium  
    BaseWorkbookManager.GetBaseWorkbookAndMarkUsedAsync: There are 1 Base Workbooks in the Base Workbook Manager
    3f0aca0b-b7df-4ef2-8983-2ab3b35c9932
    0x1868 Excel Services Application    
    Excel Calculation Services    
    27e7 Medium  
    BaseWorkbookManager.GetBaseWorkbookAndMarkUsedAsync: Spawning BaseWorkbook job to load the file.
    3f0aca0b-b7df-4ef2-8983-2ab3b35c9932
    0x1868 Excel Services Application    
    Excel Calculation Services    
    gvr1 Medium  
    BaseWorkbook.CacheStream: Fetching "http://tq-intra1:77/CorporatePlanning/Tasweeq%20QAS/9%20-%20Functional%20Procedures%20and%20Standards/Corporate%20Planning/Standards/Master%20documents/PLS-06A%20Sample%20Economic%20Template%20A%20(Condensates)%2014%20Aug%202013.xlsx"
    to local disk cache as "C:\Windows\TEMP\Excel Server\FileCache\f85d573e-d592-4ce5-8c5e-3095a297861c\Workbooks\f1c8e29f-15fc-42a9-89bb-37c14a5995b0.xlsx.xlserver"
    3f0aca0b-b7df-4ef2-8983-2ab3b35c9932
    0x1868 Excel Services Application    
    Excel Calculation Services    
    d1qs Medium  
    MossHostFileLoader.FetchStreamInternal: Fetching version 512 from File.Versions collection. The latest version available is: 512
    3f0aca0b-b7df-4ef2-8983-2ab3b35c9932
    0x1868 SharePoint Foundation        
    General                      
    1
    Critical 1719104822: #960013: Antivirus scanner timed out.
    3f0aca0b-b7df-4ef2-8983-2ab3b35c9932
    0x1868 Excel Services Application    
    Excel Calculation Services    
    91zq Medium  
    BaseWorkbookManager.GetBaseWorkbookAndMarkUsedAsync: Got an error when trying to fetch file from file loader. Error was Id=GenericFileOpenError; Microsoft.Office.Excel.Server.CalculationServer.FileOpenException: The workbook cannot be opened.
    ---> Microsoft.Office.Excel.Server.Host.HostFileException ---> Microsoft.SharePoint.SPException: Error Found:      at Microsoft.SharePoint.SPFile.GetFileStreamCore(OpenBinaryFlags openOptions, String etagNotMatch, String& etagNew,
    String& contentTagNew)     at Microsoft.SharePoint.SPFile.GetFileStream(OpenBinaryFlags openOptions, String etagNotMatch, String& etagNew, String& contentTagNew)     at Microsoft.SharePoint.SPFile.OpenBinaryStream()    
    at Microsoft.Office.Excel.Server.MossHost.MossHostFileLoader.FetchStreamInternal()     --- End of inner ex...
    3f0aca0b-b7df-4ef2-8983-2ab3b35c9932
    0x1868 Excel Services Application    
    Excel Calculation Services    
    91zq Medium  
    ...ception stack trace ---     at Microsoft.Office.Excel.Server.MossHost.MossHostFileLoader.FetchStreamInternal()     at Microsoft.Office.Excel.Server.MossHost.MossHostFileLoader.FetchStream(IIdentity currentIdentity)    
    at Microsoft.Office.Excel.Server.CalculationServer.SharePointFileLoader.FetchStream()     --- End of inner exception stack trace ---     at Microsoft.Office.Excel.Server.CalculationServer.SharePointFileLoader.FetchStream()    
    at Microsoft.Office.Excel.Server.CalculationServer.BaseWorkbookManager.CacheStream(CachedFile cachedFile, FileLoader loader)     at Microsoft.Office.Excel.Server.CalculationServer.BaseWorkbook.Microsoft.Office.Excel.Server.CalculationServer.ICachedFileProvider.SaveFile(CachedFile
    cachedFile)     at Microsoft.Office.Excel.Server.CalculationServer.Cached...
    3f0aca0b-b7df-4ef2-8983-2ab3b35c9932
    0x1868 Excel Services Application    
    Excel Calculation Services    
    91zq Medium  
    ...File.SaveFile(ICachedFileProvider fileProvider)     at Microsoft.Office.Excel.Server.CalculationServer.LocalDiskCache.ReserveCachedFileAndMarkUsed(FileId fileId, ICachedFileProvider fileProvider, Boolean replaceExistingFile)    
    at Microsoft.Office.Excel.Server.CalculationServer.BaseWorkbook.ReserveCachedFileAndMarkUsed(FileLoader fileLoader)     at Microsoft.Office.Excel.Server.CalculationServer.BaseWorkbookManager.GetBaseWorkbookAndMarkUsedAsync(AsyncHandler`1 callback,
    Object userState, Request request, Uri uri, Boolean newWorkbook, Boolean useCollection, Boolean loadedOnDemand)
    3f0aca0b-b7df-4ef2-8983-2ab3b35c9932
    10/07/2014 11:30:06.92 w3wp.exe (0x0B70)                      
    0x1868
    SharePoint Foundation         Monitoring                    
    b4ly Medium  
    Leaving Monitored Scope (ExecuteWcfServerOperation). Execution Time=84.4791
    3f0aca0b-b7df-4ef2-8983-2ab3b35c9932
    10/07/2014 11:30:06.92 w3wp.exe (0x0B70)                      
    0x0D10
    Excel Services Application     Excel Calculation Services    
    bbow Medium  
    BaseWorkbook.LoadWorkbookJobAsync: Starting. FileId.Uri=http://tq-intra1:77/CorporatePlanning/Tasweeq%20QAS/9%20-%20Functional%20Procedures%20and%20Standards/Corporate%20Planning/Standards/Master%20documents/PLS-06A%20Sample%20Economic%20Template%20A%20(Condensates)%2014%20Aug%202013.xlsx
    3f0aca0b-b7df-4ef2-8983-2ab3b35c9932
    10/07/2014 11:30:06.92 w3wp.exe (0x0B70)                      
    0x0D10
    SharePoint Server            
    Logging Correlation Data      
    xmnv Medium  
    Name=Job: LoadWorkbook 3f0aca0b-b7df-4ef2-8983-2ab3b35c9932
    10/07/2014 11:30:06.92 w3wp.exe (0x0B70)                      
    0x0D10
    SharePoint Server            
    Logging Correlation Data      
    xmnv Medium  
    Document=http://tq-intra1:77/CorporatePlanning/Tasweeq%20QAS/9%20-%20Functional%20Procedures%20and%20Standards/Corporate%20Planning/Standards/Master%20documents/PLS-06A%20Sample%20Economic%20Template%20A%20(Condensates)%2014%20Aug%202013.xlsx
    3f0aca0b-b7df-4ef2-8983-2ab3b35c9932
    10/07/2014 11:30:06.92 w3wp.exe (0x0B70)                      
    0x0D10
    Excel Services Application     Excel Calculation Services    
    91zp Medium  
    BaseWorkbook.LoadWorkbookJobAsync: Detected error that occurred in the BeginXXX portion of this call. It will be wrapped and retheown. Error was Id=GenericFileOpenError; Microsoft.Office.Excel.Server.CalculationServer.FileOpenException: The workbook
    cannot be opened. ---> Microsoft.Office.Excel.Server.Host.HostFileException ---> Microsoft.SharePoint.SPException: Error Found:      at Microsoft.SharePoint.SPFile.GetFileStreamCore(OpenBinaryFlags openOptions, String etagNotMatch, String&
    etagNew, String& contentTagNew)     at Microsoft.SharePoint.SPFile.GetFileStream(OpenBinaryFlags openOptions, String etagNotMatch, String& etagNew, String& contentTagNew)     at Microsoft.SharePoint.SPFile.OpenBinaryStream()
        at Microsoft.Office.Excel.Server.MossHost.MossHostFileLoader.FetchStreamInternal(...
    3f0aca0b-b7df-4ef2-8983-2ab3b35c9932
    10/07/2014 11:30:06.92* w3wp.exe (0x0B70)                      
    0x0D10
    Excel Services Application     Excel Calculation Services    
    91zp Medium  
    ...)     --- End of inner exception stack trace ---     at Microsoft.Office.Excel.Server.MossHost.MossHostFileLoader.FetchStreamInternal()     at Microsoft.Office.Excel.Server.MossHost.MossHostFileLoader.FetchStream(IIdentity
    currentIdentity)     at Microsoft.Office.Excel.Server.CalculationServer.SharePointFileLoader.FetchStream()     --- End of inner exception stack trace ---     at Microsoft.Office.Excel.Server.CalculationServer.SharePointFileLoader.FetchStream()
        at Microsoft.Office.Excel.Server.CalculationServer.BaseWorkbookManager.CacheStream(CachedFile cachedFile, FileLoader loader)     at Microsoft.Office.Excel.Server.CalculationServer.BaseWorkbook.Microsoft.Office.Excel.Server.CalculationServer.ICachedFileProvider.SaveFile(CachedFile
    cachedFile)     at Microsoft.Office.Excel.Server...
    3f0aca0b-b7df-4ef2-8983-2ab3b35c9932
    10/07/2014 11:30:06.92* w3wp.exe (0x0B70)                      
    0x0D10
    Excel Services Application     Excel Calculation Services    
    91zp Medium  
    ....CalculationServer.CachedFile.SaveFile(ICachedFileProvider fileProvider)     at Microsoft.Office.Excel.Server.CalculationServer.LocalDiskCache.ReserveCachedFileAndMarkUsed(FileId fileId, ICachedFileProvider fileProvider, Boolean replaceExistingFile)
        at Microsoft.Office.Excel.Server.CalculationServer.BaseWorkbook.ReserveCachedFileAndMarkUsed(FileLoader fileLoader)     at Microsoft.Office.Excel.Server.CalculationServer.BaseWorkbookManager.GetBaseWorkbookAndMarkUsedAsync(AsyncHandler`1
    callback, Object userState, Request request, Uri uri, Boolean newWorkbook, Boolean useCollection, Boolean loadedOnDemand).
    3f0aca0b-b7df-4ef2-8983-2ab3b35c9932
    10/07/2014 11:30:06.92 w3wp.exe (0x0B70)                      
    0x0D10
    Excel Services Application     Excel Calculation Services    
    8trf Medium  
    BaseWorkbookManager.UnsafeRemoveWorkbook: There are 0 Base Workbooks in the Base Workbook Manager

    Hi arsalan,
    This issue seems to be about the forefront protection. Please try to increase Antivirus time out as SharePoint Central Administration->Security->Manage antivirus settings, then compare the result.
    If this issue still exists, I suggest re-install forefront.
    In addition, please check if the links are useful for you:
    http://blog.henryong.com/2012/06/12/auto-restarting-forefront-for-sharepoint-when-it-hangs-and-times-out-with-powershell/
    http://breakfixsolution.blogspot.jp/2014/03/sharepoint-sites-were-not-accessible.html
    https://support2.microsoft.com/kb/2953311?wa=wsignin1.0
    Best Regards,
    Wendy
    Wendy Li
    TechNet Community Support

  • How to open Excel FIles

    I am a novice
    When I open excel file  I found some problems.
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Reflection;
    using System.Windows.Forms;
    using XLS=Microsoft.Office.Interop.Excel;
    using WD=Microsoft.Office.Interop.Word;
    using Microsoft.Office.Core;
    namespace ExcelDataFillWord
        public partial class Form1 : Form
            public Form1()
                InitializeComponent();
            private void button1_Click(object sender, EventArgs e)
                //  Scheduler sched = new Scheduler();
                //foreach (Task t in sched.Tasks)
                //    Console.WriteLine(t.ToString());
                //    foreach (Trigger tr in t.Triggers)
                //        Console.WriteLine(tr.ToString());
            private void label1_Click(object sender, EventArgs e)
                FileDialog.Filter = "excel文件|*.xls|Excel文件|*.xlsx";
                FileDialog.Multiselect = false;
                FileDialog.Title = "打开excel文件";
                if (FileDialog.ShowDialog() == DialogResult.OK)
                    textBox1.Text = FileDialog.FileName;
                    object missing = System.Reflection.Missing.Value;
                    //object missing = Type.Missing;
                    CloseProcess();
                   //'Excel::Application excel =new Excel::ApplicationClass();
                    Microsoft.Office.Interop.Excel.Application excel= new Microsoft.Office.Interop.Excel.Application();
                    //Excel::Workbook  Wk =(Excel::Workbook )Xls.Workbooks.Open(textBox1.Text, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing,
    missing, missing, missing, missing);
                    Microsoft.Office.Interop.Excel.Workbook workbook =(Microsoft.Office.Interop.Excel.Workbook) excel.Application.Workbooks.Open(textBox1.Text , missing, missing, missing,
    missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
                    //comboBox1.Items.Clear();
                    //foreach (Excel::Worksheet Sh in Wk.Worksheets)
                    //    comboBox1.Items.Add((Sh.Name).ToString());
                    workbook.Close(missing, missing, missing);
                    excel.Quit();
            private void CloseProcess()
                System.Diagnostics.Process[] excelProcess = System.Diagnostics.Process.GetProcessesByName("EXCEL");//实例化进程对象
                foreach (System.Diagnostics.Process p in excelProcess)
                    p.Kill();//关闭进程
                System.Threading.Thread.Sleep(10);//使线程休眠10毫秒
    problem is : can't change  excel.applicaitonclass's Com object   to   interface
    so I want to ask a question:
    excel.application is a interface ,then interface variant = a class( it inherients this interface)  object
    but interface is a abstract object ,It has no construct function . why We use  Excel.Applcation xsl=new Excel.Application();

    Hello,
    Perhaps this will help. Open an Excel file, select a sheet, range then set a value, save then close. The idea here is not to write or save but demo a few basic operations.
    Also note 'as is' all memory is cleaned up without resorting to what many do, force the garbage collector. This is important if objects are not cleaned up it is very possible in extreme cases to bring a machine down so one should ensure all objects are cleaned
    up which only comes from well written code be it C# or VB.NET
    using System;
    using System.Data;
    using System.Data.OleDb;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;
    using Excel = Microsoft.Office.Interop.Excel;
    namespace Example_C1
    public partial class Form1 : Form
    public Form1()
    InitializeComponent();
    public void OpenExcelExample(string FileName, string SheetName)
    if (System.IO.File.Exists(FileName))
    bool Proceed = false;
    Excel.Application xlApp = null;
    Excel.Workbooks xlWorkBooks = null;
    Excel.Workbook xlWorkBook = null;
    Excel.Worksheet xlWorkSheet = null;
    Excel.Sheets xlWorkSheets = null;
    Excel.Range xlCells = null;
    xlApp = new Excel.Application();
    xlApp.DisplayAlerts = false;
    xlWorkBooks = xlApp.Workbooks;
    xlWorkBook = xlWorkBooks.Open(FileName);
    xlApp.Visible = false;
    xlWorkSheets = xlWorkBook.Sheets;
    for (int x = 1; x <= xlWorkSheets.Count; x++)
    xlWorkSheet = (Excel.Worksheet)xlWorkSheets.get_Item(x);
    if (xlWorkSheet.Name == SheetName)
    Proceed = true;
    break;
    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(xlWorkSheet);
    xlWorkSheet = null;
    if (Proceed)
    Excel.Range xlRange1 = null;
    xlRange1 = xlWorkSheet.get_Range("A1");
    xlRange1.Value = "Hello";
    Marshal.FinalReleaseComObject(xlRange1);
    xlRange1 = null;
    xlWorkSheet.SaveAs(FileName);
    else
    MessageBox.Show(SheetName + " not found.");
    xlWorkBook.Close();
    xlApp.UserControl = true;
    xlApp.Quit();
    ReleaseComObject(xlCells);
    ReleaseComObject(xlWorkSheets);
    ReleaseComObject(xlWorkSheet);
    ReleaseComObject(xlWorkBook);
    ReleaseComObject(xlWorkBooks);
    ReleaseComObject(xlApp);
    MessageBox.Show("Done");
    else
    MessageBox.Show("'" + FileName + "' not located. Try one of the write examples first.");
    private void ReleaseComObject(object obj)
    try
    System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
    obj = null;
    catch (Exception)
    obj = null;
    private void button1_Click(object sender, EventArgs e)
    OpenExcelExample(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "WS1.xlsx"), "Sheet3");
    private void releaseObject(object obj)
    try
    if (obj == null)
    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();
    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

Maybe you are looking for

  • CAPTCHA in Flash Contact form

    Hello every one. I wonder if anyone have worked with CAPTCHA in contact form, it's will be great for anty spam. If some one have a template or a solution for this please write here or PM Kind regards, Alexei

  • Problem debugging jboss with Jdeveloper

    I have server side project builed by jboss , I use JDEveloper. I wont to debug this project or run jboss through jdeveloper, I can't do it. How can I do it?

  • Continued GC while memory not full

    Encounter one issue about out of memory, server continued trigger gc and full gc while the memory is less used, eapesicially the [young]. Please help.Also, what is the theory to trigger gc?Many thanks. Not calling System.gc(). Performing 10 VU's test

  • Help with fill, in shape tool?

    Hi InDesign CS 4. When I drag a new rectangle it always fills with a fade from left to right with a border line that fades as well. It's the same with elipses or polygons. Trying to change the fill, or the line color has no effect. I don't know how I

  • HT5616 I can not use my icloud email in app Store in August please help

    I can not use my icloud email in app Store in August please help ?!?