This is the first time I write in this place.
I was looking for a solution everywhere and I could not find it. I do not know if it can be done or not.
The theme is like this:
I have a json where one of the data it contains is an image. I need to export that json to an excel, where each data goes to a cell. Therefore, I need to be able to insert that image into one of the cells.
Is it possible to do this? Keep in mind that it is for a mobile app offline, so it should be in javascript and client side.
Many thanks!
Greetings.
There is a JS library to create excel. I haven't tried it though.
https://github.com/stephenliberty/excel-builder.js
However, it should be fairly trivial to loop through your JSON and create a CSV file, which will ultimately open in excel. That might work better depending on your needs.
But to be clear, when you say holds an image, do you mean a link to an image, or a base64 text of an image? The latter would be huge and probably break excel in some way.
Related
I want to implement search in a react project where i have a file locally in the project folder and i want to search from that file.
Should i load the file data into a state variable? not sure but i don't think that is something i should implement since the file can be very large in size.
Any help or direction would be appreciated, thanks!
Currently i'm storing the data into a state and then performing the search. I wanted to know if there are any better ways to do the same.
You are right about it. loading a file in state first of all can be a bad idea because its loaded like an Array Buffer or sort, so its all binary not exact text. Hence search would be a problem.
This usecase is more for the backend side to handle in Real World scenarios.
Intro
Hi, I was looking for answer in the whole Internet (in some way I kind of feel that I know every question in Stack Overflow), but the answers were never appropriate to what I'm looking for. I was trying to avoid posting question here, but situation forced me to do this.
Sorry if the answer is simpler than I think.
I'm in the middle of building my first app in Electron using JavaScript. I think that I should describe it in few words, so flam:ngo™ (which is projects name) should work like this:
User will upload two files:
file with tables (like XLSX or DOC)
file with data and blank spaces (which will be used as a template)
App will import from tables.
Now app should let user choose which rows he's interested in and where in uploaded file he wants them to be placed.
flam:ngo save document in PDF (or DOC).
Clue
Right now I need solutions just for myself and in little simpler form. For now I need flam:ngo just to work with one specify XLSX and with one DOC template, but I stuck. I know which rows in document I will always need, but I don't know what should I write to specify in JS's code that I need exactly this ones (like hey, app, pick only this one, this one and maybe this one) while JS is reading file and I don't know how to create new DOC (or PDF) file, how to write data in specified blank spaces and then at the end: how to save it in direction which I should choose for every time I'm using an app - everything in one, maybe two, processes.
Ending
Could you, please, help me: for now I have implemented file uploader which is importing file in XLSX and which is saving it as CSV, XML oraz HTML. What should I do to keep moving forward?
I really appreciate your help!
PS. For better explanation:
For now this should look like this:
1. "template.docx" is uploaded in the core
2. user uploads .xlsx
3. app reads tables and select rows chosen in code
4. app puts data from chosen rows in specify places
5. app saves file > new life of the app :)
Ok, so it's been a while and app has been already written by me. Maybe this will help someone in the future:
Solution
Packages that helps me with this issue was:
js-xlsx which converts my file to simple HTML file, where cells from my XLSX template file have always the same ID (which was important for me to work with document templates).
officegen which helps me write brand new document based on earlier prepared template.
Rest of it was just Vanilla JS.
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.
Let's say I saved some .ai file as .svg. Now I want to move all the vectors from this file to Raphael to manipulate them using JavaScript.
How can I do it? What are possible ways to achieve this goal? Please also write any pros and cons, so users will be able to choose best in their opinion way.
I had to do exactly the same thing a few months ago. I used rappar
I used node from the command line to do the conversion and save it to a file
node rappar.js test.svg >test.js
test.js now contains the vectors. The only thing I did find though is that line 537 of rappar
var files = process.ARGV.slice(0);
should be
var files = process.argv.slice(0);
Other than that it worked a treat.
You could loop through the nodes of the SVG and write them to the Raphaël object one by one, but unless you are dealing with nonstandard element types/attributes you are better off using one of the Raphaël plugins that make importing SVGs a one-line command. Such as:
https://github.com/crccheck/raphael-svg-import-classic
https://github.com/wout/raphael-svg-import
I found some simple converter here.
Pros:
It's really simple and straightforward - you upload the file, and get generated code. You can even see a preview of it. When you load really simple .svg it's working perfectly, and you can easily edit the code, but...
Cons:
But the biggest problem of it is that the code is a little bit messy. So if you load bigger file (100+ vectors, or even more; I loaded sth around 1000 for testing purposes). Also names and structure of it doesn't respond to layer's division. Sometimes some of the layers (you can see it in preview) are not in correct order, so if you want to see exactly the same 'image', you need to browse the code, looking which path correspond to which object in .svg file.
Anyway it's the only one I found, and in the end (after some work) you can achieve what you want. Best way to work with it is when you upload your .svg portion by portion, to avoid flood of messy code.
This one worked really well for me http://roomandboard.github.com/vectron/
When installing the rappar dependency at https://github.com/DmitryBaranovskiy/rappar you need to remove the Node.js code to get it to work.
Pros:
Not much code required.
Cons:
It can be a little slow on larger SVGs. You might want to consider saving it to JSON with another Raphael plugin to make the load faster the next time.
All of the vectors are in the file, so you could put those paths to a variable string and Raphael wil use that.
I'm creating a web-application which will be taking survey-type data.
Users are presented with several files and asked a question. The user, in the hope of not skewing data, must not be able to know the file name of the file.
An empty div is created for a JPlayer instance to sit in, and I have added the "location" attribute to the div, so while setting up the JPlayer instance on the client side the JPlayer knows what .wav to play
<div id="jquery_jplayer" class="jp-jplayer" location="sound.wav"></div>
Here is part of the javascript which sets up the sounds to be played and here its easy to see that the file location is simply dragged from the div
$("#jquery_jplayer").jPlayer("setMedia", {
wav: $(this).attr("location")
});
Basically, the intention is to hide "sound.wav" from the HTML document and keep the javascript dynamic.
A translation file between obfuscated and deobfuscated could be possible but it would be nice to keep this dynamic.
If you want to truly hide logic from your viewers, then you need to do it server-side rather than with client-side javascript. You can "complicate" the dissection of what is happening in the client-side code, but you cannot truly hide it.
If you want further help with the obfuscation, you'll have to describe better what you're really trying to do. The current description doesn't seem to offer enough information. What is this file path? What is it being used for? Why do you need to hide it?
If what you really want is just a Javascript function to obfuscate and de-obfuscate the sound filename, you can find lots of options with Google depending upon how elaborate you want to get. My guess here is that the determined cheat won't be fooled (since all the code is there for deobfuscating) so all you're really trying to do is make it non-obvious at first glance. Thus, any simple algorithm will do.
Since you're already using jQuery, here's a jQuery that does simple string obfuscation: http://plugins.jquery.com/project/RotationalStringObfuscator. You'd have to run the obfuscator yourself in some sort of test app to record what the server should set each filename to and then do the reverse in the client when you want to actually use the filename.
If you ask me, a better solution would be to give the filenames non-meaningful names from the beginning. This would be names like 395678264.wav and just use them that way (on both server and client). Then, the name is meaningless to anyone snooping. No deobfuscation or translation table is required because this is the real filename.