Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Error

Error

Scheduled Pinned Locked Moved ASP.NET
helpcsharpcssasp-netdata-structures
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    shanthi jothi
    wrote on last edited by
    #1

    Hi, I have create chart in excel for grid data in asp.net 2.0. my code is Dim xlWorkBook As Excel.Workbook Dim xlWorkSheet As Excel.Worksheet xlWorkBook = New Excel.Application().Workbooks.Add(Missing.Value) xlWorkBook.Application.Visible = True xlWorkSheet = xlWorkBook.ActiveSheet ' Gets the dataset containing the data 'ds4 is gridview dataset Dim dsData As DataSet = ds4 Dim i As Integer = 2 ' Outputting the fieldnames in pink bold color xlWorkSheet.Cells(1, 1) = "Student ID" xlWorkSheet.Cells(1, 2) = "Student Name" xlWorkSheet.Cells(1, 3) = "Maths" xlWorkSheet.Cells(1, 4) = "science" xlWorkSheet.Cells(1, 5) = "Total" xlWorkSheet.Range("$A1:$E1").Font.ColorIndex = Excel.Constants.xlColor1 xlWorkSheet.Range("$A1:$E1").Font.Bold = True ' Outputting the data For Each dr As DataRow In dsData.Tables(0).Rows xlWorkSheet.Cells(i, 1) = dr(0) xlWorkSheet.Cells(i, 2) = dr(1) xlWorkSheet.Cells(i, 3) = dr(2) xlWorkSheet.Cells(i, 4) = dr(3) ' Building the formula for calculating the sum xlWorkSheet.Cells(i, 5).Formula = "=SUM($C{0}:$D{0})".Replace("{0}", i.ToString()) ' Going to the next row i = i + 1 Next ' Auto fit the columns xlWorkSheet.Columns.AutoFit() ' Generating the graph Dim chart As Excel.Chart chart = xlWorkBook.Charts.Add() With chart .ChartType = Excel.XlChartType.xlColumnClustered .SetSourceData(xlWorkSheet.Range("A1:E11"), 2) .HasTitle = True .ChartTitle.Characters.Text = "Students' marks" .Axes(1, Excel.XlAxisGroup.xlPrimary).HasTitle = True .Axes(1, Excel.XlAxisGroup.xlPrimary).AxisTitle.Characters.Text = "Students" .Axes(2, Excel.XlAxisGroup.xlPrimary).HasTitle = True .Axes(2, Excel.XlAxisGroup.xlPrimary).AxisTitle.Characters.Text = "Marks" End With 'Catch ex As Exception ' Throw ex 'End Try the error is [IndexOutOfRangeException: Cannot find table 0.] Please help me

    A C 2 Replies Last reply
    0
    • S shanthi jothi

      Hi, I have create chart in excel for grid data in asp.net 2.0. my code is Dim xlWorkBook As Excel.Workbook Dim xlWorkSheet As Excel.Worksheet xlWorkBook = New Excel.Application().Workbooks.Add(Missing.Value) xlWorkBook.Application.Visible = True xlWorkSheet = xlWorkBook.ActiveSheet ' Gets the dataset containing the data 'ds4 is gridview dataset Dim dsData As DataSet = ds4 Dim i As Integer = 2 ' Outputting the fieldnames in pink bold color xlWorkSheet.Cells(1, 1) = "Student ID" xlWorkSheet.Cells(1, 2) = "Student Name" xlWorkSheet.Cells(1, 3) = "Maths" xlWorkSheet.Cells(1, 4) = "science" xlWorkSheet.Cells(1, 5) = "Total" xlWorkSheet.Range("$A1:$E1").Font.ColorIndex = Excel.Constants.xlColor1 xlWorkSheet.Range("$A1:$E1").Font.Bold = True ' Outputting the data For Each dr As DataRow In dsData.Tables(0).Rows xlWorkSheet.Cells(i, 1) = dr(0) xlWorkSheet.Cells(i, 2) = dr(1) xlWorkSheet.Cells(i, 3) = dr(2) xlWorkSheet.Cells(i, 4) = dr(3) ' Building the formula for calculating the sum xlWorkSheet.Cells(i, 5).Formula = "=SUM($C{0}:$D{0})".Replace("{0}", i.ToString()) ' Going to the next row i = i + 1 Next ' Auto fit the columns xlWorkSheet.Columns.AutoFit() ' Generating the graph Dim chart As Excel.Chart chart = xlWorkBook.Charts.Add() With chart .ChartType = Excel.XlChartType.xlColumnClustered .SetSourceData(xlWorkSheet.Range("A1:E11"), 2) .HasTitle = True .ChartTitle.Characters.Text = "Students' marks" .Axes(1, Excel.XlAxisGroup.xlPrimary).HasTitle = True .Axes(1, Excel.XlAxisGroup.xlPrimary).AxisTitle.Characters.Text = "Students" .Axes(2, Excel.XlAxisGroup.xlPrimary).HasTitle = True .Axes(2, Excel.XlAxisGroup.xlPrimary).AxisTitle.Characters.Text = "Marks" End With 'Catch ex As Exception ' Throw ex 'End Try the error is [IndexOutOfRangeException: Cannot find table 0.] Please help me

      A Offline
      A Offline
      AlexeiXX3
      wrote on last edited by
      #2

      It must be because there is no table at index 0 in your dataset Make sure you check that there is a table in the dataset

      shanthi jothi wrote:

      ' Gets the dataset containing the data 'ds4 is gridview dataset Dim dsData As DataSet = ds4

      What do you mean by this??

      Alexei Rodriguez

      1 Reply Last reply
      0
      • S shanthi jothi

        Hi, I have create chart in excel for grid data in asp.net 2.0. my code is Dim xlWorkBook As Excel.Workbook Dim xlWorkSheet As Excel.Worksheet xlWorkBook = New Excel.Application().Workbooks.Add(Missing.Value) xlWorkBook.Application.Visible = True xlWorkSheet = xlWorkBook.ActiveSheet ' Gets the dataset containing the data 'ds4 is gridview dataset Dim dsData As DataSet = ds4 Dim i As Integer = 2 ' Outputting the fieldnames in pink bold color xlWorkSheet.Cells(1, 1) = "Student ID" xlWorkSheet.Cells(1, 2) = "Student Name" xlWorkSheet.Cells(1, 3) = "Maths" xlWorkSheet.Cells(1, 4) = "science" xlWorkSheet.Cells(1, 5) = "Total" xlWorkSheet.Range("$A1:$E1").Font.ColorIndex = Excel.Constants.xlColor1 xlWorkSheet.Range("$A1:$E1").Font.Bold = True ' Outputting the data For Each dr As DataRow In dsData.Tables(0).Rows xlWorkSheet.Cells(i, 1) = dr(0) xlWorkSheet.Cells(i, 2) = dr(1) xlWorkSheet.Cells(i, 3) = dr(2) xlWorkSheet.Cells(i, 4) = dr(3) ' Building the formula for calculating the sum xlWorkSheet.Cells(i, 5).Formula = "=SUM($C{0}:$D{0})".Replace("{0}", i.ToString()) ' Going to the next row i = i + 1 Next ' Auto fit the columns xlWorkSheet.Columns.AutoFit() ' Generating the graph Dim chart As Excel.Chart chart = xlWorkBook.Charts.Add() With chart .ChartType = Excel.XlChartType.xlColumnClustered .SetSourceData(xlWorkSheet.Range("A1:E11"), 2) .HasTitle = True .ChartTitle.Characters.Text = "Students' marks" .Axes(1, Excel.XlAxisGroup.xlPrimary).HasTitle = True .Axes(1, Excel.XlAxisGroup.xlPrimary).AxisTitle.Characters.Text = "Students" .Axes(2, Excel.XlAxisGroup.xlPrimary).HasTitle = True .Axes(2, Excel.XlAxisGroup.xlPrimary).AxisTitle.Characters.Text = "Marks" End With 'Catch ex As Exception ' Throw ex 'End Try the error is [IndexOutOfRangeException: Cannot find table 0.] Please help me

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        You are flooding these forums with the most trivial questions. You obviously are very new to the world of programming. If you are trying to do such complex things because it's your job, then shame on you and on your company. If you have a choice, then you should try more simple tasks, and you should definately try reading some books. If you have no choice, then you should expect that people will soon get sick of doing your job for you, and stop answering you. We're here to help people who want to learn, not people who are trying to do jobs they are in no way remotely qualified for.

        Christian Graus Driven to the arms of OSX by Vista.

        N 1 Reply Last reply
        0
        • C Christian Graus

          You are flooding these forums with the most trivial questions. You obviously are very new to the world of programming. If you are trying to do such complex things because it's your job, then shame on you and on your company. If you have a choice, then you should try more simple tasks, and you should definately try reading some books. If you have no choice, then you should expect that people will soon get sick of doing your job for you, and stop answering you. We're here to help people who want to learn, not people who are trying to do jobs they are in no way remotely qualified for.

          Christian Graus Driven to the arms of OSX by Vista.

          N Offline
          N Offline
          Nishant Singh
          wrote on last edited by
          #4

          Just Cool down "Graus" :-D may be her job is at stake .... There is no dearth of brutal and sadistic Project Managers ;) poor thing i think she is really desperate

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups