简体   繁体   中英

How to update a cell value in excel in Python

I have a spreadsheet which is having following columns: TestID TestData ExpectedOutput ActualOutput Result

I have separate python scripts for each test-id. I need to read the row corresponding to that particular test-id and after execution, need to update result in same spreadsheet. I am not able to update that result value. can someone please help? I read the spreadsheet using Pandas. eg a row in spread sheet:

TestID TestData ExpectedOutput ActualOutput Result

Testid-1 Min_freq=5,Max_freq=60, Drive started Drive started Pass

My script would search for this testid and read the test data. after execution, it would compare the output with expected output and accordingly would update the value of cell Result. I am not getting how to update result value.

Please help me.

The only package that can modify/edit an existing excel is openpyxl You can read it by xlrd, but cannot modify it by xlwt or xlsxwriter, which can create and flash new xls and xlsx.

However, if you are using another source to edit the existing excel, they are not editing the same ones but two template mirror files, be sure to save it before letting python to read it, and vise versa.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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