Error
-
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
-
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
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
-
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
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.
-
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.
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