Home > Backend Development > Python Tutorial > Example of how Python uses tablib to generate excel files

Example of how Python uses tablib to generate excel files

高洛峰
Release: 2017-03-07 15:40:51
Original
1877 people have browsed it

The example in this article describes how Python uses tablib to generate excel files. Share it with everyone for your reference, the details are as follows:

import tablib
headers = ('lie1', 'lie2', 'lie3', 'lie4', 'lie5')
mylist = [('23','23','34','23','34'),('sadf','23','sdf','23','fsad')]
mylist = tablib.Dataset(*mylist, headers=headers)
with open('excel.xlsx', 'wb') as f:
  f.write(mylist.xlsx)
Copy after login

This is a basic and simple example of using tablib to generate an excel file. First, you need to To install the tablib module, enter: pip intall tablib on the command line to automatically download and install it.

The effect is as follows:

Example of how Python uses tablib to generate excel files

For more examples of how Python uses tablib to generate excel files, please pay attention to the PHP Chinese website for related articles!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template