我想打印网络共享(M:驱动器)上的剩余空间量(以 GB 为单位),然后获取该值并将其添加到 Excel 电子表格中。我对编程很陌生,需要我能得到的所有帮助!
提前致谢
编辑:
这是我到目前为止所管理的。
import ctypes
from win32com.client import Dispatch
import pythoncom
def drivespace():
#get space in bytes
free_bytes = ctypes.c_ulonglong(0)
ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(u'M:\\'), None, None ctypes.pointer(free_bytes))
#calculate space in GB
free_GB = free_bytes.value/1024/1024/1024
print(free_GB)
#input data to Excel
xl = Dispatch ('Excel.Application')
xl.visible = 0
xl.Workbooks.Add (r'C:\Location\Location1\Location2\Book1.xlsm')
xl.Run('Down1') #macro inside the workbook, just to move the cell down 1 row
#here is where I need some help... something to input the data to the active cell
#xl.Cells( ?? ACTIVE CELL HERE BUT DON'T KNOW HOW ?? ).value=(free_GB)
xl.Quit()
#release held Excel process
pythoncom.CoUninitialize()
所以基本上,除了将数据实际打印到活动单元格之外,我已经对所有内容进行了排序。有没有人有任何 pywin32 知识可以帮助我做到这一点?
非常感谢!