I’m trying to, in the interim, write a program that runs some power queries I have.
When I run this code, it removes the rows but also deletes.the associated power queries. Note I have sheet delete_rows(3, sheet.max_row - 1)
but sheet delete_rows(2, sheet.max_row - 1)
would also delete the query.
After I execute this, I add in more data from a new sheet and refresh the query. However, I get a com error which I assume is because.it has nothing to refresh.
How can I modify this to correct this and if possible, why would this be deleting the power query, and the modification does not?
if__name__=='__main__' book = openpyxl.load_workbook(file_path) sheet = book['Results'] sheet.delete_rows(3, sheet.max_row - 1) book.save(saveFile_path)
Edit: fix typos and added questions
submitted by /u/soberbrodan
[link] [comments]
r/learnpython I’m trying to, in the interim, write a program that runs some power queries I have. When I run this code, it removes the rows but also deletes.the associated power queries. Note I have sheet delete_rows(3, sheet.max_row – 1) but sheet delete_rows(2, sheet.max_row – 1) would also delete the query. After I execute this, I add in more data from a new sheet and refresh the query. However, I get a com error which I assume is because.it has nothing to refresh. How can I modify this to correct this and if possible, why would this be deleting the power query, and the modification does not? if__name__==’__main__’ book = openpyxl.load_workbook(file_path) sheet = book[‘Results’] sheet.delete_rows(3, sheet.max_row – 1) book.save(saveFile_path) Edit: fix typos and added questions submitted by /u/soberbrodan [link] [comments]
I’m trying to, in the interim, write a program that runs some power queries I have.
When I run this code, it removes the rows but also deletes.the associated power queries. Note I have sheet delete_rows(3, sheet.max_row - 1)
but sheet delete_rows(2, sheet.max_row - 1)
would also delete the query.
After I execute this, I add in more data from a new sheet and refresh the query. However, I get a com error which I assume is because.it has nothing to refresh.
How can I modify this to correct this and if possible, why would this be deleting the power query, and the modification does not?
if__name__=='__main__' book = openpyxl.load_workbook(file_path) sheet = book['Results'] sheet.delete_rows(3, sheet.max_row - 1) book.save(saveFile_path)
Edit: fix typos and added questions
submitted by /u/soberbrodan
[link] [comments]