I'm tiying to build an excel uploader app. Right now, I can get the data from the excel file and send it to an API to store the info.
But i need something else, and is to asign to each value the id of the excel, which i'll get after save it first.
This is how i get the excel data before store it:
$scope.loadWorksheet = function(e){
var file = e.target.result;
var workbook = XLSX.read(file, { type: "binary" });
var sheetName = workbook.SheetNames[0];
$scope.sheet = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName]);
console.log($scope.sheet);
$scope.$apply();
};
Let's say i get the next array:
[{Name: "Chuck", Age: "30"},
{Name: "Marcus", Age: "18"},
{Name: "Shelly", Age: "29"}]
How can i add to each record the id of the document?
Per example, after save the document i get on the response the id:
$scope.IdDocument = 15;
And what i need is to put it on every record, like this:
[{Name: "Chuck", Age: "30", DocumentId: "15"},
{Name: "Marcus", Age: "18" DocumentId: "15"},
{Name: "Shelly", Age: "29" DocumentId: "15"}]
There's a way to do that? Hope you can help me.
I'm using AngularJs and Javascript.