Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8408651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:41:31+00:00 2026-06-09T23:41:31+00:00

I need to stylize certain cells and rows in an xls file I create

  • 0

I need to stylize certain cells and rows in an xls file I create through my program, but I am having a few issues, possible misconceptions about how the xlwt easyxf stuff works.

First, if I write to the cell without a value and just the style, does the value inside get erased?

Second, I’m trying to write to cells using the style and value of the cell, but I keep getting an error:

"TypeError: 'XFStyle' object is not callable". -Solved

Now the problem is that the styles do not get implemented. After writing the cells, and outputting it to a xls file, there were no color,bg,size,font changes at all.

I tried googling this and was following other people’s examples, but for whatever reason, my code doesn’t work. Here it is:

def stylize_spreadsheet_accordingly(iFile, workbook, row_grey, row_underline, row_font_size, cells_yellow):
    #this time iFile is the file you're overwriting

    #styling stuff

    print "styling the document..."

    new_sheet.col(0).width = 256 * 18
    new_sheet.col(1).width = 256 * 69.43
    new_sheet.col(2).width = 256 * 9
    new_sheet.col(3).width = 256 * 20.71
    new_sheet.col(4).width = 256 * 8.43

    font_size_style = xlwt.easyxf('font: name Calibri, bold on, height 280;')
    font_underline_style = xlwt.easyxf('font: underline on;')
    fill_grey_style = xlwt.easyxf('pattern: back_color gray25;')
    fill_yellow_style = xlwt.easyxf('pattern: back_color yellow;')

    iBook = open_workbook(iFile)
    iSheet = iBook.sheet_by_index(0)

    for row_index in range(iSheet.nrows):
        if row_index in row_grey:
            for col_index in range(iSheet.ncols):
                new_sheet.write(row_index,col_index, iSheet.cell(row_index,col_index).value, fill_grey_style)
        if row_index in row_underline:
            for col_index in range(iSheet.ncols):
                new_sheet.write(row_index,col_index, iSheet.cell(row_index,col_index).value, font_underline_style)
        if row_index in row_font_size:
            for col_index in range(iSheet.ncols):
                new_sheet.write(row_index,col_index, iSheet.cell(row_index,col_index).value, font_size_style)
    for each in cells_yellow:
        new_sheet.write(each[0], each[1], iSheet.cell(each[0],each[1]).value, fill_yellow_style)

    return workbook

new_sheet is a global variable that I made in another function that represents the sheet I added to my xlwt workbook. The workbook I pass in, is the file that is supposed to contain that new_sheet. I might be over complicating it or doing it unethically, but it works.

P.S. If there’s a different way I could do this or change certain cells to be a full color in a different manner, please let me know. Once again, thanks.

Thanks, I fixed the code to what you guys said, and the TypeError went away, but after it completes, none of the styling options I created and used, went through. The xls file was still in its default format. How can this be?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:41:32+00:00Added an answer on June 9, 2026 at 11:41 pm

    You are getting 'XFStyle' object is not callable because you are calling it like a function instead of just passing it to sheet.write e.g.

    instead of

    new_sheet.write(row_index,col_index, iSheet.cell(row_index,col_index).value, fill_grey_style())
    

    use

    new_sheet.write(row_index,col_index, iSheet.cell(row_index,col_index).value, fill_grey_style)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need some help for creating a File and String search engine. The program needs
Need to apply a filter to a file like this: TUPAC_0006:1:1:2554:2356#0/1 0 * 0
Need to search the directory/sub-directories to find a file, would prefer it to stop
In our JavaFX project we need a line chart. I can easy stylize the
Need help to convert code from asp control to input type to fetch file
Need a div to partially show the image behind it, is this even possible?
Need advise I am currently using CRM4.0 webservice to create account from reading my
I have a site I made using jsp's and I need to stylize it.
I need a light css editor with certain functions. Already downloaded and tried a
need help here, been fixing for hours but to no avail. i will like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.