.NET code hangs setting up a chart

  • Thread starter Thread starter Chris Magoun
  • Start date Start date
C

Chris Magoun

I have some .NET code that opens an excel spreadsheet, dumps some data into
it, and then makes a chart. The problem is that once the data becomes so
big, the system seems to hang. The routine invovled looks like this:

Private Sub CreateExcelChart(ByVal xl As Excel.Application, ByVal wb As
Excel.Workbook, ByVal xlRow As Integer, ByVal xlFirstCol As Integer, ByVal
xlLastCol As Integer)
Dim sheetData As Excel.Worksheet = wb.Sheets("ChartData")

Select Case Me.ExcelGraphType
Case OLAPGridExcelGraphType.BarGraph
'This code branch is not the issue
Case OLAPGridExcelGraphType.LineGraph
'This one is
sheetData.Range(sheetData.Cells(2, 1),
sheetData.Cells(xlRow - 2, xlLastCol)).Select()
wb.Charts.Add()
wb.ActiveChart.ChartType = Excel.XlChartType.xlLineMarkers<<<<<<< THIS IS WHERE I HANG

Dim s As Excel.Series
For Each s In wb.ActiveChart.SeriesCollection
s.XValues = "=ChartData!R1C" & xlFirstCol & ":R2C" &
xlLastCol
Next
End Select

wb.ActiveChart.Move(After:=wb.Sheets(2))
End Sub

Has anyone seen this? Thanks,
Chris Magoun
 
I see the problem now. The plotBy = Rows can only take up to 255 rows or
else it chokes and throws a dialog, which is hanging the system.

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top