第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

xlsxwriter 條件格式問題

xlsxwriter 條件格式問題

侃侃爾雅 2021-12-16 15:03:30
我有如下所示的條件格式:worksheet_budget.conditional_format('D2:D100', {'type': 'cell',                                            'criteria': 'between',                                            'minimum': 0,                                            'maximum': 100,                                            'format': caution})worksheet_budget.conditional_format('D2:D100', {'type': 'cell',                                           'criteria': '<',                                           'value': 0,                                           'format': over})它的意圖是對(duì)于每個(gè)小于 0 的值,將格式切換為大于和 0 - 100 之間的格式,以及警告格式。然而,最終發(fā)生的是,對(duì)于沒有值的字段,它會(huì)將其視為 0 并使用警告格式。我只希望具有會(huì)計(jì)編號(hào)的字段具有兩種格式之一。如果它是空的,它應(yīng)該沒有格式。
查看完整描述

2 回答

?
鴻蒙傳說

TA貢獻(xiàn)1865條經(jīng)驗(yàn) 獲得超7個(gè)贊

正如@martineau 指出的那樣,并在文檔中突出顯示,將'type': 'cell'第二種格式更改為'type': 'blanks'應(yīng)將over格式應(yīng)用于所有沒有值的單元格。


您還需要?jiǎng)h除criteria和value鍵:


worksheet_budget.conditional_format('D2:D100', {'type': 'blanks',

                                       'format': over})


查看完整回答
反對(duì) 回復(fù) 2021-12-16
?
慕神8447489

TA貢獻(xiàn)1780條經(jīng)驗(yàn) 獲得超1個(gè)贊

幾乎每次我在 XlsxWriter 中回答有關(guān)條件格式的問題時(shí),我都會(huì)說同樣的話:首先弄清楚如何在 Excel 中進(jìn)行操作,然后將其應(yīng)用到 XlsxWriter。


將空白單元格視為零的條件格式問題似乎是 Excel 中的一個(gè)已知問題/功能。我遵循了這篇文章中有關(guān)該問題的方法之一的建議,并為空白單元格設(shè)置了額外的默認(rèn)格式。我還需要設(shè)置stop_if_true屬性。這是一個(gè)工作示例:


import xlsxwriter


workbook = xlsxwriter.Workbook('conditional_format.xlsx')

worksheet = workbook.add_worksheet()


# Add a format. Light red fill with dark red text.

format1 = workbook.add_format({'bg_color': '#FFC7CE',

                               'font_color': '#9C0006'})


# Add a format. Green fill with dark green text.

format2 = workbook.add_format({'bg_color': '#C6EFCE',

                               'font_color': '#006100'})


# Add a default format.

format3 = workbook.add_format()



# Some sample data to run the conditional formatting against.

data = [

    [34, -75, None, 75, 66, 84, 86],

    [6, 24, 1, 60, 3, 26, 59],

    [None, 79, 97, -13, 22, 5, 14],

    [-27, -71, None, 17, 18, 0, 47],

    [88, 25, -33, 23, 67, "", 36],

    ['', 100, 20, 88, 54, 54, 88],

    [6, 57, '', 28, 10, 41, 48],

    [52, 78, -1, 96, 26, 0, ""],

    [60, -54, 81, None, 81, 90, 55],

    [70, 5, 46, 14, 71, 41, 21],

]



for row, row_data in enumerate(data):

    worksheet.write_row(row + 2, 1, row_data)


worksheet.conditional_format('B3:H12', {'type': 'blanks',

                                        'stop_if_true': True,

                                        'format': format3})


worksheet.conditional_format('B3:H12', {'type': 'cell',

                                        'criteria': 'between',

                                        'minimum': 0,

                                        'maximum': 100,

                                        'format': format1})


worksheet.conditional_format('B3:H12', {'type': 'cell',

                                        'criteria': '<',

                                        'value': 0,

                                        'format': format2})


workbook.close()

輸出:

http://img1.sycdn.imooc.com//61bae4e40001264f04950367.jpg

查看完整回答
反對(duì) 回復(fù) 2021-12-16
  • 2 回答
  • 0 關(guān)注
  • 290 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)