.NET code hangs setting up a chart
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
wb.ActiveChart.PlotBy = Excel.XlRowCol.xlRows
<<<<<<< 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
|