I am using SheetJS library to parse xlsx file with javascript.
The way i got the file force me to pass received data as string into the javascript function.
Now I confused how do i pass the string into XLSX.utils.sheet_to_txt. What type of convertion should I use?
The solution has found.
The string was converted to hex and converted back to array
Related
I am currently working on a custom SAPUI5 app. I would like to make a service call, which expects the Guid in a different format than it is currently available.
An example:
Available (base64): QvLAUUzUCZbhAAAAjSS2iA==
As it should be (hexadecimal): 42F2C0514CD40996E10000008D24B688
I have not found an online decoder, which could produce the desired result, however, I was able to encode the guid 42F2C0514CD40996E10000008D24B to QvLAUUzUCZbhAAAAjss2iA== with the SAP ABAP standard function module HTTP_BASE64_ENCODE. With the usual online encoders, however, I got a different result.
How can I decode the encoded guid with JavaScript so that it has the desired format?
The string is in hexadecimal format you will have to convert it.
First you convert the string to binary (atob > charCodeAt) and then using the toString(16) you get the hex.
I will not post the code, since its already explained
Decode Base64 to Hexadecimal string with javascript
Do i have to make a variable and paste the CSV data and then convert to JSON or please specify some methods.
Thank You!
I'm not familiar enough with react to know if there is a necessity to make it react specific, but if you are open to using a library, this one is superb:
https://github.com/okfn/csv.js/
This library allows you to
Fetch the CSV from a url
Parse that CSV into an array
Serialize it back into CSV format if needed
So for you, I would say, use this library to fetch the data, parse the data, and then just JSON.stringify the array.
If you don't need to do it programmatically, why not just take the CSV, and put array brackets around it, and set your variable as that?
For example, my CSV:
Apple,Banana,Strawberry,
Pickle,Cucumber,Lettuce,
Milke,Bread,Onions,
Then I turn it into an array:
[['Apple','Banana','Strawberry'],
['Pickle','Cucumber','Lettuce'],
['Milk','Bread','Onions']]
You can just use built in Excel functions like concatenate to turn it into this format if your CSV file is really big and this is just a one-off exercise
I am trying to convert a small paragraph into a sequence of numbers (and maybe chars) like the md5 does.
I tried md5() in PHP and http://www.myersdaily.org/joseph/javascript/md5.js using JS but I get different result.
I do not know why this is happening, but can you suggest me a way to convert the text to a sequence of chars and numbers (to save them in DB) that will give me the same output? I do not mind if the output is not crypto.
Thank you
I would use the base64 encode/decode. Check out the link for the php http://php.net/manual/en/function.base64-encode.php and here is a link with some examples for javascript Base64 encoding and decoding in client-side Javascript
If you don't need crypto convert them into Hexadecimal value.
For example "Stack" will be 537461636B.
If you want to easily encrypt them, just use xor. This cannot give you different results in any possible language.
in PHP I found this function here PHP convert string to hex and hex to string
in JS I found some code here http://snipplr.com/view/52975/
In my app I have an array and I want to pass this array to a javascript script to display an html list.
My app generate this array after reading information from JSON and I need to pass it to javascript. In iOS I used this function: stringByEvaluatingJavaScriptFromString.
How I can do the same in Android?
Use Gson library. It is an amazing JSON parsing library that can parse and create JSON arrays.
https://code.google.com/p/google-gson/
So convert your array to JSON and send it over :)
I am working on a project and I was not able to figure out how to do this. I have a json file and need to assign it to a js variable to use the protovis visualization tools.
I tried searching on google but could not find any. Please let me know if someone knew how to do this. Thanks!
Use jQuery's parseJSON().
Description: Takes a well-formed JSON string and returns the resulting
JavaScript object. version added: 1.4.1jQuery.parseJSON( json )
jsonThe JSON string to parse. Passing in a malformed JSON string may
result in an exception being thrown.
If you're getting the file from your server via the XMLHttpRequest object, you can parse the json using the JSON.parse function:
var myJson = JSON.parse(response);
For browsers that don't support the JSON object you can get a library for it here: http://www.json.org/js.html