Dynamic Excel Files via Python.

In a website, I saw a request from a user, saying:

I am creating xlsx for my clients based on dynamic information. When I am generating the xlsx file, I am using formula, cell coloring, row border coloring etc for 400 records, which makes the file creation time delay. So currently, its taking around 40 minutes. But I need some solution which would help me to generate it in minutes.

 

Most of the programming languages and scripting shells have support for excel but all of them are not simple to implement and some of them has lack of features and only some portion of Excel features can be simulated. So, I made a quick search for it and noticed that Python has a great module for this kind of jobs : XlsxWriter

 

By looking at features it supports, I liked it and made a sample from its examples: Creating 400 excel files, each file has its file number inside, all files have a data set and all have a total count of columns multiplied by file number.

 

This is the command I used to run the program. It is nice that creating and making basic operations on all excel files took only 2.65s.

 

When I checked the folder, I saw 400 excel files that are really created.

 

And here is the 400th file content. There is also a formula inside! 🙂

 

If you wanna see the code, you may find it in my github repo.

Advertisements