views:

851

answers:

2

I have an excel sheet containing excel chart. I am able to display entier excel sheet on browser using an iframe. However, I only want to display the chart present inside the excel sheet on the browser.

How do I achieve this? I see that it needs Javascript + ActiveX APIs. I tried but couldn't get it to work.

Please see code given below. It doesn't work as I am not able to set data attribute of "object" tag dynamically. It doesn't allow.

<object id="objFrame" data="" type="application/vnd.ms-excel"></object>

<script>
var Excel = new ActiveXObject("Excel.Application"); 
Excel.Visible = false;
document.getElementById("objFrame").data  = Excel.Workbooks.Open("Test.xls").Sheets("Chart1");
Excel.Quit();
</script>

Is there any other way to achieve this? Please post sample code. Thanks.

+1  A: 

You should check this tool out, I believe this will achieve exactly what you're looking for, without having to load the memory bloat/leak known as the Office COM server, into browser memory, and feel like your violating security best practices.

James
Thanks. But I want to use only Javascript + ActiveX to achieve this. No third party tools.
Chandan .
+1  A: 

SpreadsheetGear for .NET provides the ability to load Excel workbooks, plug in values, calculate and then render a chart (or a range of cells which contain a chart) on the server which can then be displayed in the browser. You can see live ASP.NET (C# and VB) samples here.

Disclaimer: I own SpreadsheetGear LLC

Joe Erickson
Thanks. But I want to use only Javascript + ActiveX to achieve this. No third party tools.
Chandan .