自动增加 xls 中的行并使用 python 更新它的值 [英] auto increment row in xls and update it's values using python

查看:66
本文介绍了自动增加 xls 中的行并使用 python 更新它的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 python 自动更新 xls 文件(行和列)时遇到问题.

Facing issue while automatically updating an xls file ( Row and column) using python.

示例:(这是第一行和第二行,想要自动增加行值并相应地更新它的值)

Example: ( This is for first and second row, want to automatically increase the row values and correspondingly update it's values )

第一行

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)

第二行

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.

谢谢,尼拉吉

推荐答案

您可以将 write 放入循环中以增加行号.

You could put the write in a loop to increment the row number.

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)

这篇关于自动增加 xls 中的行并使用 python 更新它的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆