How can you access data in an Excel Spreadsheet using javascript - javascript

I have a website that uses some JavaScript to access data in a .xlsx file from a Microsoft Excel Spreadsheet. When testing I was able to access it by having the file in the same folder, however in practice my company uses SquareSpace, and the way to access their files is more complicated than I would like, since I need to set it up so that the less tech savvy people in the company can reupload and update the spreadsheet. Preferably, I'd like to have it so that my script is accessing the file directly from OneDrive. I know it's possible to display a spreadsheet on from OneDrive on SquareSpace (or any website) by embedding it. But I don't need to display the spreadsheet, I need my code to read the data in the spreadsheet and respond to it. Essentially, is there a way to connect a website to a Microsoft Excel document and save the data as JavaScript variables?

Related

Reading local excel file in browser with read-excel-file.js

I'm trying to create an html table that is based on data coming in from an excel sheet. I plan on using a javascript script to convert the excel data into an html table using read-excel-data.js. I have the excel sheet locally, but am not sure how to send the excel file with the html/js/css to the browser. So in my javascript file when I try to call readXlsxFile("data.xlsx"), data.xlsx is not found because it does not exist within the browser. Is there a way for me to send data.xlsx to the browser without having to manually upload with an input type="file" element?
For obvious security reasons, the browser should not allow this at all except in the case of a user action, such as file input. In fact, think what implications it would have if a Web site could explore and read/write data from the file system on which it is running.
You can only directly receive files from agents such as web servers or similar applications via functions such as fetch(...)

Is it possible to write data from a chrome extension to a local excel sheet?

I've created a chrome extension that take some user data and automate some tasks in a certain website, i have read that chrome extensions have no access to local files and i need to write the user data to an excel sheet. i don't know if that has changed lately!
Is that possible to automatically send data after user interaction with the extension to a local excel sheet?

How to convert DOCX to ODT format using javascript?

I am working on a in-website document editor(word and excel document). So far I am able to edit ODT files using WEBODF. Is there any way to convert DOCX file to ODT using javascript so that i can use the file in the editor? any alternatives for editing word and excel documents inside a website? I have tried saving the file in OneDrive and then using the share link to open editing on sharepoint but this editor cannot be inserted inside an website and can only be done in a new tab? i need the editor inside the website as i need to implement azure versioning of the documents
WebODF is an awesome tool to be used as an online editor. Assuming you have no restrictions implementing a separate backend server, you can use libreoffice, which gives you a command line utility to exactly perform that job. You can convert docx file to odt file using the following command -
soffice --headless --convert-to odt <input file>.docx
The approach would be to create an API
Which would take docx file as input
Store that file temporarily somewhere and run the above command
Serve the converted odt file and delete the temporary files.
If you want to store those files in the server, then you can maintain a database to achieve that as well.
To take care of restricted cross origin policy, you can implement AJAX calls in the front-end to perform file uploading and viewing operations using Javascript blobs.

Modifying local files embedded in a Google Chrome Extension using JS

I have been doing a lot of research and have been unable to find an answer to my exact question. I understand that having a google chrome extension that can write to local user files would be a major security breach and thankfully isn't possible. However in my extension is a .json file that is used to make a HTML webpage with links via JavaScript. The JS reads the .json file and inserts the lines of code on the html page. I am attempting to make a user interface that allows them to update and edit the .json file that is inside the extension in order to add new lines of code to the webpage, but have been unable to find anything that could make this work due to security issues. I was thinking that since the file is in the extension users should be able to modify it.
If that was confusing here is a flow of what I want to happen and where it is not working:
Works:
Users clicks on button that takes them to a webpage hosted in the extension -> when page is loaded, the javascript runs -> the JS looks at a .json file in the extension using an XMLHttpRequest, parses the data, and then inserts it into the html -> The user now see's the content that was contained in the .json file on the html page.
Doesn't work:
After this I would like to have an interface that will allow the user to edit this .json file in order to update the page as they see fit, all in the extension itself.
If it was just me using this extension I could simply use the chrome storage api's available, however this is for my team at work, who are wanting to make edits as we need. Which means we will all be editing the same .json file.
Any information regarding this would be very beneficial. Even if it's as simple as it can't be done. Either way manually editing the .json file without a simple UI is much easier than editing the html directly.
Thanks in advance!
Posts/Articles I have looked at regarding this question:
Access Local Files using a Google Chrome Extension
https://developer.chrome.com/extensions/storage
Local file access with javascript
Allow Google Chrome to use XMLHttpRequest to load a URL from a local file

JavaScript API to work with Excel files stored on OneDrive?

I want to create an web application that uses an Excel file stored on the users OneDrive, preferably directly from JavaScript. The web application should not be running inside Excel on the client, so I think that excludes the JavaScript API for Office.
Are there any alternative APIs or is it simply not possible?
You can use the OneDrive Javascript SDK to get Excel files (download) from a user's OneDrive, and then manipulate that content once retrieved from the service.
You can use the OneDrive Javascript SDK directly to traverse the file hierarchy and find an Excel file, or you can use the Web picker to let a user choose (or save) the file (free UI, no need to build hierarchy traversal).
In terms of actually manipulating the Excel file, there are certainly modules and libraries available to help do this (node.js, python)

Categories

Resources