简体   繁体   中英

When using set_row() for xlsxwriter, how do I get this to include the first column?

I don't really know how to ask that question in the title... but here's the code:

w = 0

for data in expireintlist:
    if expireintlist[w] != 0:
        if (expireintlist[w] - epochalarm) <= cur_time:
            worksheet.set_row(w+1, None, formatAlarm, {'hidden': True})
            print("HERE!!!")
    w += 1

What I'm doing is looping through the list of GPG key expiration dates, and any dates that fall within 60 days of today, to set the worksheet row format to 'formatAlarm'. And this works... right now I have 2 keys that fall within 60 days, but for some reason, this isn't including the first column of the spreadsheet for the reformat.

Quick example

What am I missing? A few things to consider... this is obviously just the bit that is reformatting the rows, but in case you're asking:

epochalarm and cur_time are defined earlier. formatAlarm is as well.

formatAlarm = workbook.add_format({'bold': True, 'bg_color': 'red', 'num_format': 'mmm d yyyy hh:mm AM/PM'})

You'll also see that I start at w+1 because I use the very first row in the worksheet for a header.

Have you tried to use set_column ? I think the below could work for you, check out the xlsx documentation here

column_width = 30
formatAlarm = workbook.add_format({'bold': True, 'bg_color': 'red', 'num_format': 'mmm d yyyy hh:mm AM/PM'})


worksheet.set_column('A:A', columnd_width, formatAlarm)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM