Reading in Excel file, Excel still open in Task Manager

Here's my code:

 

using Microsoft.Office.Interop.Excel;        
///
        string filename = @"C:\example3.xlsx";
        object updateLinks = 0;
        object readOnly = true;
        object format = 5;
        object password = "";
        object writeResPassword = "";
        object ignoreReadOnlyRecommended = true;
        object origin = XlPlatform.xlWindows;
        object delimiter = "";
        object editable = false;
        object notify = false;
        object converter = 0;
        object addToMRU = false;
        object local = false;
        object corruptLoad = false;

        ApplicationClass appcls = new ApplicationClass();

        WorkbookClass wbook = (WorkbookClass)(appcls.Workbooks.Open(filename,
            updateLinks, readOnly, format, password, writeResPassword, ignoreReadOnlyRecommended,
            origin, delimiter, editable, notify, converter, addToMRU, local, corruptLoad));

        //Get the first sheet (index can be replaced by Sheet Name String)
        Worksheet wsht = (Worksheet)wbook.Worksheets[1];    
        
        //Do other stuff

        wbook.Close(false, false, false);
  

 

I am working on a project where I need to read an excel file and output it to a repeater.  I took a look at my Task Manager and was surprised to see that there were about 10 or so EXCEL.exe processes running.  I thought that closing the workbook in the code would kill the process, but apparently not.  Anyone know how to fix this?

0
Apples
5/8/2008 3:00:37 PM
asp.net.integration 1945 articles. 0 followers. Follow

5 Replies
640 Views

Similar Articles

[PageSpeed] 21

I posted this recently in another thread.

This is small static function I have in my HelperClass. You can remove the static keyword if you don't want to put it in a class. 

using System.Diagnostics;
 // static method to kill all excel processes
        public static void KillExcel()
        {
            try
            {
                Process[] ps = Process.GetProcesses();
                foreach (Process p in ps)
                {
                    if (p.ProcessName.ToLower().Equals("excel"))
                    {
                        p.Kill();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERROR " + ex.Message);
            }
        }

Thanks,
Max
Let Me Google That For You!
0
bullpit
5/8/2008 3:35:26 PM

bullpit:

I posted this recently in another thread.

This is small static function I have in my HelperClass. You can remove the static keyword if you don't want to put it in a class. 

using System.Diagnostics;
 // static method to kill all excel processes
        public static void KillExcel()
        {
            try
            {
                Process[] ps = Process.GetProcesses();
                foreach (Process p in ps)
                {
                    if (p.ProcessName.ToLower().Equals("excel"))
                    {
                        p.Kill();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERROR " + ex.Message);
            }
        }

 

Say, for instance, that I'm working on something completely different in Excel, and I run this program.  Will that destroy whatever I'm working on? 

0
Apples
5/8/2008 3:38:20 PM
0
bullpit
5/8/2008 4:12:00 PM
Use Quit() method of application. When initializing application you can say if you want to be windowed or windowless.
Don't forget to mark solution providing post as "Answered".
It helps others to find correct solutions!

Also visit my ASP.NET blog!
0
DigiMortal
5/8/2008 5:08:19 PM
Reply:

Similar Artilces:

HyperLinkField links to Excel files always open in Excel as Read-Only.
I have an ASP.net site on an IIS 6 server. On one page, I have a GridView containing a HyperLinkField. This field contains links that point to Excel files on the server, albeit on another drive. The links open properly in Excel when clicked, however the files aways open as Read-Only. I want these files to be writable after they open. The permissions on the directory containing the Excel files is set for full access to Everyone, including the IIS and ASPNET users. Also, when these files are browsed over the network (not via web broswer), they open properly (writable). Why are these files...

Got error after open excel file from server..During Export Excel File
this error appears if you have tried to save a workbook on a drive and you do not have Modify and Delete permissions to the location where the file is being saved. It is also possible that another user has a read lock on the file.Excel saves a file using three steps (if the file already exists in the target location):Creates a temporary file with a randomly generated name, such as 4CCA4100.Deletes the original file.Renames the temporary file to the original file name.If Excel cannot delete the original file or cannot rename the temporary file, this error message appears.To temporarily work a...

Excel experts : Filling an complex Excel file and parsing a complex Excel file
I am stuck with below mentioned problem The requirement is that, we have Excel file template(.xls) which has Macros and most of the Worksheets are either hidden OR locked. When the end user clicks on a button to download it, follows modifications has to be done to the Excel sheet. Unlock the Excel worksheet, fill some data at certain cells and then lock it back Write some data into a hidden worksheet There are two options as far as I know Excel Interop/MICROSOFT Excel 11.0 Object Library  OLEDB Driver I cannot go with option 1 becaus...

How to open and read excel file
Dear All, How to open and read excel file using powerbuilder? Joe You can use OLE automation or you can use the Excel ODBC driver and load the file contents into a datawindow/datastore. -- <hopethishelps/> Roy Kiesler [TeamSybase] Sybase Developer Network -- http://sdn.sybase.com <Joe> wrote in message news:046DB21DCA1E3B2E004C26AE85256C13.004C26BC85256C13@webforums... > Dear All, > > How to open and read excel file using powerbuilder? > > Joe One method is through OLE automation. Check http://my.sybase.com/detail?id=47867 and ht...

Saving Excel file to be opened read-only
I've written a program in C# that creates an Excel worksheet.  I want to make it so that when it opens, it can only be opened in read-only mode so that the file can't be locked on the network.  How can I accomplish this?  My current SaveAs function is as follows: WSC_oXL.DisplayAlerts = false; WSC_oXL.ActiveWorkbook.SaveAs(WSC_save_path, Excel.XlFileFormat.xlWorkbookNormal, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); WSC_oXL.DisplayAlerts = tru...

How to Dynamically open excel through IE without creating an excel file
Hi, Is there a way to open excel within Internet Explorer to show some data from database (Oracle),through excel without actually creating an excel file on the server in ASP.net,dynamically? Thanks, Girish. you can send html down to the client and then set the contenttype header to the excel. it needs to be atleast excel97 or higher to be able to interpret the html. Response.ContentType = "application/vnd.ms-excel" Response.AppendHeader("Content-Disposition", "filename=blah.xls;") Mike Banavige~~~~~~~~~~~~Need a site code sample in a differe...

How to Read Excel File AT VB.NET
Hi anyone know how do i read excel file at VB.net & display the result in a label or something.. e.g i know cell A2 is a string of text - e.g Hello this is the P/L for the month  i want grab that and put in a label etc.Thanks , it would be good if can refer me to url on using Microsoft Excel Library Object & its coding to connect, close connection , grab data from cell and input back the data. Regards,Bao  My Anime Site My Quality Animes HR BLOG With the proper connection string (http://www.connectionstrings.com/?carrier=excel) you can query it like ...

ADO.Net for Excel files
I wrote a windows form application in C# that uses ADO.Net to read from an Excel file. I receive xls files but have to manually save them as xlsx files because I can't get the program to read xls files (I get "External table is not in the expected format"). As an aside, for broadest .net compatibility, I set each of the Projects (which create assemblies/dlls) for the application to .net framework 2.0. I have 2 questions: 1. How can I get my program to read xls files when Excel 2007 is installed? 2. How can I support environments where Excel 2002 and Excel 2003 are installe...

How to open and read Excel 2007 file
Would you please tell me what component(s) do I need to add to my form to open and read Excel 2007 spreadsheet under C++ builder 2007 using VCL Thank you for your help MB ...

opening excel file with vb.net?
Hi, I'm trying to open an excel file using vb.net. I've found a way on the web but I'm getting this error: <script runat="server"> Sub LinkButton_Click(sender As Object, e As EventArgs) Dim xlApp As Excel.Application Dim xlWB1 As Excel.Workbook Set xlApp = New Excel.Application xlApp.Visible = True Set xlWB1 = xlApp.Workbooks.Open("test.xls") xlWB1.Close Set xlWB1 = Nothing xlApp.Quit Set xlApp = Nothing End Sub </script> Error: Excel.Application not defined. Which .net class handles the excel object?...

Reading Excel Files from a .Net Web Form
Hi, This might be a dumb question, but ... When reading an Excel file from a .Net Web Form, is it necessary to have Microsoft Excel actually installed on the client machine running the web form? Also, do the Excel files being read need to be saved as "values only" or can the values be extracted from a spreadsheet where the cells contain formulas? Thanks. -Wayne Hi, For the 1st part, Office is not necessary to be installed. But Download the Office XP PIAs and use them to develop Office XP solutions with Visual Studio .NET. For 2nd Part I think you need to use Values.Regar...

Convert dataset to excel in xslt and open in new browser or new excel file
I have a problem that look very eazy , i am using xslt to convert datset to excel - working greta here is the cod( server side ) DataSet dsExcel = new DataSet(); dsExcel = (DataSet)Session["DatasetDataToExcel"]; //Remove the tabel pk in the db from excel //dsExcel.Tables[0].Columns.Remove("CustTabelId");dsExcel.WriteXml(Server.MapPath("datasetDataXml.xml")); Response.ContentType = "application/vnd.ms-excel";Response.Charset = ""; DataSet ds = new DataSet();ds.ReadXml(Server.MapPath("datasetDataXml.xml")); XmlDataDocument x...

How to copy data from one excel file to other excel file
Hi I have two excel file (Ex1 and Ex2), both have same template (headers) and data will be populated from the dataset. Upto this step its works fine. My question : How to copy the data  form 6th row to last row of "Ex2" and paste it into the "Ex1" after the last row in Ex1.   Advance thanks Have a look here: For VB - http://support.microsoft.com/kb/306022 For C# - http://support.microsoft.com/kb/306023/ -Damien  Visoft, Inc - Home | Blogs Latest Blog Post: ASP.NET 4.0 AJAX Preview 4 - Client Templates...

Problem opening and excel file in IE 6 using application/vnd.ms-excel
Can someone help with this?I am having a problem opening an excel file in IE, on PC's that have Office 2000 installed.  I am setting the Response.ContentType = "application/vnd.ms-excel".This works fine in other browsers, just in IE a blank excel sheet is opened.Any suggestions would be appreciated. What are the rest of the headers you're sending?  Also, are there any noticeable differences between the machines where this works and the ones where it doesn't?Peter BrunoneMS MVP, ASP.NETFounder, EasyListBox.comDo the impossible, and go home early. The only major differences I hav...

Web resources about - Reading in Excel file, Excel still open in Task Manager - asp.net.integration

Reading (process) - Wikipedia, the free encyclopedia
Reading is a complex cognitive process of decoding symbols in order to construct or derive meaning ( reading comprehension ). It is a means of ...

Everybody Else Is Reading This
I’m A Doctor And I’m Coming Around (In Most Cases) On Telehealth MedCity News Christian Bale Still Experiencing PTSD From American Psycho Research ...

"One evening early this summer, I opened a book and found myself reading the same paragraph over and ...
"I simply couldn’t marshal the necessary focus. I was horrified. All my life, reading books has been a deep and consistent source of pleasure, ...

READING THE ELECTORAL TEA LEAVES: We Win, They Lose
By Richard Larsen It’s hard to think of any other way to characterize the off-year elections results across the nation, than that the rejection ...

Manufacturing ISM Contracts; Lowest Reading Since June 2009; Glimmers of Hope Extinguished
After flirting with contraction for three months, the Manufacturing ISM fell into negative territory with a 48.6 reading, below the lowest Econoday ...

A Reading for the Pigou Club
Toward a Pigouvian State by Jonathan Masur and Eric Posner in the University of Pennsylvania Law Review .

Weekend Reading: Abraham Lincoln: First Annual Message to Congress
Abraham Lincoln (December 3, 1861): "If any good reason exists why we should persevere longer in withholding our recognition of the independence ...

Syed Rizwan Farook’s Dating Profile Shows He Liked Reading ‘Religious Books’ And Shooting Target Practice ...
Syed Rizwan Farook’s Dating Profile Shows He Liked Reading ‘Religious Books’ And Shooting Target Practice

ICYMI: Reading a fly's mind, real Minecraft phone and more
Today on In Case You Missed It: Neuroscientists figured out what fruit flies are thinking with fluorescent molecules. Minecraft now has an internal ...

Evening Reading
From krgthulu. Or buy Robert's book! Krgthulu's come a long way (as I have, in my own somewhat different way.

Resources last updated: 12/6/2015 3:58:30 PM