Questions tagged [xlsxwriter]

XlsxWriter is a python module for creating Excel XLSX files

XlsxWriter is a Python module for creating Excel XLSX files.

It can be used to write text, numbers, and formulas to multiple worksheets and it supports features such as formatting, images, charts, page setup, autofilters, conditional formatting and many others.

This module cannot be used to modify or write to an existing Excel XLSX file.

1959 questions
11
votes
2 answers

UnicodeDecodeError error writing .xlsx file using xlsxwriter

I am trying to write about 1000 rows to a .xlsx file from my python application. The data is basically a combination of integers and strings. I am getting intermittent error while running wbook.close() command. The error is the…
Santanu C
  • 1,362
  • 3
  • 20
  • 38
10
votes
4 answers

xlsxwriter error: AttributeError: 'Workbook' object has no attribute 'add_format'

I'm doing some simple conditional formatting using xlsxwriter but I am getting this error when I run the code below. AttributeError: 'Workbook' object has no attribute 'add_format' I have updated xlsxwriter and looked at a lot of questions on SO…
aqw
  • 126
  • 1
  • 1
  • 9
10
votes
1 answer

why pandas dataframe style lost when saved with "to_excel"?

Per this example the to_excel method should save the Excel file with background color. However, my saved Excel file does not have any color in it. I tried to write using both openpyxl and xlsxwriter engines. In both cases, the Excel file was saved,…
Chandu
  • 103
  • 1
  • 5
10
votes
2 answers

Write pandas dataframe to Excel with xlsxwriter and include `write_rich_string` formatting

The following is reproducible and generates the desired output. import xlsxwriter, pandas as pd workbook = xlsxwriter.Workbook('pandas_with_rich_strings.xlsx') worksheet = workbook.add_worksheet() # Set up some formats to use. bold =…
Clay
  • 2,584
  • 1
  • 28
  • 63
10
votes
3 answers

Excel export with Flask server and xlsxwriter

So I've been using XLSXWriter in the past to export an excel file containing one tab filled with two pandas dataframes. In the past I've only been exporting the file to a local path on the user's computer but I'm doing the transition to a web…
John_Mtl
  • 349
  • 2
  • 4
  • 13
10
votes
2 answers

Handle Nan when using Pandas ExcelWriter in python

How would I change the following code to handle NaN values as just empty cells within my dataframe as I iterate through it line by line outputting values in column A? excel = pd.ExcelWriter(f_name,engine='xlsxwriter') wb = excel.book ws =…
Mike
  • 197
  • 1
  • 2
  • 10
10
votes
1 answer

How to apply format as 'Text' and 'Accounting' using xlsxwriter

I have been using xlsxwriter for a while and find it to be really helpful. I have used it for multiple purposes like custom data validation, custom formats etc However there are two things i am not able to perform. set format of a cell to 'text'…
user1906450
  • 517
  • 1
  • 6
  • 19
9
votes
1 answer

'XlsxWriter' object has no attribute 'save'. Did you mean: '_save'?

I was trying the following code that I found. import pandas as pd import xlsxwriter data = {'Name': ['John', 'Jane', 'Adam'], 'Age': [25, 30, 35], 'Gender': ['M', 'F', 'M']} df = pd.DataFrame(data) writer = pd.ExcelWriter('output.xlsx',…
Straniero95
  • 101
  • 1
  • 1
  • 2
9
votes
3 answers

Delete row/column from Excel with xlsxwriter

Is it possible? I know ws.set_row('B:B', options={'hidden': True}) But, is there something like ws.set_row('B:B', options={'delete_row': True})?
PedroBiel
  • 489
  • 1
  • 8
  • 21
9
votes
1 answer

Unable to close worksheet in xlsxwriter

I am trying to create an excel workbook using xlsxwriter, but when I try to do workbook.close() i get following exception : Traceback (most recent call last): File "/usr/local/bin/fab", line 11, in sys.exit(program.run()) File…
gpd
  • 180
  • 1
  • 13
9
votes
1 answer

Pandas xlsxwriter to write dataframe to excel and implementing column-width and border related formatting

Background: I am using Pandas and have a dataframe 'df' which I intend to write into an Excel sheet. I use the code below and get the output Excel sheet as shown in attached snapshot 'Present.JPG': import pandas as pd import xlsxwriter writer =…
Sinha
  • 431
  • 1
  • 5
  • 12
9
votes
1 answer

Thick border in xlsxwriter

Is there any option to add thick border in Excel using xlsxwriter? I'm writing a border between a range using conditional format. Add table won't work in my case.
abhilash mishra
  • 235
  • 2
  • 3
  • 11
9
votes
3 answers

Rename Excel worksheet using xlsxwriter

How do i rename excel worksheet using xlsxwriter in python. I am using python 2.7 in linux to create excel reports. But cannot find an option to rename the tabs
kten
  • 445
  • 4
  • 13
  • 26
9
votes
4 answers

How can I format the index column(s) with xlsxwriter?

I'm using xlsxwriter and the set_column function that format the columns in my excel outputs. However, formatting seems to be ignored when applied to the index column (or index columns in case of multi index). I've found a workaround, so far is to…
A. Kerbrat
  • 91
  • 1
  • 3
9
votes
3 answers

How to dump a dictionary into an .xlsx file with proper column alignment?

I have a dictionary with 2000 items which looks like this: d = {'10071353': (0, 0), '06030011': (6, 0), '06030016': (2, 10), ...} Given that I want to write it to an .xlsx file, I use this code (taken from here): import xlsxwriter workbook =…
FaCoffee
  • 7,609
  • 28
  • 99
  • 174