Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel macros and ASP (<- is it possible to use ?) 1

Status
Not open for further replies.

pdevteam

Programmer
Jun 5, 2001
6
FI
Hello!

I wonder if it's possible to use Excel macros within ASP -code?

I'm developing an application which retrieves data from SQL Server to Excel.

Can I use Excel macros somehow to generate chart automatically from the query contents (only two columns of data are returned - text-col and number-col)?

Thanks!
 
The easiest way to accomplish this..is to set up an excel sheet with a defined data area, from which a chart/graph will be produced, and just insert your data into that area....
 
I'm developing a web-application with ASP which retrieves data from the database. The server is WinNT 4.0 Server, IIS4.0 and SQL Server 7.

It passes the data to Microsoft Excel 2000 which is embedded to Internet Explorer.

The problem is that I get data to Excel pretty fine, but the problem is that the script should create a chart automatically from the data got from the database.

I've tried to use the following code to generate the chart (It works pretty fine when running as Excel macro), but it does not show the chart (and doesn't show any errors):

<%
Set MyExcelChart = CreateObject(&quot;Excel.Sheet&quot;)

MyExcelChart.ActiveSheet.Name = &quot;Object 1&quot;

MyExcelChart.Application.Visible = True

MyExcelChart.ActiveSheet.Range(&quot;a2:b4&quot;).Select

MyExcelChart.Charts.Add

MyExcelChart.ActiveChart.ChartType = 97

MyExcelChart.ActiveChart.BarShape = 3

MyExcelChart.ActiveChart.HasTitle = True

MyExcelChart.ActiveChart.ChartTitle.Text = &quot;AutoChart&quot;

MyExcelChart.ActiveChart.SetSourceData MyExcelChart.Sheets(&quot;Object 1&quot;).Range(&quot;a2:b4&quot;), PlotBy = 1

MyExcelChart.ActiveChart.Location 1

'MyExcelChart.ActiveChart.Location 1

MyExcelChart.ActiveChart.HasDataTable = True

MyExcelChart.ActiveChart.DataTable.ShowLegendKey = True
%>

Another problem is that the script names the Excel workbook randomly from some reason. I've queries stored to the database from where the script gets the SQL and produces graph.

If you have any suggestions (examples) or ideas how to implement this, I would appreciate it. I've tried to find example from the net few days but found nothing.

Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top