Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/452.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Javascript以xlsx格式的工作表导出Json数据_Javascript_Angularjs - Fatal编程技术网

如何使用Javascript以xlsx格式的工作表导出Json数据

如何使用Javascript以xlsx格式的工作表导出Json数据,javascript,angularjs,Javascript,Angularjs,嗨,我有一个嵌套的json对象数据,因为我有3个或更多的对象 除此之外,它还取决于保存将要增加的数据 有些员工,而不是我,需要以xlsx格式将json数据导出到 这边我这里有表结构,我需要以这种格式导出我的json数据,有人能帮我做这件事吗,因为在过去的3天里,我试图实现这一点,但无法做到。。请制作小提琴/普朗克并寄给我,这将是对我的帮助,提前谢谢 export.html <html ng-app="myApp"> <head> <script src="https

嗨,我有一个嵌套的json对象数据,因为我有3个或更多的对象 除此之外,它还取决于保存将要增加的数据 有些员工,而不是我,需要以xlsx格式将json数据导出到 这边我这里有表结构,我需要以这种格式导出我的json数据,有人能帮我做这件事吗,因为在过去的3天里,我试图实现这一点,但无法做到。。请制作小提琴/普朗克并寄给我,这将是对我的帮助,提前谢谢

export.html

<html ng-app="myApp">
<head>
<script src="https://rawgithub.com/eligrey/FileSaver.js/master/FileSaver.js" type="text/javascript"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.7.12/xlsx.core.min.js"></script>
  <script src="https://cdn.jsdelivr.net/alasql/0.3/alasql.min.js"></script>
   <script data-require="jquery@*" data-semver="2.1.4" src="https://code.jquery.com/jquery-2.1.4.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.5/angular.min.js"></script>
</head>
      <div ng-controller="myCtrl">
          <button ng-click="exportData()" class="btn btn-primary" style="float:right;margin-right:30px; margin-bottom:30px;">Export&nbsp;&nbsp;<i class="fa fa-arrow-down"></i></button>
            </div>
     </html>
我需要以这种方式在未来的xlsx导出表中显示我的数据 逆变器可能会增加,但格式应相同,必须显示 只有这样。。我试过4种不同的方法,但都被拒绝了,可以吗 有人帮我吗?从过去的两天起,我就在这里结巴 问题完全盲目的这个话题,请使小提琴和发送它将是 请帮我,我已经尝试了所有的方法,谷歌也请一些人在这方面的帮助了。提前谢谢


这不应该是AngularJS的责任,而是一个web服务(将由AngularJS使用)。很抱歉,我问过他们是谁在创建web API,每个人都在用AngularJS告诉我们只需要做。。有什么想法请你去做并给予,因为我从我身边尝试了所有的方法,这是我唯一做不到的。。请让我知道。在javascript中,我们可以做的其他事情意味着这也是k,但它应该以与我给出的相同的方式导出。任何人都可以让我知道这个答案。我同意这不是Angular的责任,但仍然有库来处理这类事情。查看此文档:这不应该是AngularJS的责任,而是一个web服务(将由AngularJS使用)。很抱歉,我已经问过他们是谁在创建web API,每个人都在用AngularJS告诉我们只需要做。。有什么想法请你去做并给予,因为我从我身边尝试了所有的方法,这是我唯一做不到的。。请让我知道。在javascript中,我们可以做的其他事情意味着这也是k,但它应该以与我给出的相同的方式导出。任何人都可以让我知道这个答案。我同意这不是Angular的责任,但仍然有库来处理这类事情。查看以下文档:
var app=angular.module('myCtrl',[]);
app.controller('myCtrl',function($scope){
$scope.data = [
  {

    "InverterId": Inverter,
    "LstRecords": [
      {
        "Id": 1,
        "InverterId": 1,
        "TimeofReading": "20170220",
        "Lastreading": 0,
        "Readingby": 0
      },
      {
        "Id": 32,
        "InverterId": 1,
        "TimeofReading": "20170221",
        "Lastreading": 0,
        "Readingby": 12
      },
      {
        "Id": 32,
        "InverterId": 1,
        "TimeofReading": "20170221",
        "Lastreading": 0,
        "Readingby": 12
      }
    ]
  }
]

});
$scope.exportData = function () {
    alasql('SELECT * INTO XLSX("john.xlsx",{headers:true}) FROM ?', [$scope.data] );  
};