xlwings

xlwings error: pywintypes.com_error: (-2147352573, 'Member not found.', None, None)

北城余情 提交于 2021-02-19 08:09:05
问题 I have an Excel open which has RTD streaming data (financial data from a trading platform). My goal is read the data by Python and save it as soon as it changes. The goal is to capture every milisecond. I am using xlwings to read the cell value but usually after 50-100 attempts I got the same error. Any idea how to solve it? import xlwings as xw n_of_times_checked=0 while True: n_of_times_checked +=1 print("Cell value:",xw.Range("D41").value," Num of times checked:",n_of_times_checked) The

Copy pasting multiple sheets into new workbook

為{幸葍}努か 提交于 2021-02-17 06:11:53
问题 The goal is to copy paste multiple existing sheets out of a workbook into a new workbook using xlwings. I have: app = xw.App(visible=False) book = xw.Book(path) sheet_1 = book.sheets["Sheet1"] sheet_2 = book.sheets["Sheet2"] wb_res = xw.Book() sheet_active = wb_res.sheets.active sheet_1.api.Copy(Before=sheet_active) This throws: TypeError: Objects for SAFEARRAYS must be sequences (of sequences), or a buffer object. Bonus question for the brave: - How can I replace all formulas on a sheet for

xlwings gives “Invalid class string” error

萝らか妹 提交于 2021-02-11 13:53:11
问题 I'm simply trying to get xlwings working with: Windows 8.1 Python 2.7.5 Excel 2013 xlwings installed OK (it imports without error messages). I've tried using IDLE and also using ipython/Python 2.7.6 and under both I get similar error traces which I don't really follow. Here is the output from the IDLE session: Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information. >>> from xlwings import Workbook,

Move worksheet within a workbook to the end [duplicate]

浪子不回头ぞ 提交于 2021-02-10 15:51:00
问题 This question already has an answer here : Moving Worsksheet after a Named Worksheet in Excel using pywin32 Dispatch (1 answer) Closed 3 months ago . With xlwings, I am trying to move a worksheet within a workbook to the end. For example, a workbook contains a collection of the following sheets: Sheet1, Sheet2, Sheet3 How can I move Sheet1 after Sheet3 in order to get the following order? Sheet2, Sheet3, Sheet1 If I use ws1.api.Move(Before=ws3.api) the line works as expected, but I am not

Move worksheet within a workbook to the end [duplicate]

眉间皱痕 提交于 2021-02-10 15:50:20
问题 This question already has an answer here : Moving Worsksheet after a Named Worksheet in Excel using pywin32 Dispatch (1 answer) Closed 3 months ago . With xlwings, I am trying to move a worksheet within a workbook to the end. For example, a workbook contains a collection of the following sheets: Sheet1, Sheet2, Sheet3 How can I move Sheet1 after Sheet3 in order to get the following order? Sheet2, Sheet3, Sheet1 If I use ws1.api.Move(Before=ws3.api) the line works as expected, but I am not

passing argument in xlwings RunPython VBA function

浪子不回头ぞ 提交于 2021-01-29 07:42:22
问题 I am getting some data from excel sheets using python. I'm using xlwings to accomplish this. I am trying to pass the path to the current workbook to my file, where it can use it to find the Excel book. I cannot use xlwings UDF's. Here's my VBA code: Sub Button1_Click() RunPython ("import exceltest; exceltest.excelTest('" & ThisWorkbook.FullName & "')") End Sub Here's my exceltest.py Python code: def excelTest(path_of_file): print (path_of_file) Here's the error I'm getting: Error File "

xlwings - Automation error for simple UDF function setting cell value

…衆ロ難τιáo~ 提交于 2021-01-29 07:06:40
问题 I have a fairly basic function that is supposed to set a cell value (in theory a DataFrame, but I've replaced that with 1 as part of my debugging). @xl.func def RT_GetChartData(): excel = xl.Book.caller() excel.app.display_alerts = False #I do this because I keep getting OLE errors excel.sheets("EventDates").range("TempEventOutput").value = 1 return "done" When I call this function from Excel, it sometimes sets the cell to 1 (but not every time, as I've replaced that with 2, 3, etc and doesn

module 'xlwings' has no attribute 'Book'

爷,独闯天下 提交于 2020-08-05 10:05:48
问题 I'm trying to use xlwings for the first time but I can't quite understand the documentation. From the section "Quickstart" I read import xlwings as xw wb = xw.Book() # this will create a new workbook When I try this "at home", I have no problem importing xlwings but with the second script I get this error: AttributeError: module 'xlwings' has no attribute 'Book' When I try to see the attributes of xw I can see AboveBelow,ActionTime etc. but not Book. Can you help please? Thank you very much.