How to edit chart data using office.js within Microsoft Word - javascript

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.

Related

How to embed interactive chart inside a pdf?

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 extract data from these websites that don't output data in the HTML source code?

Many years ago I used to use Perl and Python to crawl through some websites by looking at data in the HTML source code.
Now I would like to do another personal project that involves extracting numerical data from:
Table elements on this PredictIt Website
Individual graph elements (x and y for each) on this PredictWise Website
Individual graph elements (x and y for each) on this Five Thirty Eight Website
None of these web pages' HTML source code contain the numerical data. Is there a way to extract these data? If so, where?
I feel like there must be a way, because these are all front-end information that the browser needs to render the charts and graphs.
(I can't find raw-data provided to developers on these webpages. So I guess I have to extract data myself.)
The table elements on the first link are indeed readable from the rendered HTML. If using Chrome, right click on the text and choose "Inspect." The Chrome debugger will show you the exact HTML element that contains the data.
The other links are more difficult. I don't see a way to view the data in raw HTML, but on the second link I am able to see the JSON data supplying the graphs with their data from the server. You may be able to parse that for your project.
The data look like this:
{"id":"1687","name":"Hawaii Caucus - DEM","notes":"","suppress_timestamp":"0","header":["Outcome","PredictWise","Derived Betfair Price","Betfair Back","Betfair Lay","Pollster","Derived PredictIt"],"default_sort":"2","default_sort_dir":"desc","shade_cols":["1"],"history":[{"timestamp":"03-17-2016 1:03PM","table":[["Hillary Clinton","43 %",null,null,null,null,"$ 0.425"],["Bernie Sanders","57 %",null,null,null,null,"$ 0.570"]]},...
Open the Chrome debugger on that website and goto the Network tab. From there, look for requests for "table_xxxx.json" . You can see the URL for requesting the data, and the raw data returned from the server.
Hope this helps!

Converting Excel Data to a Chart in HTML dynamically

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.

Using google script to manipulate data conditional formating and data validation

I was looking for already 3 days but nowhere found how to manipulate those two tools by google script.
I am interested in maiking script runned dynamic creation of worksheets and fast edditing of worksheets.
I need to alter those: data validation and conditional formating which are available normaly on tool bar.
Please help, give me the name of class that consists of those or the functions in google script with little information I will find rest.
Thanks in adavance
Tom
Data validation can be set using Range.setDataValidation(). Unfortunately Apps Script doesn't support setting conditional formatting, but you can star this feature request to get notified if/when it's added.
The tools you are asking about appear to be in the Range class of the Google Apps Script Spreadsheet API. Note that the API calls deal with a range of cells at a time, although you can easily define a range that contains only one cell.
The question in its current form has nothing to do with Google App Engine, so consider taking that off the question tags.

How to display excel chart in browser?

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

Categories