Giter Site home page Giter Site logo

json-export-excel's Introduction

ngJsonExportExcel - export excel from json using AngularJS

How to get it ?

Bower

bower install ng-json-export-excel --save

Usage

  1. Add json-export-excel.js and FileSaver.js to your main file (index.html)

  2. Set ngJsonExportExcel as a dependency in your module

var myapp = angular.module('myapp', ['ngJsonExportExcel'])
  1. Example simple:
<button ng-json-export-excel data="dataList" report-fields="{'uesr.username': 'Heder 1', keyjson2: 'Header 2', keyjson3: 'Head 3'}" filename =" 'export-excel' " separator="," class="css-class"></button>

Default filename = 'export-excel'

Default separator = ';'

  1. Please find examples in the directory example or You can check out this live example here: http://plnkr.co/6ieuJ1khmKFds9VYHoDv

json-export-excel's People

Contributors

garryone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

json-export-excel's Issues

How to set report-fields ,use $scope

for example
<button ng-json-export-excel data="datalist" report-fields="select" filename="'filename'" separator=',' class="btn-sm btn-primary">Export Excel</button>

$scope.select = "{id: 'ID Heder', DeviceName: 'DeviceName', udeviceId: 'udeviceId'}"

Data not getting displayed properly

If any value contains the character comma then while opening in excel data is not getting displayed properly. Any workaround to fix this problem.

Is it possible to include some static messages at bottom of the excel document?

Example:
I have data objects that looks like below.

$scope.dataList = [
                    {
                        id: 1,
                        name: 'github',
                        price: '200$',
                        publisher: {
                            name: 'hieutran',
                            company: 'Dtag-VN'
                        }
                    },
                    {
                        id: 2,
                        name: 'google',
                        price: '300$',
                        publisher: {
                            name: 'tran',
                            company: 'Vietname'
                        }
                    }
                ];
$scope.Messages= ["Message 1","Message 2","Message 3"];

Right now, I am able to generate a Excel using only one data object as below.

<button ng-json-export-excel data="dataList" report-fields="{id: 'ID Heder', name: 'Name Header', price: 'Price Head'}" filename="'filename'" class="btn-sm btn-primary">Export Excel</button>

image

I'm looking for a solution to achieve below report.
image

Is this possible here?

Returning blank string for date type object

when a field is date type then it is always returning "" as value. I have modified file to add check for date type object. see if its helpful

function _objectToString(object) {
var output = '';
if(angular.isDate(object)){
return object.toLocaleDateString();
}
angular.forEach(object, function(value, key) {
output += key + ':' + value + ' ';
});

                    return '"' + output + '"';
                }

Data is displayed in one column only

Sometimes when I export the data to csv file, the data is displayed in the first column only. I have tried this on different platforms and it works on both and also displays incorrectly on both so I can't figure out the cause so far.

One thing I came across was the separator to be , and I believe this is already done here:
<button class="btn btn-sm btn-warning" ng-json-export-excel data="reports_index.models" report-fields="{'user_name': 'User', 'title': 'Title', 'department': 'Department', 'senior': 'Senior', 'assessment_name': 'Assessment Name', 'product_name': 'Product Name', 'submission_date': 'Submission Date', 'country': 'Country', 'score': 'Score'}", filename =" 'report' " class="css-class">Export</button>

thank you for this

through your repo, I find FileSaver.js and find this issue
mybe this will help me to export excel

$scope.separator

With the new $scope.separator addition we might need to either update the example to include: separator="," or change the default separator on line 19: to ','.

Thanks,
Kevin

Fetch data on click event

Hi,
The way your plugin works is that data should be available when user click on the button. Is there any way to call web api service first, when user clicks on a button?

Thanks,
Igor

default format of exported file is csv.

Hi,
Default format of exported file is csv.

I have modified file extension in FileSaver.js.

Its exporting now excel files with .xls format. But when I open it using Microsoft Excel it gives following warning everytime.

'The file format and extension do not match. file can be corrupted or unsafe.Unless you know this source don't open it. Do you want to open it anyway ?' : Yes : No

Is there any way to remove this warning ?

Regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.