Writing to online excel from front-end - javascript

I have a form with several fields (written in React).
By submitting the form, I want the values will be written to an existing Excel file (the Excel file is saved in OneDrive), i.e. each submit will add 1 row to the Excel sheet.
How can I do it?

You can use the Excel REST API to do this.
To add a row, first identify the endpoint for your Excel file, and send a POST request to a URL like
https://graph.microsoft.com/v1.0/me/drive/root:/{sheet-name}:/workbook/tables/Table1/rows/add
with a payload similar to:
{
'index': null,
'values': [
['col-1-value', 'col-2-value', ...]
]
}
Where index signifies the offset from the last created row.

Related

How to insert empty rows above data header row using sheetjs package in nodejs?

Hello everyone please need helo to achieve similar using NODEJS sheetjs package
(Desired Sheet):
I want to know how can I insert the few empty rows and then append the sheet.
Currently my exported data look like this:
I tried sheet_to_aoa and all but didn't work. The data was overriding the headers.
Your desired format require to handle header, data manually.
Use this to append row to the end of the sheet
XLSX.utils.sheet_add_aoa(workSheet, [['', 'Your', 'Desired data']], {
skipHeader: true, // Won't override headers
origin: -1, // Add to the end
});
Welcome to Stackoverflow!

Scrape CSV data to SQL table using PHP, LOAD DATA from URL with Javascript object, (beginner)

(I'm learning and not a pro, so please excuse any faux pas)
I am aware that the PHP, LOAD DATA function may be what I need, but I can't get to the file behind the Java Object.
I am trying to update a SQL table, i.e. overwrite matching dates, with data from a CSV file from Javascript buttons on one of these websites:
-"Download Data" from https://www.investing.com/rates-bonds/us-10-yr-t-note-historical-data (adjusting dates would be ideal)
-"Download Range" from https://www.barchart.com/futures/quotes/Znh18/price-history/historical
-"Download Spreadsheet" from http://quotes.wsj.com/bond/BX/TMUBMUSD10Y/historical-prices
The data looks something like this
Time,Open,High,Low,"Last Price",Change,Volume,"Open Interest"
02/08/18,121.0781,121.25,120.5313,120.8906,-0.10939999999999,2938115,0
02/07/18,121.2031,121.6094,120.8594,121,-0.48439999999999,2201308,3569670
I have used the http://simplehtmldom.sourceforge.net/ utility to extract individual pieces of data, but that seems laborious if a file exists.
e.g. currently this is my code for finding table data on the WSJ page using the file_get_html() function:
...
// Finds the last cash price
foreach($html->find('span[id=price_quote_val]') as $e){
echo str_replace("/32.","",str_replace(" ",".",$e->plaintext)). ' last cash price<br>';
$field='Last';
$value=str_replace("/32.","",str_replace(" ",".",$e->plaintext));
include('table_update.php');
}
....
Thanks!
Chris
I have read other posts, including:
Save CSV files into mysql database
Importing CSV data using PHP/MySQL

Is there a way to use javascript and the node module (oracledb) to import a csv to an oracle database?

I am currently trying to use the node module Oracledb to import a csv to my database. The database is connected correctly, as I can SELECT * FROM MYDB. But I cannot find a way to easily import a CSV to this database.
*note : I am currently using jsontoCSV and then fswrite to create the CSV. So if it is easier to write a SQL query to import a json to Oracle using Oracledb, that could also work.
Thank you.
I only have a rough management overview on oracle techniques. I would guess to use sqlloader or datapump (abbrevated dp) to read csv; perhaps using additionally (oracle) external tables (could be accessed via file system). It depends on your infrastructure.
The internet is full of examples. One main ressource for me is "ask tom" (use your fav. search engine with the words oracle ask tom kyte).
User SQL*Loader as mentioned.
create table
drop table mytab;
create table mytab (id number, data varchar2(40));
mycsv.csv
"ab", "first row"
"cd", "secondrow"
Create control file myctl.ctl:
LOAD DATA
INFILE 'mycsv.csv'
INSERT INTO TABLE mytab
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS (id, data)
Run:
sqlldr cj/cj#localhost/orcl control=myctl.ctl

Extracting data from excel sheet into csv (or) Json using Javascript

I need to extract the data from an excel sheet into csv or json format and then display the content in the form of charts(bar, pie and line) using javascript. I have been working on it since 2 days and not able to find any good source. Any help regarding this would be appreciated. Thank you.
You can also pull data from a google spreadsheet as CSV data like this:
var spreadsheet = "https://docs.google.com/spreadsheet/pub?key=youruniquekeyhere&single=true&gid=2&output=csv"
d3.csv(spreadsheet, function (error, data) {
// use your data here
});
Notice the output=csv at the end of that URL.
gid=0 is worksheet 1, gid=1 is worksheet 2 and so on. You must publish your worksheet to the web first to make it available.
In addition to Christophe Viau's tutorials, here are more resources:
https://github.com/mbostock/d3/wiki/Gallery#basic-charts
http://www.d3noob.org

Passing a javascript array to a form / $_POST without ajax

I'm working on a form upload element that can be used in the Zend Framework forms. I'm trying to make it so the programmer can use it in any project without having to manually configuring any settings.
The files are uploaded by an AJAX uploader which returns JSON data like:
[
{
"name":"image.png",
"size":42410,
"type":"image\/png",
"url":"http:\/\/example.com\/image.png",
"thumbnail_url":"http:\/\/example.com\/thumbnail\/image.png",
}
]
Since the uploader itself is a form element I'm trying to put that data in the form so on the submit the values can be retrieved from the $_POST.
I was adding hidden input fields with javascript named uploader-data[] (when submitting the form) but that only allows me to pass 1 variable at the time to the hidden field.
So I guess my question is: "How can I pass the whole array/object to the $_POST / form?". Even though I am using AJAX for the uploader itself I don't want to use it to submit the form. I want a regular form submit containing all the data from the JSON object/array. The files itself are already uploaded but I might want to use the JSON data in my database or at some other place.
Is it possible to do something like this?
Thanks in advance.
Put your javascript value into an input field using JSON.stringify
:
data = [
{
"name":"image.png",
"size":42410,
"type":"image\/png",
"url":"http:\/\/example.com\/image.png",
"thumbnail_url":"http:\/\/example.com\/thumbnail\/image.png",
}
]
document.getElementById('my_hidden_input').value = JSON.stringify(data);
This will turn your array in the following text value:
[{"name":"image.png","size":42410,"type":"image/png","url":"http://example.com/image.png","thumbnail_url":"http://example.com/thumbnail/image.png"}]
Zend can parse the JSON value into a php array.

Categories