Jaffer Sadiq

Jaffer Sadiq

  • NA
  • 155
  • 69.1k

How to generate the output as pdf/Excel n MVC with angularJs

Dec 24 2018 6:26 AM
Hi,
 
I need to generate the output value as PDF or excel as per the end user choice.
 
Which is the best choice to handle. whether in Angular or MVC.
 
AngularJS:
  1. $scope.ReportGenerate = function () {  
  2. TransactionReportData();  
  3. }  
  4. function TransactionReportData() {  
  5. var ReportData = {  
  6. Customername: $scope.SelectedCustomer.Identifier,  
  7. Transactionid: $scope.Transactionid,  
  8. StartDate: $('#StartDate').val() + " 00:00:00",  
  9. EndDate: $('#EndDate').val() + " 23:59:59",  
  10. OrderID: OdrID  
  11. };  
  12. var result = TransactionSearchService.GenerateReport(ReportData);  
  13. result.then(function (response) {  
  14. $scope.RPTData = response.data;  
  15. if ($scope.RPTData.ErrorInfo == null) {  
  16. $scope.ReportGenerateFormat = $scope.RPTData.ReportTransactions; // I need this value should be generate as PDF and excel and outpurformat display as Array(list)  
  17. }  
  18. else {  
  19. $scope.ErrorMessage += $scope.RPTData.ErrorInfo.Code;  
  20. $scope.ErrorMessage += " : ";  
  21. $scope.ErrorMessage += $scope.RPTData.ErrorInfo.Description;  
  22. }  
  23. });  
  24. };  
Controller :
  1. public ActionResult GenerateReport(string data)  
  2. {  
  3. DataContractJsonSerializer jsonObjectPersonInfo = new DataContractJsonSerializer(typeof(Transsearchdata));  
  4. MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(data));  
  5. Transsearchdata Search = (Transsearchdata)jsonObjectPersonInfo.ReadObject(stream);  
  6. Transactionsearch TransSearchData = new Transactionsearch();  
  7. TransactionReportResponse response = TransSearchData.ReportData(Search, "en");  
  8. return Json(response, JsonRequestBehavior.AllowGet);  
  9. }  
How to do achieve this in MVC with angularjs.
 
It would be great if someone support.

Answers (4)