Use javascript to generate spreadsheet including formulas and user inputs - javascript

Using Javascript, I want to let users download or generate a spreadsheet that contains several parameter values they've chosen, as well as formulas that perform calculations using those parameters. After they generate/download the spreadsheet, users need to have the ability to change parameters and potentially customize the formulas.
I've seen that this can probably be done server side, but I think that requires learning yet another new language (I'm learning to code just for this project) so I suspect that's not yet feasible for me in the near future.
My solution thus far has been to convert the spreadsheet into delimited format, then code it into an array of arrays so it can be downloaded as a .csv file when someone clicks on a link.
Unfortunately, I'll need to make somewhat frequent changes to the formulas, and it's a complicated spreadsheet with complicated and repetitive formulas so it's tedious to find where to make changes (to give a sense, the code for the array currently takes up 19 pages when copied into MS Word, 12pt TNR.)
So a few questions:
Is there an easier/better way to download or generate a spreadsheet with formulas and user input?
If the answer to #1 is no, is there a way to break up an array in the code and make it easier to find/edit an individual cell/value?
As an alternative, should I consider switching to Google spreadsheets? Haven't done this because a handful of users might not be able to access Google at work, but the majority can. Maybe the pros outweigh the cons?
Is there another idea I haven't considered?
Very much appreciate any suggestions or feedback!

Related

JavaScript - Create and Edit .xls or .xlsx (Excel Spreadsheet) Files WITH OFFICE JS API

I saw that Microsoft made an Office API for JavaScript.
I've seen that it's possible to use their API to develope add-ins for some of the Office softwares.
But does anyone know if it's possible to use it, or a different API of theirs, to create, read and write Excel .xlsx or xls files? I don't care what type to use.
I'm basically running a script that would create data that I want to put into excel, and want to not lose the data, so I could run the script, stop it, and continue it so it'd continue writing the data from where I left off.
I want it to be as fastest as possible. I'm not very familiar with JavaScript, and don't have a lot of experience it as a developer (I just didn't work with it much, although I did learn it and know how program in it).
I also want for the development to be as quick as possible.
I don't mind spending time on learning how to use different libraries, but if it's possible, I prefer to do it as little as possible.
So I want something simple and fast, and I don't want a lot of special options. All I care about is writing the data.
The script itself will do:
*Data analysis
*Data output into a JS file
And I want continue the script so it'd continue filling in data into the created file.
That's all there's to it.
I prefer to use something official from Microsoft, because it'd probably the best solution for that.
If such tools/libraries/API(s) don't exist, or if there are better solutions, what do you recommend?

Easy way to store and retrieve data

I'm working on this project that requires my team and I to do a state of the art of existing Bluetooth modules and their characteristics. I thought it would be easier for us if we could just find a way to store everything we'll find in a programming interface, that is, we would just have to input the new data to a form and it would automatically update the underlying storage structure.
We need to be able to easily extract the created content and export it to .txt or .tex. The method used need to be easy to use, this is only a small part of the project and we don't have time to learn complex tools.
I know Javascript and a bit of C++. At first, I thought of creating an HTML form and use Js to take the input and add it to a JSON file that would then be transformed into an HTML table. This approach seems broken to me though, we wouldn't be able filter anything without writing lines of code and getting data from an HTML file with C++ must be a pain in the a**. Also, the JSON data would be in the browser local storage which is really not a good idea.
I also used SQLite a bit some years ago, and I remember that it is easy to filter the data. Does it sound like a good option to you ? Is it easy to add/retrieve data into/from an SQLite database ?
Thanks for the help !

Just want to make sure I'm doing things right

I am planning on creating a website with one of my friends. Both of us know next to
nothing of coding and programming. We are planning to display hundreds, potentially thousands
of images on this website. These images will have a short description, and will not be user uploaded, but we may potentially want to implement an option to save the favorite images.
There will be a button that randomizes the images shown (one image at a time). Users will click this button and it will randomize from all the images, displaying a new one on the screen replacing the old one. Is it possible to write code that makes it so it will display a new random image, but not repeat the same image until it has cycled through all of the images (potentially thousands)?
Just from browsing the web, looking at tutorials, and reading some other stuff we've have a general idea of what needs to be done. We need to store the images as files on a server, and store the description of the images and file path on a database. To create the button function we use javascript(?) and write a script that will randomize. Someone mentioned JSON but I don't know what that is.
Are we on the right track? We are both currently looking into PHP. Although we have a general idea of what needs to be done, we don't know where to start as far as tying this whole project together.We are trying to figure out how to start saving the images as files, and implementing them into the database but don't really know how.
tl;dr We would like some guidance on where to go with this, how we can possibly tie all of this together, and if we have the right idea of what to do.
Learning this stuff out of the blue can seem kind of overwhelming at first, that is why I'm extremely grateful for all the advice and answers.
Forgive me for leaving this as an answer. I don't have enough rep to leave it as a comment.
Programming is all about problem solving one step at a time. I'd suggest writing a basic list of all the things your program must do. For instance, in your case, the list may start like:
1. Store img file path in database
2. Retrieve img path from database to display on webpage
3. Attach a description to img
4. Write code to randomize images
5. Write code to display images
6. Etc. etc.
Once you have this, you can start looking into which programming languages are best suited for the task. First each task, you'll usually have several options. For instance, you may decide on PHP or ASP.NET for tasks involving your server. Or JSON vs XML for handling data. I good place to browse basic language capabilities is w3schools.com. They provide pretty basic stuff that someone with no programming experience can understand. Hope this helps! Good luck!
You might be able to limit your technical needs quite a bit in my opinion.
As far as I have understood what you wanna do, you won't really need a server-side scripting language and you won't need a database neither.
And if you are totally new to programming then you would profit a lot on restricting yourselves to one programming language instead of having to learn three (for example PHP, Javascript and MySQL).
So you would "just" need to learn a bit of HTML, CSS and Javascript.
To store the images on your webserver, you just need some FTP client. You will need the FTP client or some editor with FTP client included to upload your HTML, CSS and Javascript files as well anyways.
To save the link or url to your images, you don't necessarily need a database. for example you can put all the images into your HTML code with <img> tags. you can initially hide them by CSS. Or you save the urls of your images by using Javascript arrays or objects (JSON means nothing else than JavaScript Object Notation).
All the logic can be done by Javascript itself. You can use it to randomize the images you wanna display plus to save the images a user already has seen.
TL;DR: I recommend that you restrict yourselves to "just" learning a bit of HTML, CSS and Javascript. Seems like everything you wanna do can be done without needing a server-side programming language or a database.

Adding nodes to XML with a form

I've created a list using XML and have embedded an XSL stylesheet in it. Now I want to know, because this is a list of movies that constantly grows, is there a way to create a form that will add child and grandchild nodes to the list.
I'm thinking there might be some javascript involved, but I have no idea what I'm doing when it comes to scripting.
If the intension is to write new entries into this xml file you need to look at some form of serverside scripting. Javascript can not write to files.
PHP is probably the easiest to understand, start by buying a book that explains the basics with a few examples, it's not that hard to grasp, and a form and a simple function for writing to files shouldn't take you to long to figure out.
If you have no interest in that sort of thing, hire someone to do the job for you, it will probably only take a few hours for someone who knows what they are doing to get a complete system up and running for you, and unless you really would like to learn a serverside language that is probably the best option.
If you really want to do it all on the client side, you can try HTML5 client-side storage. This means the data will be persistent only for the user that enters the data (and only for the browser used to enter it, and only on the computer that was used).
If you want the movies to be accessible to multiple people, or from multiple computers, you need to use server-side storage.
FYI, HTML5 storage is not yet very well standardized across browsers.

Get html form from xsd

I have a quite complex xsd file that describe some objects (it's not important, but it's the DATEX II standard)
Do you know if there is an automatic way to create an html form that act like a "wizard" to guide the user to create xml object as described in the xsd?
The answer to this depends on the intended user base, how you want your users to access your forms, and the technology stack you have in place already or you're willing to deploy.
If your users are quality control analysts, and so the intent is to have them use that generated UI to manage test cases, then a handful of commercial tools have this ability. A quick search on Google for terms such as "generate ui forms from XSD to test web services" should give you on first page the major players in this space (I won't name names to avoid conflict of interests). There are differences in how vendors approach this, that have to do with the time it takes to generate these forms from large bodies of XML Schema, which in turn translate into different degrees of usability. Given what I see in DATEX, from a complexity perspective, you may have a hard time to find a free tool for this...
If your users are rather data entry specialists, then the above are not the tools you want them to use. Without knowing much about your environment (I see your java-ee tag, but still not clear how it would relate to this task), one model could be a combination of InfoPath with SharePoint; while the process to generate the form is not fully automatic, it comes close to that. It is XSD driven, in the sense that at design time you drag and drop XSD on a design form, that allows you to build some really nice UI. Follow their competition on your particular technology stack and you may have your answer. Or, you can go to this site that lists XForms implementations; IBM's form designer, much like InfoPath, can use XML Schema for design, etc.
If this is for developers to get some XML, another alternative might also be to go with an Excel based (or SharePoint lists) approach and generate XML from that data (you give away cost to acquire something to build specific to your requirements tooling, here assuming people that are really familiar with spreadsheets instead).
Given how DATEX model looks like, you'll have to do some manual customizations anyway, if you plan to use the extensibility model, or if you choose to build different forms for different scenarios i.e. instead of one big form that'll give you all descendents for the abstract payloadPublication in some drop down, to just a specific, simple form e.g. MeasurementSiteTablePublication.
I know this is an old question, but I ran into this issue myself and couldn't find a satisfying open-source solution. I ended up writing my own implementation, XSD2HTML2XML. To my knowledge it is the most complete tool out there. It supports automatic generation of HTML forms from XSD, including the population of a form with XML data.
If you prefer an out-of-the-box solution rather than writing your own, please see my implementation, XML Schema Form Generator.

Categories

Resources