Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4625336
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:15:27+00:00 2026-05-22T03:15:27+00:00

my app in c# has a prob in writing to excel sheet. My app

  • 0

my app in c# has a prob in writing to excel sheet.
My app create excel sheet for its purpose and does not write in it.
the below code is for reference only..

class a
{
    void m()
    {
        b bee=new b();    
        Excel.Application oXL;
        Excel._Workbook oWB;
        b.write(oXL,oWB); //will be called multiple times
    }
}

class b
{
    static b() //declared static so that only once excel workbook with sheets will be     created
    {
        Excel._Application oXL = new Excel.Application();
        Excel._Workbook oWB = (Excel._Workbook)(oXL.Workbooks.Add(Type.Missing));
    }

    write( Excel.Application oXL, Excel._Workbook oWB)
    {
        oXL.Visible = true; //Here its throwing, Object reference not set to an instance of an  
                    //Object
    }
}

Help will be appreciated, thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T03:15:28+00:00Added an answer on May 22, 2026 at 3:15 am

    I think you want to have code along the lines of the following:

    class a
    {
        b bee;
        public a()
        {
            bee = new b();
        }
    
        void m()
        {
            b.write(oXL,oWB); //will be called multiple times
        }
    }
    
    class b
    {
        public b()
        {
            Excel._Application oXL = new Excel.Application();
            Excel._Workbook oWB = (Excel._Workbook)(oXL.Workbooks.Add(Type.Missing));
        }
    
        write()
        {
            oXL.Visible = true;
        }
    }
    

    You then need to make sure, that you create only as many instances of a as you want Excel sheets.

    You can use it like this:

    a aa = new a();
    for(...)
        aa.m();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my app has a bug, and i believe its because I'm not reseting the
My app has several buttons which trigger different events. The user should NOT be
My app has the ability of sharing its content between different instances of the
My app has many controls on its surface, and more are added dynamically at
my app has a photoshop like feature wherein the user can create a new
My app has been rejected 2 times because its only a iPhone app, the
My app has permissions, and certain tests need to not be run when a
My app has an options menu that is available in almost all Activities, which
My app has the ability to store passwords. But these are important passwords, so
My app has started throwing errors when I try to save a particular class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.