5

In my excel-export.html I have:

<div class="config-menu-container first">

            <div class="menu-title">
        <span class="excel import">Excel import</span>
                <span class="excel export">Excel Export</span>
            </div>

            <ul class="menu-body step2" id="exportable">
                <li class="title">
                    <span class="label main order first”>1</span>
                    <span class="label main order second”>2</span>
                    <span class="label main order third”>3</span>
                </li>
                <li class="row" ng-repeat="device in devices">
                    <span class="label sub first" ng-bind="device.deviceId" ng-click="deviceScope = device.id"></span>
                    <span class="input second">
                        <custom-input type="text" width="330" height="24" model="device.name"></custom-input>
                    </span>
                    <span class="input third" ng-repeat-end>
                        <custom-input type="select2" width="462" height="24" label=“Select Device."
                                      options="option.billingInfo" model="device.billingTargetId"></custom-input>
                    </span>
                </li>
            </ul>
</div>

In my excel-export.directive.js I have:

'use strict';

angular.module('bemsApp')
  .directive('excelExport', function () {
    return {
      templateUrl: 'app/directives/excel-export/excel-export.html',
      restrict: 'EA',
      link: function (scope, element, attrs) {
          scope.exportData = function () {
                var blob = new Blob([document.getElementById('exportable').innerHTML], {
                    type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"
                });
                saveAs(blob, "Report.xls");
            };
      }
    };
  });

When I try to save the Excel file, an error occurs saveAs did not define.

I have to separately define the saveAs function wondering if there is a way to save the Excel file.

6
  • 2
    You need a Filesaver.js library since FileSaver intervace is removed from the html5 specs. See the doc updates.html5rocks.com/2011/08/… Commented Mar 31, 2015 at 5:23
  • Won't the <a> tag work, like described in answer here? Commented Mar 31, 2015 at 5:38
  • @iiro is correct. But why not make it an answer, would upvote. Commented Mar 31, 2015 at 5:42
  • It might help you. code-sample.com/2014/12/… Commented Mar 31, 2015 at 5:43
  • I was successful by far is to create an Excel file containing the Filesaver.js. So you open an Excel file, not an HTML tag that data into output unchanged. In order to output in Excel format would you want to do this any other way? Commented Mar 31, 2015 at 5:43

1 Answer 1

4

You need a Filesaver.js library since FileSaver interface is removed from the html5 specs. See the doc

http://updates.html5rocks.com/2011/08/Saving-generated-files-on-the-client-side

Sign up to request clarification or add additional context in comments.

2 Comments

I was successful by far is to create an Excel file containing the Filesaver.js. So you open an Excel file, not an HTML tag that data into output unchanged. In order to output in Excel format would you want to do this any other way?
@bismute sorry but i don't really understand what do you mean now? Could you clarify a bit?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.