简体   繁体   English

自动递增xls中的行并使用python更新其值

[英]auto increment row in xls and update it's values using python

Facing issue while automatically updating an xls file ( Row and column) using python. 使用python自动更新xls文件(行和列)时遇到问题。

Example: ( This is for first and second row, want to automatically increase the row values and correspondingly update it's values ) 示例:(这是第一行和第二行,要自动增加行值并相应地更新其值)

For first row 对于第一行

sheet1.write(0, 0, Number)
sheet1.write(0, 1, algo_type.tag)
sheet1.write(0, 2, ref_slope)
sheet1.write(0, 3, opt_slope)
sheet1.write(0, 4, angle)

For second row 对于第二行

sheet1.write(1, 0, Number)
sheet1.write(1, 1, algo_type.tag)
sheet1.write(1, 2, ref_slope)
sheet1.write(1, 3, opt_slope)
sheet1.write(1, 4, angle)

Please suggest how to takel this type of situations. 请提出如何处理这种情况的建议。

Thanks, Niraj 谢谢,Niraj

You could put the write in a loop to increment the row number. 您可以将write放入循环中以增加行号。

maxRows = 10   # or however many rows you want
for rowNumber in range(maxRows):
    sheet1.write(rowNumber, 0, Number)
    sheet1.write(rowNumber, 1, algo_type.tag)
    sheet1.write(rowNumber, 2, ref_slope)
    sheet1.write(rowNumber, 3, opt_slope)
    sheet1.write(rowNumber, 4, angle)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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