export excel

为什么80%的码农都做不了架构师?>>>   hot3.png

You can install it via pip:

$ pip install Flask-Excel

or clone it and install it:

$ git clone http://github.com/pyexcel/Flask-Excel.git
$ cd Flask-Excel
$ python setup.py install

Installation of individual plugins , please refer to individual plugin page. For example, if you need xls file support, please install pyexcel-xls:

$ pip install pyexcel-xls

Setup

In your application, you must import it before using it:

from flask.ext import excel

or:

import flask.ext.excel

Quick start

A minimal application may look like this:

from flask import Flask, request, jsonify
from flask.ext import excel

app=Flask(__name__)

@app.route("/upload", methods=['GET', 'POST'])
def upload_file():
    if request.method == 'POST':
        return jsonify({"result": request.get_array(field_name='file')})
    return '''
    
    Upload an excel file
    

Excel file upload (csv, tsv, csvz, tsvz only)

''' @app.route("/download", methods=['GET']) def download_file(): return excel.make_response_from_array([[1,2], [3, 4]], "csv") @app.route("/export", methods=['GET']) def export_records(): return excel.make_response_from_array([[1,2], [3, 4]], "csv", file_name="export_data") # insert database related code here if __name__ == "__main__": app.run()

转载于:https://my.oschina.net/jk409/blog/707931

你可能感兴趣的:(export excel)