Excel charts on the fly with ASP

S

Steve T

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:C10: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.Text = 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
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top