Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 31st, 2007, 07:37 AM
Registered User
 
Join Date: Jan 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to hemant.dna Send a message via Yahoo to hemant.dna
Default Excel sheet accessing(edit/update) in asp.net

Excel Version Dll 11.o
name space :
using Microsoft.Office.Interop;
using Office;

#region Code for Access the excelsheet
        public void GetExcel_Method()
        {
            Microsoft.Office.Interop.Excel.Application oExcel = null;
            Microsoft.Office.Interop.Excel.Workbook oBook = null;
            Microsoft.Office.Interop.Excel.Worksheet oSheet = null;
            Microsoft.Office.Interop.Excel.Range oRng;
            object missing = Type.Missing;
            try
            {
                oExcel = new Microsoft.Office.Interop.Excel.Application();

                oBook = oExcel.Workbooks.Open(@"C:\\inetpub\\wwwroot\\Test Excel\\NMDS.xls",missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
                oExcel.Visible = true;
                oBook.Activate();
                oSheet = (Microsoft.Office.Interop.Excel.Worksheet) oBook.Worksheets["Employee"];
                oSheet.get_Range("C5","C5").set_Value(Type.Missing ,"India Software Solutions");
                oSheet.get_Range("C9","C9").set_Value(Type.Missing ,"Hemant");

                oSheet.SaveAs("C:\\Documents and Settings\\Administrator\\Desktop\\NMDS1.xls",Micro soft.Office.Interop.Excel.XlFileFormat.xlExcel7,Ty pe.Missing,Type.Missing,Type.Missing,Type.Missing, Type.Missing,Type.Missing,Type.Missing,Type.Missin g);
                oExcel.Quit();
                System.Runtime.InteropServices.Marshal.ReleaseComO bject(oExcel);
                System.Runtime.InteropServices.Marshal.ReleaseComO bject(oBook);

                System.GC.Collect();

            }
            catch (Exception ex)
            {
                Response.Write("Error accessing Excel: " + ex.ToString());
            }



        }

        #endregion


i am getting this error =="Object is not set to instant"

"Error accessing Excel: System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Office.Interop.Excel.Workbooks.Open(Stri ng Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad) at London.NMDS_Profile.Test_XML.GetExcel_Method() in d:\sfc_new\nmds_profile\test_xml.aspx.cs:line 131 "

SDS





Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.Net Moving Chart to Excel Sheet 2 sili18 General .NET 0 June 15th, 2007 12:39 PM
Opening and emailing Excel sheet through ASP.Net venterjo ASP.NET 1.0 and 1.1 Basics 0 October 10th, 2005 09:55 AM
how to edit and update my access db using asp.net method ASP.NET 1.0 and 1.1 Basics 4 April 25th, 2005 03:03 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.