导出excel所需操作
pip install xlwt 安装xlwt-1.2.0-py2.py3-none-any.whl
添加win32模块
cmd 命令下执行python3 registry.py
然后运行pywin32-218.win-amd64-py3.3.exe
下载链接:https://jaist.dl.sourceforge.net/project/pywin32/pywin32/Build%20218/pywin32-218.win-amd64-py3.3.exe
1、MSO.py
1)、开始-运行-cmd
2)、进入win32com\client
>cd D:\Program Files (x86)\Python33\Lib\site-packages\win32com\client
3)、执行makepy.py
D:\Program Files (x86)\Python33\Lib\site-packages\win32com\client>makepy.py
4)、在弹出窗口中选择"Microsoft Office 15.0 Object Library",确定:
Generating to D:\Program Files (x86)\Python33\Lib\site-packages\win32com\gen_py\91493440-5A91-11CF-8700-00AA0060263Bx0x2x9.py
Building definitions from type library...
Generating...
Importing module
5)、从命令行窗口中可以看到在文件夹gen_py中生成了一个.py文件,重命名为:MSO.py
2、MSPPT.py
重复上述步骤,
在第4步中选择“Microsoft PowerPoint 15.0 Object Library”,
重命名为:MSPPT.py
使用时进行导入
import win32com.gen_py.MSO as MSO
import win32com.gen_py.MSPPT as MSPPT
g = globals()
for c in dir(MSO.constants): g[c] = getattr(MSO.constants, c)
for c in dir(MSPPT.constants): g[c] = getattr(MSPPT.constants, c)
def ppt2jpg(path,dPath):
pythoncom.CoInitialize()
App = win32com.client.DispatchEx("PowerPoint.Application")
App.Visible = True
App.DisplayAlerts= False
Presentation = App.Presentations.Open(path)
Presentation.SaveAs(dPath,ppSaveAsJPG)
Presentation.Close()
App.Quit()
path指ppt文件,dPath指图片保存位置
Member name | Description |
---|---|
ppSaveAsPresentation | Save as a presentation. |
ppSaveAsPowerPoint7 | Reserved for internal use. |
ppSaveAsPowerPoint4 | Reserved for internal use. |
ppSaveAsPowerPoint3 | Reserved for internal use. |
ppSaveAsTemplate | Save as a template. |
ppSaveAsRTF | Save as an RTF. |
ppSaveAsShow | Save as a slide show. |
ppSaveAsAddIn | Save as an AddIn. |
ppSaveAsPowerPoint4FarEast | Reserved for internal use. |
ppSaveAsDefault | Save in the default format. |
ppSaveAsHTML | Save as an HTML document. |
ppSaveAsHTMLv3 | Save as HTMLv3. |
ppSaveAsHTMLDual | Save as HTML Dual version. |
ppSaveAsMetaFile | Save as a MetaFile. |
ppSaveAsGIF | Save as a GIF image. |
ppSaveAsJPG | Save as a JPG image. |
ppSaveAsPNG | Save as a PNG image. |
ppSaveAsBMP | Save as an BMP image. |
ppSaveAsWebArchive | Save as a Web archive. |
ppSaveAsTIF | Save as a TIF file. |
ppSaveAsPresForReview | Reserved for internal use. |
ppSaveAsEMF | Save in the Enhanced MetaFile (EMF) format. |
ppSaveAsOpenXMLPresentation | Save as an open XML presentation. |
ppSaveAsOpenXMLPresentationMacroEnabled | Save as a macro-enabled open XML presentation. |
ppSaveAsOpenXMLTemplate | Save as an open XML template. |
ppSaveAsOpenXMLTemplateMacroEnabled | Save as a macro-enabled open XML template. |
ppSaveAsOpenXMLShow | Save as an open XML show. |
ppSaveAsOpenXMLShowMacroEnabled | Save as a macro-enabled open XML show. |
ppSaveAsOpenXMLAddin | Save as an open XML add-in. |
ppSaveAsOpenXMLTheme | Save as an open XML theme. |
ppSaveAsPDF | Save as a PDF. |
ppSaveAsXPS | Save in the XML Paper Specification (XPS) format. |
ppSaveAsXMLPresentation | Save as an XML presentation. |
ppSaveAsOpenDocumentPresentation | Save as an open document presentation. |
ppSaveAsOpenXMLPicturePresentation | Save slideshow as an OpenXML Picture Presentation. |
ppSaveAsWMV | Save slideshow as a Windows Media Video (WMV) file. |
ppSaveAsExternalConverter | Save as External Converter. |