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
9
votes
6 answers

xlsxwriter: How to insert a new row

Using xlsxwriter, how do I insert a new row to an Excel worksheet? For instance, there is an existing data table at the cell range A1:G10 of the Excel worksheet, and I want to insert a row (A:A) to give it some space for the title of the report. I…
Jason O.
  • 3,168
  • 6
  • 33
  • 72
9
votes
3 answers

How to set automatically the width of a column in xlsxwriter

I'm getting lost of using worksheet.set_column all the time. Is there any possibility of setting the width of all columns automatically? What would be the Python function that simulates it? (using only xlsxwriter library): def autofit(filename,…
Anis Khadhri
  • 177
  • 1
  • 2
  • 12
9
votes
4 answers

How to set formatting for entire row or column in xlsxwriter Python?

workbook = xlsxwriter.Workbook('demo1.xlsx') worksheet = workbook.add_worksheet() format = workbook.add_format({ 'bg_color': '#5081BB','font_color': '#FFFFFF','font_size': 12,'text_wrap':'true'}) textWrap =…
Mj.
  • 321
  • 1
  • 6
  • 13
9
votes
2 answers

Python Xlsx Writer - Write String to new row

I am using the xlsxwriter tool to write some data to a .xlsx from the user input. (I am very new to programming in general so sorry if my code is awful, it would be appreciated if you suggested / corrected any mistakes I have made! sorry!) Below is…
Ashley Redman BSc
  • 186
  • 1
  • 3
  • 18
8
votes
4 answers

Move a worksheet in a workbook using openpyxl or xl* or xlsxwriter?

I've read the docs for, openpyxl, xlwt, xlrd, xlutils, xlsxwriter. I don't find a way to move a sheet in an Excel workbook. Tests added a worksheet to the ends. Concretely, I have a calendar of sorts, ['JAN','FEB',...,'DEC'] and I need to replace…
xtian
  • 2,765
  • 7
  • 38
  • 65
8
votes
1 answer

Pandas to Excel conditional formatting whole column

I want to write a Pandas dataframe into Excel with formatting. For this I'm using xlsxwriter. My question is twofold: First, how can I apply conditional formatting to a whole column? In the examples they use specific cell-range formatting (eg.…
lte__
  • 7,175
  • 25
  • 74
  • 131
8
votes
1 answer

Cannot write to an excel AttributeError: 'Worksheet' object has no attribute 'write'

I am trying to write text to an excel I am following this post. This was working earlier but now it is not. I get: Error: line 122, in worksheet.write(0, 11, 'HI') AttributeError: 'Worksheet' object has no attribute 'write' df1 A …
user9086741
8
votes
1 answer

Pandas Excel Writer using Openpyxl with existing workbook

I have code from a while ago that I am re-using for a new task. The task is to write a new DataFrame into a new sheet, into an existing excel file. But there is one part of the code that I do not understand, but it just makes the code…
MattR
  • 4,887
  • 9
  • 40
  • 67
8
votes
2 answers

Appending rows in excel xlswriter

I have created an xls file in which I write some user inputs into the cells. So far so good, the program works; it writes the first line. But when I run again the program instead of appending the rows it writes on top of the first one. I'm trying…
8
votes
2 answers

XLSX Writer Python- 3 Color Scale with Number as Midpoint

I'm trying to conditional formatting in XLSX writer with a 3 color scale with a 0 midpoint value in the middle. I want all negative values to scale from red (lowest number) to yellow (when the value is zero) and all positive numbers to scale from…
8
votes
1 answer

Pandas DataFrame to Excel: Vertical Alignment of Index

Given the following data frame: import pandas as pd d=pd.DataFrame({'a':['a','a','b','b'], 'b':['a','b','c','d'], 'c':[1,2,3,4]}) d=d.groupby(['a','b']).sum() d I'd like to export this with the same alignment with…
Dance Party2
  • 7,214
  • 17
  • 59
  • 106
8
votes
1 answer

python XlsxWriter text wrapping and links styling

I need help with python XlsxWriter. I need to add link styling for external file link columns. But Xlsxwriter doesn't recognize styling for links(its second column) (text: underline, text-color: blue) if I'm adding the text wrapping for another…
Igor Komar
  • 381
  • 1
  • 8
  • 16
8
votes
1 answer

How can I get around Excel's URL Limitation?

I'm using the excellent xlsxwriter to build spreadsheets with Python. I've become aware of the issue where you can only write 40k or so URLS to a sheet before you start getting warned and the functionality is gated. Is there a way to write the urls…
HaPsantran
  • 5,581
  • 6
  • 24
  • 39
8
votes
1 answer

Applying formatting row by row in addition to column formatting with xlsxwriter

I am formatting all of my columns in an excel file using the xlsxwriter module: def to_excel(video_report, feed): # Create a Pandas Excel writer using XlsxWriter as the engine. writer = pd.ExcelWriter('daily_report.xlsx',…
metersk
  • 11,803
  • 21
  • 63
  • 100
8
votes
2 answers

How to apply multiple formats to one column with XlsxWriter

In the below code I apply number formatting to each of the columns in my excel sheet. However, I can't seem to figure out to apply multiple formattings to a specific column, either the centering or the numbering end up being over written. Is it…
metersk
  • 11,803
  • 21
  • 63
  • 100