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
14
votes
3 answers

Possible to alter worksheet order in xlsxwriter?

I have a script which creates a number of the following pairs of worksheets in order: WorkSheet (holds data) -> ChartSheet using WorkSheet After the script is finished, I am left with worksheets ordered as such: Data1, Chart1, Data2, Chart2, Data3,…
Ben Southgate
  • 3,388
  • 3
  • 22
  • 31
13
votes
5 answers

Merge rows based on value (pandas to excel - xlsxwriter)

I'm trying to output a Pandas dataframe into an excel file using xlsxwriter. However I'm trying to apply some rule-based formatting; specifically trying to merge cells that have the same value, but having trouble coming up with how to write the…
mikelowry
  • 1,307
  • 4
  • 21
  • 43
13
votes
2 answers

Alternating row color using xlsxwriter in Python 3

Has anybody implemented alternating row color while generating excel using xlsxwriter in Python3? data_format = workbook.add_format( { 'bg_color': '#FFC7CE' }) worksheet.write(data_row, data_col + 1, row[1], data_format) This sets…
r0xette
  • 898
  • 3
  • 11
  • 24
13
votes
4 answers

Apply styles while exporting to 'xlsx' in pandas with XlsxWriter

I use the .to_excel method of pandas to write a DataFrame as an Excel workbook. This works nice even for multi-index DataFrames as index cells become merged. When using the pure XlsxWriter I can apply formats to cells what also works nice. However I…
Nikita
  • 429
  • 2
  • 6
  • 14
12
votes
3 answers

Remove default formatting in header when converting pandas DataFrame to excel sheet

This is something that has been answered and re-answered time and time again because the answer keeps changing with updates to pandas. I tried some of the solutions I found here and elsewhere online and none of them have worked for me on the current…
ArthurH
  • 203
  • 1
  • 3
  • 8
12
votes
2 answers

Setting default number format when writing to Excel from Pandas

I'm looking to set the default number format when writing to Excel from a Pandas dataframe. Is this possible? I can set the default date/datetime_format with the following, but couldn't find a way to set the default number format. writer =…
ChrisG
  • 1,230
  • 4
  • 17
  • 35
12
votes
3 answers

Writing multiple pandas dataframes to multiple excel worksheets

I'd like for the code to run 12345 thru the loop, input it in a worksheet, then start on 54321 and do the same thing except input the dataframe into a new worksheet but in the same workbook. Below is my code. workbook =…
Milhouse
  • 565
  • 3
  • 8
  • 16
12
votes
1 answer

Insert pandas chart into an Excel file using XlsxWriter

I use python 3.4, pandas 0.14.1 and XlsxWriter 0.5.6. I create a graph called 'graph' using pandas with the following code graph=data_iter['_DiffPrice'].hist() , which produces a beautiful histogram. Now, how do I insert that graph into an Excel…
Charles
  • 613
  • 2
  • 8
  • 18
11
votes
5 answers

Pandas / xlsxwriter writer.close() does not completely close the excel file

I'm trying to modify manually an excel file after creating it with a python script. Unfortunately, if the script is still running, a sharing file violation error message appears when trying to save it with the same name. Everything runs smoothly in…
Nicolas Peille
  • 149
  • 1
  • 2
  • 10
11
votes
1 answer

XlsxWriter set global font size

How do permanently set the font size using xlswriter when you first create the workbook? I tried: book = xlsxwriter.Workbook(os.getcwd() + '\\test.xlsx') sheet1 = book.add_worksheet() format = book.add_format() format.set_font_size(10) But I still…
guy
  • 1,021
  • 2
  • 16
  • 40
11
votes
2 answers

XlsxWriter: lock only specific cells

I'm creating xlsx files with xlsxwriter and want to protect specific cells (for example all cells in a range B2:B20). The documentation says that you can use worksheet.protect() method - it's turn on protection for whole worksheet by default - and…
dabajabaza
  • 301
  • 1
  • 4
  • 14
11
votes
2 answers

XlsxWriter: set_column() with one format for multiple non-continuous columns

I want to write my Pandas dataframe to Excel and apply a format to multiple individual columns (e.g., A and C but not B) using a one-liner as such: writer = pd.ExcelWriter(filepath, engine='xlsxwriter') my_format =…
Qululu
  • 1,040
  • 2
  • 12
  • 23
11
votes
4 answers

xlswriter formatting a range

In xlswriter, once a format is defined, how can you apply it to a range and not to the whole column or the whole row? for example: perc_fmt = workbook.add_format({'num_format': '0.00%','align': 'center'}) worksheet.set_column('B:B', 10.00,…
Gabriel
  • 3,737
  • 11
  • 30
  • 48
11
votes
3 answers

Charts from Excel to PowerPoint with Python

I have an excel workbook that is created using an excellent "xlsxwriter" module. In this workbook, there about about 200 embedded charts. I am now trying to export all those charts into several power point presentations. Ideally, I want to preserve…
nyan314sn
  • 1,766
  • 3
  • 17
  • 29
11
votes
1 answer

Writing pandas/matplotlib image directly into XLSX file

I am generating plots in pandas/matplotlib and wish to write them to an XLSX file. I am not looking to create native Excel charts; I am merely writing the plots as non-interactive images. I am using the XlsxWriter library/engine. The closest…
sparc_spread
  • 10,643
  • 11
  • 45
  • 59