To Achieve this, Firstly you have to Read the Excel Data and then Save it in Fields of Entity.
1) Read Excel data Using Angular js.
Step 1: Download the angular.min.js lib from Here.
Step 2: Create an Html file and Copy paste the following code from Here.
Step 3: After save this file, Run this file in Browser and then you will see there is a dataObjects variable which store all Excel Data. After store the data in variable it will call the Save Function to save the Data.
Step 4: Create a new Web Resource in Dynamic CRM. Upload this HTML file in this Web Resource.
Now apply this web Resource on Entity form.
Cool..... Its working....
NOTE: Apply debugger in Save function and then check Data variable contain all Excel Data.
Important Point: Column Name must be in Single Word like Column_1, Column_2 etc.
Step 2: Create an Html file and Copy paste the following code from Here.
// This is the code to read the Excel data
<html>
<head>
// Add lib in the code
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.11.5/xlsx.full.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.11.5/jszip.js"></script>
<script type="text/javascript">
var app = angular.module('myApp', []);
app.controller("myCtrl", ["$scope",function($scope){
$scope.selectedFile = null;
$scope.msg = "";
$scope.loadFile = function (files) {
$scope.$apply(function () {
$scope.selectedFile = files[0];
})
}
$scope.handleFile = function () {
var file = $scope.selectedFile;
if (file) {
var reader = new FileReader();
reader.onload = function (e) {
var data = e.target.result;
var workbook = XLSX.read(data, { type: 'binary' });
var first_sheet_name = workbook.SheetNames[0];
var dataObjects = XLSX.utils.sheet_to_json(workbook.Sheets[first_sheet_name]);
// Now your Excel data is in dataobjects.
if (dataObjects.length > 0) {
$scope.save(dataObjects); // call save function to save the data.
} else {
$scope.msg = "Error : Something Wrong !";
}
}
reader.onerror = function (ex) {
}
reader.readAsBinaryString(file);
}
}
$scope.save = function (data) {
// to save the data in Dynamic CRM, Write code Here.........
// We can save the data using Web Api
alert("this is save function");
}
}]);
</script>
<meta></head>
<body style="word-wrap: break-word;">
<div ng-app="myApp" ng-controller="myCtrl">
<input type="file" name="file" onchange="angular.element(this).scope().loadFile(this.files)">
<br><br>
<input type="button" value="Import Data" ng-click="handleFile()">
<br>
<p ng-bind="msg"></p>
</div>
</body></html>
<html>
<head>
// Add lib in the code
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.11.5/xlsx.full.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.11.5/jszip.js"></script>
<script type="text/javascript">
var app = angular.module('myApp', []);
app.controller("myCtrl", ["$scope",function($scope){
$scope.selectedFile = null;
$scope.msg = "";
$scope.loadFile = function (files) {
$scope.$apply(function () {
$scope.selectedFile = files[0];
})
}
$scope.handleFile = function () {
var file = $scope.selectedFile;
if (file) {
var reader = new FileReader();
reader.onload = function (e) {
var data = e.target.result;
var workbook = XLSX.read(data, { type: 'binary' });
var first_sheet_name = workbook.SheetNames[0];
var dataObjects = XLSX.utils.sheet_to_json(workbook.Sheets[first_sheet_name]);
// Now your Excel data is in dataobjects.
if (dataObjects.length > 0) {
$scope.save(dataObjects); // call save function to save the data.
} else {
$scope.msg = "Error : Something Wrong !";
}
}
reader.onerror = function (ex) {
}
reader.readAsBinaryString(file);
}
}
$scope.save = function (data) {
// to save the data in Dynamic CRM, Write code Here.........
// We can save the data using Web Api
alert("this is save function");
}
}]);
</script>
<meta></head>
<body style="word-wrap: break-word;">
<div ng-app="myApp" ng-controller="myCtrl">
<input type="file" name="file" onchange="angular.element(this).scope().loadFile(this.files)">
<br><br>
<input type="button" value="Import Data" ng-click="handleFile()">
<br>
<p ng-bind="msg"></p>
</div>
</body></html>
Step 3: After save this file, Run this file in Browser and then you will see there is a dataObjects variable which store all Excel Data. After store the data in variable it will call the Save Function to save the Data.
Now apply this web Resource on Entity form.
Cool..... Its working....
NOTE: Apply debugger in Save function and then check Data variable contain all Excel Data.
Important Point: Column Name must be in Single Word like Column_1, Column_2 etc.