ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   .NET code hangs setting up a chart (https://www.excelbanter.com/excel-programming/335435-net-code-hangs-setting-up-chart.html)

Chris Magoun

.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



Chris Magoun

.NET code hangs setting up a chart
 
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


"Chris Magoun" wrote in message
...
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





All times are GMT +1. The time now is 10:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com