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

  • Home
  • SEARCH
  • 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 9236431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:17:27+00:00 2026-06-18T07:17:27+00:00

Hi I am writing a C# code to generate chart in an excel sheet,

  • 0

Hi I am writing a C# code to generate chart in an excel sheet, fetching data from SQL server.
Writing the following code to to declare chart. It is giving exception for Index. Help me solve this.

Worksheet sheet1 = workbook.Worksheets[0];

Worksheet sheet2 = workbook.Worksheets[1];

Chart chart = sheet2.Charts[0];

Exception is in chart declaration.

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-06-18T07:17:29+00:00Added an answer on June 18, 2026 at 7:17 am

    Exception is probably occurring because the the Charts collection of sheet2 is empty.
    Check to see if the count of sheet2.Charts is greater than zero before calling Charts[0]:

    if (sheet2.Charts.Count > 0)
    {
        Chart chart = sheet2.Charts[0];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing code to import dozens of moderate sized text files into SQL SERVER
I am writing some code to generate an opml file from a list of
Im writing some code in R whereby i need to generate a data set
The following is excerpted from Writing solid code , page 115. int strcmp( const
Hi I took the following code from a program I'm writing to check a
I am writing code to clone object but have no cue from Hobo documentation.
I am writing code for a database to fetch data in an activity which
I'm writing some code to generate a full screen page with a header. I'm
I am in the following situation: I am writing code for a kernel that
I am writing code to perform the following steps; Register a .net .dll and

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.