Home > Article > Backend Development > Example of how Python uses tablib to generate excel files
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)
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:
For more examples of how Python uses tablib to generate excel files, please pay attention to the PHP Chinese website for related articles!