win32com

Writing array to Excel in Python with win32com

自古美人都是妖i 提交于 2019-12-12 07:16:43
问题 I'm making a Python script which parses data files. The parsed data is then sent to an Excel file. The data can be rather huge. I'm looking at 10 to 20 columns, but the number of rows can be well over 100.000. Writing this amount of data to Excel with win32com takes a considerable amount of time. My first step was to iterate over every cell in the Excel file, which is very time consuming. After some digging I found out how I can write a row with a single call, reducing the time needed

Sending Outlook mail to multiple distribution lists in Python

▼魔方 西西 提交于 2019-12-12 04:32:20
问题 I'm using Python and win32com.client to send Outlook mails to multiple distribution lists like so: olMailItem = 0x0 obj = win32com.client.Dispatch("Outlook.Application") newMail = obj.CreateItem(olMailItem) newMail.Subject = "This is subject" newMail.To = "abc@company.com" newMail.CC = "samplegrp1; samplegrp2" # offending statement //some html processing in mail content newMail.Send() The above code works as I'm able to send to a single group using: newMail.CC = "samplegrp1" but when I try to

Word : Deleting Lines in between a Table and a Heading using Python

你。 提交于 2019-12-12 03:56:10
问题 I have a scenario in which there is a Heading/Constant Text like "Call Tree:" present all over the Word document and after that there are some lines, and once the line are over, there is a Table . So I want the lines between the table and the Heading/Constant Text "Call Tree:" to be deleted using python/win32 component. For Example : Input is : ... Call Tree : Line 1 ... Line 2 ... .... .... .... .... Line N .... Table # 1 ..... Output is (i.e. all the lines in between the table and "Call

Python win32com.adsi module limits number of returned members from AD

落爺英雄遲暮 提交于 2019-12-12 03:47:25
问题 Using the following code... import win32com.adsi DNC=win32com.adsi.ADsGetObject('LDAP://rootDSE').Get('DefaultNamingContext') path = 'LDAP://cn=BIG_GROUP,ou=Groups,'+DNC groupobj = win32com.adsi.ADsGetObject(path) users = groupobj.member print len(users) The output is always a maximum 1500, even if BIG_GROUP contains several thousand members. How can I execute this query in a way that returns all members of BIG_GROUP? 回答1: AD returns N results at a time from a large attribute (like member),

EnsureDispatch error when using cx_freeze for making exe

烂漫一生 提交于 2019-12-12 02:05:25
问题 I am working with Python 3.4 on Windows 7. My setup file is as follows: from cx_Freeze import setup, Executable, sys exe=Executable( script="XYZ.py", base="Win32Gui", ) includefiles=[] includes=[] excludes=[] packages=[] setup( version = "1.0", description = "XYZ", author = "MAX", name = "AT", options = {'build_exe': {'excludes':excludes,'packages':packages,'include_files':includefiles}}, executables = [exe] ) from distutils.core import setup import py2exe, sys, os, difflib sys.argv.append(

Python: Autofill cells in Excel according to a formula in previous cells

扶醉桌前 提交于 2019-12-12 01:57:18
问题 Using Python and win32com: I have a formula in an Excel file, at cells A5:A54. I'm trying to fill the cells A55:A61 with values according to the same formula. I searched online and found this: http://pythonexcels.com/python-excel-mini-cookbook/ Quote from the link: "This script uses Excel’s autofill capability to examine data in cells A1 and A2, then autofill the remaining column of cells through A10." The code from the link: # # Autofill cell contents # import win32com.client as win32 excel

Python - Using win32com.client to format an Excell cell range as table

北城以北 提交于 2019-12-12 01:53:49
问题 I'm trying to write a function that selects all non empty cells in a worksheet, adjust column width to content, and format them as table. I am stuck on the last point, here's my current code: import win32com.client from win32com.client import constants f = r"D:\Project\test_copy.xlsx" exc = win32com.client.gencache.EnsureDispatch("Excel.Application") exc.Visible = 1 exc.Workbooks.Open(Filename=f) exc.ActiveSheet.UsedRange.Select() exc.Selection.Columns.AutoFit() exc.ActiveSheet.ListObjects(

How to refresh excel using python

最后都变了- 提交于 2019-12-11 15:18:10
问题 I need to evaluate a function within excel using python right after writing that function into excel with xlsx writer or openpyxl. I need to pull the number generated by this function back into python to use in a formula. I cannot calculate this number straight in python because it uses an excel function that was custom made to interact with another program. If I open the excel file after the function is written to a cell, the function evaluates. I've tried using win32com but does not seem to

provider cannot be found error in python connecting to SQL Server

前提是你 提交于 2019-12-11 13:44:58
问题 I'm attempting to connect to a SQL Server database within a Python script. I'm using SQLNCLI as provider on my connection string. from win32com.client import Dispatch connection_string = "Provider=SQLNCLI;server=%s;initial catalog=%s;user id=%s;password=%s"%(server,db_name,user,pwd) dbConn = Dispatch("ADODB.Connection") dbConn.Open( connection_string ) When executing the script I get this error: provider cannot be found. It may not be properly installed. Any ideas on how to fix this? 回答1:

win32com not importing from python file - DLL load failed

老子叫甜甜 提交于 2019-12-11 12:34:38
问题 I'm trying to import win32com.client module into python 2.7.10 which give me error Traceback (most recent call last): File "C:/Users/varma/Desktop/1.py", line 2, in <module> import win32api ImportError: DLL load failed: The specified module could not be found. But the same is working from Python Shell and terminal and not giving any error if i execute code import win32com.client Why running the code giving in python file giving me error and the same code is not giving any error if wrote on