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.
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.
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
You might want to check the Funfun Excel add-in. Basically, Funfun allows you to use JavaScript directly in your Excel as the image below shows.
Here I have a sample chart which is plotted using HighChart.js with data in the spreadsheet. You could see the chart at the right side of your Excel. You could then click the button at the left-top corner of the chart to open the chart in default browser. Which looks like this.
Also, if you want to show both the spreadsheet and the chart in the browser. You have two option.
The first is to use Excel online. Then you have the same thing on your browser as in your local Excel.
As for the second option, Funfun also has an online editor in which you could explore with your JavaScript code alongside with your data.
You could check the detailed code of this example on the link below.
https://www.funfun.io/1/edit/5a439b96b848f771fbcdedf0
Disclosure: I'm a developer of Funfun
Related
I'm creating a word add-in using the word javascript api that pulls data from database, allowing users to create tables/text with the data. I would now like to add the functionality to change charts based on the data
I can see information about editing charts in the documentation for excel, however I can't see anything for word.
Is it possible to edit chart data within word?
If so, would someone be able to provide me an example or link to the appropriate location to look?
I've tried doing it in excel and have made progress but can't see anything on the word side
I'm afraid that there are no chart editing APIs in the Word JavaScript yet. It's a good idea, and you can suggest it at Office Developer Suggestion Box.
In the meantime, a chart in Word is a element in the file's OOXML. You could try the following workaround: Your add-in could get the XML using the Office.Document.getFileAsync, edit the OOXML, then use the Word createDocument API to create a new document that is just like the original, but with your chart edits.
I have a requirement wherein we have to display a chart and few parameters (date, name etc) inside a pdf file.
The user should be able to modify the chart depending upon the data selected by the user.
I have seen some examples https://www.youtube.com/watch?v=Z5bdBeFwNCU but not sure how these are getting generated.
Any pointer is highly appreciated.
Also I am a java script developer so if there is any solution in JS It would be easier for me to follow
You can look into the docmentation of the creators (Adobe):
Using JavaScript with PDF files - Tutorials about process.
Javascript API reference for PDF format - a PDF document listing all commands.
I did a few projects where charts/diagrams are created on the fly, based on user entries. For that, I used a combination of form fields and annotations, whose parameters are calculated using Acrobat JavaScript.
There is also an undocumented function in Acrobat JavaScript which allows to create the icon for button form fields.
As the actual approach depends a lot on the kind of information and graphs, one would have to look at what has to be accomplished. Feel free to contact me in private, if there is some interest. It might be worthwhile to look at "make or buy"…
Is it possible to be able to upload an excel document with varying ranges of data, and have that data dynamically displayed in a basic form of chart(bar, pie, etc.) on our company website.
After doing some research I figured the only two possible ways to maybe do something like this is to use a very complicated macro in VBA or a Javascript parser to read the data and display it then. The data that will eventually go in here will have sensitive information so I cannot use google charts or anything like that.
This problem has to be divided into two parts.
One -part is to gather and process the information needed to display the chart.
Second - This is the easiest, a way to display a chart in HTML. For this, you can use www.c3js.org javascript library to display the chart in HTML.
Regarding part one, it depends in which technology is built your website.
For example, If it is in php, you will need to find a library in php, which can read and parse excel files.
Then you have to create a service in your website, where the data is going to be provided. For example,
www.yourcompany.com/provideChartData.php
You can format the response as json format.
Once you have solved that, you only have to call the service from your page, and the data will be dynamically displayed. You can call it using jquery library for javascript ($.post("www.yourcompany.com/provideChartData.php",function (data) { code to display chart ....}))
There is no real easy way to do this that I have found. I have had to manually parse these things in the past but there are some libraries out there for node that might help you.
https://www.npmjs.com/package/node-xlsx
You can also export form excel as CSV. When you do this, me sure to set the custom separator to something other than ',' and you should be fine to import it into a large array and get the data/charts you need.
https://github.com/wdavidw/node-csv
Hope that helps.
so I have an IQY file (Internet Query file), it's found locally on my computer. This file when opened in excel will show me a table of a SharePoint list. I would like to use JavaScript, in IE browser (I can use ActiveXObject if needed) to search the resulted table for a value.
I already know how to search in excel, So that's not the problem. How can I turn this IQY file into an temp excel sheet with JavaScript? If it's not possible, is there a way to read from the table using the IQY file without using excel?
I hope my question is understandable.
Thank you.
So I've found a way to overcome this problem. In the file data there's an href, that when opened by a browser will display the data in excel format. So I've used this data to get the information I needed.
I wish to manipulate excel spreadsheets using macros in Javascript rather than the default VBA. I can execute javascript code using the following VBA code
'javascript to execute
Dim b As String
b = "function meaningOfLife(a,b) {return 42;}"
'VBA tool to run it
Dim o As New ScriptControl
o.Language = "JScript"
o.AddCode b
MsgBox o.Run("meaningOfLife", 0, 1)
this enables me to execute arbitrary javascript, however I do not have access to the excel spreadsheet from within the javascript environment. Is there any way I can set and get worksheet values in the active worksheet from within javascript?
For people using Excel 2016 or later version, there is an Excel add-in called Funfun in the add-in store that actually allows you to write and run JavaScript code directly in Excel. And of course, your JavaScript code also has access to the data stored in the spreadsheet. Here is a screenshot of how it looks like in Excel
2016.
Well in the middle of the interface you have a section in which you could write JavaScript, CSS and HTML code. It is pretty much like a playground built into the Excel. But the Funfun also has an online editor in which you could test with your code. You could see it in the pic below. I also posted the link of the example in the first picture so you could play with.
https://www.funfun.io/1/#/edit/5a4e0d461010eb73fe125c4e
What is special about the Funfun online editor is that it contains a 'spreadsheet' just like Excel. Though you can't actually do any formatting in here, you could copy your data into the cells and test your code directly.
To use the data stored in the spreadsheet, all you need to do is to write some configuration in the short.io file of Funfun to tell JavaScript which area in the spreadsheet that contains your data. For example, in the example that I posted, all you need to write is
{
"data": "=A2:B9"
}
And in the JavaScript code, an object called $internal is used to read the data. So in order to read the data that stored in A2:B9, you need to write
var data = $internal.data;
And its done. You could go to the documentation of Funfun if you want to know more.
If you are satisfied with the result you achieved in the online editor, you could easily load the result into you Excel using the URL above. Of couse first you need to insert the Funfun add-in from Insert - My add-ins. Here are some screenshots showing how you could do this.
Disclosure: I'm a developer of Funfun
It depends what sort of "Excel programming" you want to do.
If you want to manipulate Excel files, you can do so via COM automation, or even ODBC to some degree, using JavaScript running under the Windows scripting environment.
But if you want to have your code running within an active Excel session doing things the visitor will see, you have fewer options.
See this question I posted a few years back when I had some JavaScript I wanted to run within Excel and didn't have the budget to convert to VBA:
How can I use JavaScript within an Excel macro?