I'm getting the error File Size would require Zip64 when running the following code. The excel conversion is to large to save to disk to be later converted. Is there a way to zip before saving to disk? I tried writer.book.use_zip64() but it will not work. The result of the output from to_excel function is NoneType if assign it to a variable.
writer = pd.ExcelWriter(file_name,engine='xlsxwriter')
output_df.round(2)
output_df.to_excel (writer, index = False, header=True)
writer.save()
Pandas writes Excel files using the Xlwt module for xls files and the Openpyxl or XlsxWriter modules for xlsx files. To use XlsxWriter with Pandas you specify it as the Excel writer engine:
In order to apply XlsxWriter features such as Charts, Conditional Formatting and Column Formatting to the Pandas output we need to access the underlying workbook and worksheet objects. After that we can treat them as normal XlsxWriter objects.
) You can see that there are three sheets, and each sheet has different Name columns. The to_excel () function accepts sheet_name as a parameter, and here we can pass the three different sheet names and that DataFrame is saved in the respective sheets. If you want to export Pandas DataFrame to Excel files, then ExcelWriter () class is all you need.
Excel files can be created in Python using the module Pandas. In this article we will show how to create an excel file using Python. We start by importing the module pandas. From the module we import ExcelWriter and ExcelFile. The next step is to create a data frame.
I tried writer.book.use_zip64() but it will not work.
It should work. Here is a working example based on your snippet:
import pandas as pd
output_df = pd.DataFrame({'Data': [10, 20, 30, 20, 15, 30, 45]})
file_name ='pandas_simple.xlsx'
writer = pd.ExcelWriter(file_name, engine='xlsxwriter')
output_df.round(2)
output_df.to_excel(writer, index = False, header=True )
writer.book.use_zip64()
writer.save()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With