I am getting the below error while running the given code from Azure devops pipeline and the same code works fine when triggered from local virtual machine. Any help would be indeed appreciated!!!
Error:
com_error: (-2147221005, 'Invalid class string', None, None)
Versions:
pywin32 = 300,
Excel = WPS Office
Agent Type: Self hosted agent configured in C: drive which is running as a service.
from threading import Lock
import win32com.client as win32
from openpyxl import load_workbook
from pyexcelerate import Workbook, Color, Style, Fill
from win32com.client import Dispatch, DispatchEx
from xlrd import open_workbook
with lock:
while True:
try:
EP._filepath = filepath
EP._activesheet = open_workbook(filepath)
break
except:
ValueError
try:
xl = Dispatch('Excel.Application')
except:
xl = DispatchEx('Excel.Application')
finally:
xl = win32.gencache.EnsureDispatch('Excel.Application')
wb = xl.Workbooks.Open(filepath)
wb.Close(True)