本文介绍了xlsxwriter set_column 隐藏不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用 XlsxWriter 隐藏一列,但它似乎不起作用.该函数返回 0,表示该列已成功隐藏.

I'm trying to hide a column with XlsxWriter but it seems not working. The function returns 0 that means that the column has been hided with success.

我使用的是带有数字而不是字母的列.

I'm using column with number and not with letter.

workbook.get_worksheet_by_name('SENSORS').set_column(5,5, None, None, {'hidden': 1})

但是,列不会被隐藏.为什么该语句不起作用?

However, the columns don't be hide.Why the statement doesn't work?

提前致谢.

推荐答案

它应该可以工作.这是一个基于您的代码段的简单示例:

It should work. Here is a simple example based on your snippet:

import xlsxwriter

workbook = xlsxwriter.Workbook('test.xlsx')
worksheet = workbook.add_worksheet('SENSORS')

workbook.get_worksheet_by_name('SENSORS').set_column(5, 5, None, None, {'hidden': 1})

for col_num in range(8):
    worksheet.write(0, col_num, col_num)

workbook.close()

输出,注意第 5 列是隐藏的.

Output, note that column 5 is hidden.

这篇关于xlsxwriter set_column 隐藏不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-19 08:01