当前位置: 首页>>代码示例>>Python>>正文


Python Dispatch.Visible方法代码示例

本文整理汇总了Python中win32com.client.Dispatch.Visible方法的典型用法代码示例。如果您正苦于以下问题:Python Dispatch.Visible方法的具体用法?Python Dispatch.Visible怎么用?Python Dispatch.Visible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在win32com.client.Dispatch的用法示例。


在下文中一共展示了Dispatch.Visible方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: excel_open

# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import Visible [as 别名]
def excel_open(file_name):
    try:
        excel = Dispatch('Excel.Application')
        excel.Visible = False #If we want to see it change
        data_sheet = excel.Workbooks.Open(file_name)
        #Activate Excel Parts
        workBook = excel.ActiveWorkbook
        activeSheet = excel.ActiveSheet
        sheets = workBook.Sheets
        return sheets, workBook
    except:
        print '(' + str(clock(0)) + ') ERROR: Failed to initalize workbook. Retrying...'
        try:
            excel_close(workBook)
        except:
            pass
        try:
            excel = Dispatch('Excel.Application')
            excel.Visible = False #If we want to see it change
            data_sheet = excel.Workbooks.Open(file_name)
            #Activate Excel Parts
            workBook = excel.ActiveWorkbook
            activeSheet = excel.ActiveSheet
            sheets = workBook.Sheets
            return sheets, workBook
        except:
            print '(' + str(clock(0)) + ') ERROR: Failed to initialize workbook on second try.'
            return False, False
开发者ID:green131,项目名称:2170Scouting,代码行数:30,代码来源:scouting.py

示例2: docFilter

# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import Visible [as 别名]
def docFilter(fileList):
    '''
        转换word为txt,提取信息后清除txt.
    '''
    error_file = []
    for f in fileList:
        # fileName = f.split('\\')[-1].split('.')[-2].decode('gbk')
        # filePath = ''.join(f.split('\\')[:-1]).decode('gbk')
        f = os.path.realpath(f)
        fileName = f.split('\\')[-1].split('.')[0]

        print fileName.decode('gbk') + '  start ..'
        print '-------------------------------------'
        word = Dispatch("Word.Application")
        # 后台静默运行
        word.Visible = 0
        word.DisplayAlerts = 0
        try:
            doc = word.Documents.Open(f,0,ReadOnly = 1)
            saveFileTxt = re.sub('.doc','.txt',f).decode('gbk')
            #保存为 txt 格式
            doc.SaveAs(u'%s' % saveFileTxt ,7)
            content = open(saveFileTxt,'r').read()
            #开始过滤
            pattern_result =  Filter(content)
        except Exception, E:
            print E
            error_file.append(f)
            continue
        finally:
开发者ID:cfhb,项目名称:script,代码行数:32,代码来源:trans_doc.py

示例3: save2xlsx

# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import Visible [as 别名]
def save2xlsx(fname, output_dump=None):
    """
    Do a simple : create empty xlsx, paste python list as content, save as given
    fname, close and quit MS Excel
    """

    from win32com.client import Dispatch
    if output_dump is None:
        output_dump = []
    xlapp = Dispatch("excel.application")
    xlapp.DisplayAlerts = False
    xlapp.Visible = True
    xlapp.ScreenUpdating = True

    # create a new spreadsheet
    xlbook = xlapp.Workbooks.Add()

    # use the first worksheet
    sht1 = xlbook.Sheets("Sheet1")
    # inserts all the accepted claims
    address = list2exceladdress(output_dump)
    pprint(address)
    ur1 = sht1.Range(address)
    ur1.Value = output_dump
    xlbook.SaveAs(fname)    # save the spreadsheet
    xlbook.Close()              # close the workbook
    xlapp.DisplayAlerts = True
    xlapp.Quit()                # quit Excel
开发者ID:boonkwee,项目名称:mypylib,代码行数:30,代码来源:mylib.py

示例4: convert

# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import Visible [as 别名]
    def convert(self):
        try:
            # initialize COM for multi-threading, ignoring any errors
            # when someone else has already initialized differently.
            pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED)
        except pythoncom.com_error:
            pass

        word = Dispatch("Word.Application")
        word.Visible = 0
        word.DisplayAlerts = 0
        doc = word.Documents.Open(self.fullname)
        # Let's set up some html saving options for this document
        doc.WebOptions.RelyOnCSS = 1
        doc.WebOptions.OptimizeForBrowser = 1
        doc.WebOptions.BrowserLevel = 0  # constants.wdBrowserLevelV4
        doc.WebOptions.OrganizeInFolder = 0
        doc.WebOptions.UseLongFileNames = 1
        doc.WebOptions.RelyOnVML = 0
        doc.WebOptions.AllowPNG = 1
        # And then save the document into HTML
        doc.SaveAs(FileName="%s.htm" % (self.fullname),
                   FileFormat=8)  # constants.wdFormatHTML)

        # TODO -- Extract Metadata (author, title, keywords) so we
        # can populate the dublin core
        # Converter will need to be extended to return a dict of
        # possible MD fields

        doc.Close()
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:32,代码来源:office_com.py

示例5: navigate

# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import Visible [as 别名]
	def navigate(self):
		self.v_result.id = self.task_id
		try:
			logger.debug("task_id=%3d, worker=%2d, visit=%s" % (self.task_id, self.worker_id, self.dest_host))
			start = int(time.time())
			ie = Dispatch('InternetExplorer.Application')    
			ie.Visible = 0
			ie.Navigate(self.dest_host)
			state = ie.ReadyState    			
			count = 0
			while 1:
				state = ie.ReadyState    
				if state == 4:   
					self.v_result.result = 'OK'
					self.v_result.code = 0
					break
				if count > self.timeout:
					self.v_result.result = 'Timeout'
					self.v_result.code = 1
					break
				time.sleep(1)
				count = count + 1
			end = int(time.time())
			self.v_result.consume_time = end - start
			state = None
			ie.Quit()
			ie = None
			del ie
		except Exception, e:
			exstr = traceback.format_exc() 
			print exstr
			self.v_result.result = 'Exception'
			self.code = 3
开发者ID:coolham,项目名称:pv_generator,代码行数:35,代码来源:run_pv_mp.py

示例6: __init__

# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import Visible [as 别名]
	def __init__(self,dc1,xlwb1,Hi,Me,Lo):
	
		
		
		self.High=Hi
		self.Medium=Me
		self.Low=Lo
		word = Dispatch('Word.Application')
		xlApp = Dispatch("Excel.Application")
		xlApp.Visible = True
		
	
		self.doc1 = dc1
		
		
		self.xlWb1 =xlwb1
		self.xlSht1 = self.xlWb1.WorkSheets(3)
		
		
		print "Please give path of second excel sheet"
		print "\n"
		self.xlWb2 =xlApp.Workbooks.Open(raw_input())
		
		self.xlSht2 = self.xlWb2.WorkSheets(3)
		print "Please give path and name to save file e.g C:\Users\inprsha\Desktop\hello.xlsx"
		print "\n"
		self.xlWb2.SaveAs(raw_input())
		print "enter row no in which u want to fill details"
		self.row_no=raw_input()
开发者ID:configOps,项目名称:python-Numpy-Win32com,代码行数:31,代码来源:excel2.py

示例7: toExcel

# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import Visible [as 别名]
 def toExcel(self):
     #Instantiate win32com client excel object and create common objects
     xl = Dispatch("Excel.Application")
     xl.Visible = True
     xl.Workbooks.Add()
     wb = xl.ActiveWorkbook
     shts = wb.Sheets
     
     #Check for file with current path and name, change it if need be, save it
     checker = CheckFilename(self.o_path, self.filename)
     filename = checker.checkName()
     wb.SaveAs(filename)
     
     shts("Sheet1").Delete
     shts("Sheet2").Delete
     shts("Sheet3").Delete
     
     keys = self.output.keys()
     
     for sheet in keys:
         xl.Worksheets.Add().Name = sheet
         sht = shts(sheet)
         r,c = 1,1
         export = self.output[sheet]
         for row in export:
             c = 1
             for cell in row:
                 sht.Cells(r,c).Value = cell
                 c+=1
             r+=1
         
     xl.ActiveWorkbook.Save()
开发者ID:psmyth1,项目名称:code-samples,代码行数:34,代码来源:ExportExcel.py

示例8: gen_excel

# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import Visible [as 别名]
 def gen_excel(self, rows):
     f =  os.getcwd() + "\\" + "tmp" + repr(rows) +'.xls'
     if os.path.exists(f):
         os.remove(f)
     shutil.copy("send.xls", f)
     
     rows += 1
     f_open = (f)
     xlsApp = Dispatch("Excel.Application")
     xlsApp.Visible = False
     xlsBook = xlsApp.Workbooks.Open(f_open)
     sheet_name = u'工资表模板'
     #print (sheet_name)
     writeSht = xlsBook.Worksheets(sheet_name)
     
     to_addr = self.readSht.Cells(rows, self.mailCol).Value
     print(to_addr)
     
     for j in range(1,23):
         if j == self.mailCol:
             continue
         writeSht.Cells(2,j + 1).Value = self.readSht.Cells(rows, j).Value
         #print (writeSht.Cells(6,j).Value)
     xlsBook.Close(SaveChanges=1)
     #xlsApp.Quit()
     return to_addr
开发者ID:balabalazhoucj,项目名称:AutoSendSalary,代码行数:28,代码来源:rt_parserxlsx.py

示例9: visit_job

# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import Visible [as 别名]
def visit_job(id, sleep = 0.001 ):  
    try:  
        #urllib.urlopen('http://192.168.1.242:8080/').read()  
		start = time.time()
		ie = Dispatch('InternetExplorer.Application')    
		ie.Visible = 0
		url = 'http://blog.sina.com.cn/zgrwzj'
		ie.Navigate(url)
		state = ie.ReadyState    			
		logger.debug("visit: %s", url)
		while 1:
			state = ie.ReadyState    
			if state ==4:   
				break
			time.sleep(1)
		state = None
		# end
		end = time.time()
		run_time = end - start
		t_str = " Elipse Time:%.2f s" % run_time
		if ret == True:
			r_str = "OK"
		else:
			r_str = "Failed"
		r_str = r_str + '\t' + t_str
		return r_str
    except Exception, e:  
        #print '[%4d]' % id, sys.exc_info()[:2]  
		exstr = traceback.format_exc() 
		logger.debug("test_job exception:%s", exstr)
		return "Exception"
开发者ID:coolham,项目名称:pv_generator,代码行数:33,代码来源:run_pv_mt.py

示例10: StartChemDraw

# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import Visible [as 别名]
def StartChemDraw(visible=True, openDoc=False, showDoc=False):
  """ launches chemdraw """
  global cdApp, theDoc, theObjs, selectItem, cleanItem, centerItem
  if cdApp is not None:
    # if called more than once, do a restart
    holder = None
    selectItem = None
    cleanItem = None
    centerItem = None
    theObjs = None
    theDoc = None
    cdApp = None

  cdApp = Dispatch('ChemDraw.Application')
  if openDoc:
    theDoc = cdApp.Documents.Add()
    theObjs = theDoc.Objects
  else:
    theDoc = None
  selectItem = cdApp.MenuBars(1).Menus(2).MenuItems(8)
  cleanItem = cdApp.MenuBars(1).Menus(5).MenuItems(6)
  if _cdxVersion == 6:
    centerItem = cdApp.MenuBars(1).Menus(4).MenuItems(1)
  else:
    centerItem = cdApp.MenuBars(1).Menus(4).MenuItems(7)
  if visible:
    cdApp.Visible = 1
    if theDoc and showDoc:
      theDoc.Activate()
开发者ID:connorcoley,项目名称:rdkit,代码行数:31,代码来源:chemdraw.py

示例11: __init__

# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import Visible [as 别名]
	def __init__(self, path,docfile,xml):
		self.path = path
		word = Dispatch('Word.Application')
		word.Visible=False
		self.xml=xml
		# self.doc1=word.Documents.Open(os.path.join(os.getcwd(), 'MARS.doc'))
		self.doc1=word.Documents.Open(docfile)
开发者ID:configOps,项目名称:python-Numpy-Win32com,代码行数:9,代码来源:nessus.py

示例12: get_table_box

# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import Visible [as 别名]
    def get_table_box(self, targetSheet, startRow, endRow, startCol, endCol):
        
        """
        startRow, Starts at 1, not 0!
        endRow, Inclusive
        startCol, Starts at 1
        endCol Inclusive
        """
        logging.debug("Loading table on {}".format(targetSheet))
        raise
        # Attach the excel COM object

        xl = Dispatch('Excel.Application')

        # Open the project file
        book = xl.Workbooks.Open(self.excelPath)

        # Select the sheet
        sheet = book.Sheets(targetSheet)

        xl.Visible = False

        rows = list()
        for row in range(startRow,endRow+1):
            rows.append(list())
            for col in range(startCol, endCol+1):
                thisVal = sheet.Cells(row,col).Value
                rows[-1].append(thisVal)

        book.Close(SaveChanges=0) #to avoid prompt

        return rows
开发者ID:MarcusJones,项目名称:ExergyUtilities,代码行数:34,代码来源:util_excel_api.py

示例13: __init__

# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import Visible [as 别名]
	def __init__(self,path,docfile):
		word = Dispatch('Word.Application')
		word.Visible=True
		self.path=path
		self.doc = word.Documents.Open(os.path.join(os.getcwd(), self.path))
		self.doc1=word.Documents.Open(docfile)
		# self.doc1=word.Documents.Open(os.path.join(os.getcwd(), 'MARS.doc'))
		self.doc1.Save()
开发者ID:configOps,项目名称:python-Numpy-Win32com,代码行数:10,代码来源:robust.py

示例14: start_main

# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import Visible [as 别名]
def start_main():
    from sys import argv
    filePathName = NBA_POWER_RANKING_CSV_FILE

    from win32com.client import Dispatch
    xl = Dispatch('Excel.Application')
    wb = xl.Workbooks.Open(filePathName)
    xl.Visible = True # optional: if you want to see the spreadsheet
开发者ID:lau-gary10,项目名称:nbaPowerRanking,代码行数:10,代码来源:open_excel_instance.py

示例15: get_rows

# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import Visible [as 别名]
    def get_rows(self, targetSheet, startRow=1, endRow = 1000, startCol=1,endCol = 100):
        """
        Return cols until first blank
        """
        #logging.debug("Loading project from {0}".format(self.excelPath))

        # Attach the excel COM object

        xl = Dispatch('Excel.Application')

        # Open the project file
        book = xl.Workbooks.Open(self.excelPath)

        # Select the sheet
        sheet = book.Sheets(targetSheet)

        xl.Visible = False

        rows = list()

        if not endRow:
            runUntilRow = 1000
        else:
            runUntilRow = endRow

        if not endCol:
            runUntilCol = 100
        else:
            runUntilCol = endCol

        checks = 0

        for row in range(startRow,runUntilRow+1):
            col = 1

            #?? What is this?
            if not endRow and not sheet.Cells(row,col).Value:
                break

            # Only return non-empty rows!
            if sheet.Cells(row,col).Value is None:
                pass
            else:
                rows.append(list())

            for col in range(startCol, runUntilCol+1):
                checks += 1
                thisVal = sheet.Cells(row,col).Value
                #print checks, thisVal
                if thisVal is not None:
                    rows[-1].append(thisVal)

        book.Close(SaveChanges=0) #to avoid prompt

        logging.debug("Checked {} cells".format(checks))
        logging.debug("Returning {} rows".format(len(rows)))

        return rows
开发者ID:MarcusJones,项目名称:ExergyUtilities,代码行数:60,代码来源:util_excel_api.py


注:本文中的win32com.client.Dispatch.Visible方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。