Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用xlsxwriter在表格中循环查看索引_Python_Loops_Worksheet_Xlsxwriter - Fatal编程技术网

Python 使用xlsxwriter在表格中循环查看索引

Python 使用xlsxwriter在表格中循环查看索引,python,loops,worksheet,xlsxwriter,Python,Loops,Worksheet,Xlsxwriter,我想知道我是否可以使用xlsxwriter迭代工作表并确定索引的长度?我现在使用的代码不是我想要的工作方式 for worksheet in workbook.worksheets(): if len(worksheet.index) <= 1: worksheet.hide() else: move on and do something else 工作簿中工作表的。工作表(): 如果len(worksheet.index)没有公共方法来确

我想知道我是否可以使用xlsxwriter迭代工作表并确定索引的长度?我现在使用的代码不是我想要的工作方式

for worksheet in workbook.worksheets():
    if len(worksheet.index) <= 1:
       worksheet.hide()
    else:
        move on and do something else
工作簿中工作表的
。工作表():

如果len(worksheet.index)没有公共方法来确定XlsxWriter工作表是否有数据,因为父应用程序在添加数据时可以自己跟踪数据

或者,您可以检查
工作表.dim_rowmax
是否为
None


另外,应用程序添加空工作表,然后隐藏它们,这有点奇怪。这可能会让最终用户感到困惑。也许您可以在创建空工作表之前确定是否需要先添加数据

谢谢你的见解,我一定会调查的