ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel charts on the fly with ASP (https://www.excelbanter.com/excel-programming/288528-excel-charts-fly-asp.html)

Steve T[_4_]

Excel charts on the fly with ASP
 
I have a script which creates an excel workbook, dumps a load of data into
it and calls the following code. The ranges are created from a query and
relate to the data that has just been added to the workbook.

xlApplication.Sheets("Sheet1").Select
xlApplication.ActiveSheet.Range("A1:A10,C1:C10:D1: D10,F1:F10").Select
xlApplication.Charts.Add
xlApplication.ActiveChart.SetSourceData
xlApplication.Sheets("Sheet1").Range("A1:A10,C1:C1 0:D1:D10,F1:F10"), 2
xlApplication.ActiveChart.Location 1
xlApplication.ActiveChart.HasDataTable = True
xlApplication.ActiveChart.DataTable.ShowLegendKey = True
xlApplication.ActiveChart.HasTitle = True
xlApplication.ActiveChart.ChartTitle.Characters.Te xt = strGraphTitle
xlApplication.ActiveChart.DisplayBlanksAs = 3
xlApplication.ActiveChart.PlotVisibleOnly = True
xlApplication.ActiveChart.Name = strChartTabName

A1:A10 contain the x-axis data and the rest of the ranges are plotted on the
chart. All ranges are of the same type [i.e. number or currency or time
etc...]

The excel file is then saved and opened in a web browser.

At first I thought that it was working really well, but excel gets confused
when the data is in a time format. For some reason this screws up the chart.
Closer inspecting shows that the data ranges are overridden and the chart is
meaningless.

Strangely, if I record a macro in excel [which produces equivalent vb code]
that plots the same chart on the data I get the same result.

Could this be a quirk of excel or is there something glaringly obvious that
I have missed.

Many thanks in advance.
Steve





All times are GMT +1. The time now is 08:13 PM.

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