企业办公人员如果经常需要对文档进行打印操作,可以试试小编带来的这款打印excel强制页面纵向.exe软件,这是一个很实用的打印辅助工具,能够帮助用户将各种不同类型和格式的文件生成为纵向的效果,从而让文件实现纵向打印,满足用户的打印需求,只需一键即可转换。
软件功能
主要为快速的将文件夹内的PPT、EXCEL、WORD生成对应的PDF。PS:印象中如不能转换好像需要安装有office,成品是写定了为纵向也可以改为横向或者不设置。

使用方法
打开Excel,//点击左上角的表格标志,点击打印,然后选择打印预览,//在打印预览里有个对页面横纵的设置,点击横向,//调整表格的大小,点击缩放比例,缩放调整到大小合适的比例,//接下来选择页面设置,点击页边距,居中方式点击水平和垂直,设置完成后整个表格就能居中了,然后就可以直接打印了。
代码说明
"""【程序功能】:将【目标文件夹】内所有的 ppt、excel、word 均生成一份对应的 PDF 文件【作者】:qzw,提供内部使用【目标文件夹】:默认为此程序目前所在的文件夹;若输入路径,则为该文件夹(只转换该层,不转换子文件夹下内容)【生成的pdf名称】:原始名称+.pdf"""import os, win32com.client, gc# Worddef word2Pdf(filePath, words):# 如果没有文件则提示后直接退出if(len(words)<1):print ("
【无 Word 文件】
")return# 开始转换print ("
【开始 Word -> PDF 转换】")try:print ("打开 Word 进程...")word = win32com.client.Dispatch("Word.Application")word.Visible = 0word.DisplayAlerts = Falsedoc = Nonefor i in range(len(words)):print(i)fileName = words[i] # 文件名称fromFile = os.path.join(filePath, fileName) # 文件地址toFileName = changeSufix2Pdf(fileName) # 生成的文件名称toFile = toFileJoin(filePath,toFileName) # 生成的文件地址print ("转换:"+fileName+"文件中...")# 某文件出错不影响其他文件打印try:doc = word.Documents.Open(fromFile)doc.SaveAs(toFile,17) # 生成的所有 PDF 都会在 PDF 文件夹中print ("转换到:"+toFileName+"完成")except Exception as e:print(e)# 关闭 Word 进程print ("所有 Word 文件已打印完毕")print ("结束 Word 进程...
")doc.Close()doc = Noneword.Quit()word = Noneexcept Exception as e:print(e)finally:gc.collect()# Exceldef excel2Pdf(filePath, excels):# 如果没有文件则提示后直接退出if(len(excels)<1):print ("
【无 Excel 文件】
")return# 开始转换print ("
【开始 Excel -> PDF 转换】")try:print ("打开 Excel 进程中...")excel = win32com.client.Dispatch("Excel.Application")excel.Visible = 0excel.DisplayAlerts = Falsewb = Nonews = Nonefor i in range(len(excels)):print(i)fileName = excels[i] # 文件名称fromFile = os.path.join(filePath, fileName) # 文件地址print ("转换:"+fileName+"文件中...")# 某文件出错不影响其他文件打印try:wb = excel.Workbooks.Open(fromFile)for j in range(wb.Worksheets.Count): # 工作表数量,一个工作簿可能有多张工作表toFileName = addWorksheetsOrder(fileName, j+1) # 生成的文件名称toFile = toFileJoin(filePath,toFileName) # 生成的文件地址ws = wb.Worksheets(j+1) # 若为[0]则打包后会提示越界ws.PageSetup.Orientation=2 # 设置页面方向,纵向=1,横向=2ws.ExportAsFixedFormat(0,toFile) # 每一张都需要打印print ("转换至:"+toFileName+"文件完成")except Exception as e:print(e)# 关闭 Excel 进程print ("所有 Excel 文件已打印完毕")print ("结束 Excel 进程中...
")ws = Nonewb.Close()wb = Noneexcel.Quit()excel = Noneexcept Exception as e:print(e)finally:gc.collect()# PPTdef ppt2Pdf(filePath, ppts):# 如果没有文件则提示后直接退出if(len(ppts)<1):print ("
【无 PPT 文件】
")return# 开始转换print ("
【开始 PPT -> PDF 转换】")try:print ("打开 PowerPoint 进程中...")
powerpoint = win32com.client.Dispatch("PowerPoint.Application")ppt = None# 某文件出错不影响其他文件打印for i in range(len(ppts)):print(i)fileName = ppts[i] # 文件名称fromFile = os.path.join(filePath, fileName) # 文件地址toFileName = changeSufix2Pdf(fileName) # 生成的文件名称toFile = toFileJoin(filePath,toFileName) # 生成的文件地址print ("转换:"+fileName+"文件中...")try:ppt = powerpoint.Presentations.Open(fromFile,WithWindow=False)if ppt.Slides.Count>0:ppt.SaveAs(toFile, 32) # 如果为空则会跳出提示框(暂时没有找到消除办法)print ("转换至:"+toFileName+"文件完成")else:print("(错误,发生意外:此文件为空,跳过此文件)")except Exception as e:print(e)# 关闭 PPT 进程print ("所有 PPT 文件已打印完毕")print ("结束 PowerPoint 进程中...
")ppt.Close()ppt = Nonepowerpoint.Quit()powerpoint = Noneexcept Exception as e:print(e)finally:gc.collect()# 修改后缀名def changeSufix2Pdf(file):return file[:file.rfind('.')]+".pdf"# 添加工作簿序号def addWorksheetsOrder(file, i):return file[:file.rfind('.')]+"_工作表"+str(i)+".pdf"# 转换地址def toFileJoin(filePath,file):return os.path.join(filePath,'pdf',file[:file.rfind('.')]+".pdf")# 开始程序print ("====================程序开始====================")print ("【程序功能】将目标路径下内所有的 ppt、excel、word 均生成一份对应的 PDF 文件,存在新生成的 pdf 文件夹中(需已经安装office,不包括子文件夹)")print ("注意:若某 PPT 和 Excel 文件为空,则会出错跳过此文件。若转换 PPT 时间过长,请查看是否有报错窗口等待确认,暂时无法彻底解决 PPT 的窗口问题。在关闭进程过程中,时间可能会较长,十秒左右,请耐心等待。")filePath = input ("输入目标路径:(若为当前路径:"+os.getcwd()+",请直接回车)
")# 目标路径,若没有输入路径则为当前路径if(filePath==""):filePath = os.getcwd()# 将目标文件夹所有文件归类,转换时只打开一个进程words = []ppts = []excels = []for fn in os.listdir(filePath):if fn.endswith(('.doc', 'docx')):words.append(fn)if fn.endswith(('.ppt', 'pptx')):ppts.append(fn)if fn.endswith(('.xls', 'xlsx')):excels.append(fn)# 调用方法print ("====================开始转换====================")# 新建 pdf 文件夹,所有生成的 PDF 文件都放在里面folder = filePath + '\pdf\'if not os.path.exists(folder):os.makedirs(folder)word2Pdf(filePath,words)excel2Pdf(filePath,excels)ppt2Pdf(filePath,ppts)print ("====================转换结束====================")print ("
====================程序结束====================")os.system("pause")
软件测评
软件能够对文档进行强制性的页面转换操作,适用于Excel、Word、PPT、PDF等多种格式的文件,让用户可以横向打印文件也能纵向打印文件,提升工作效率。好了,今天的打印excel强制页面纵向.exe分享就到这里了,想要下载更多软件就来
非凡软件站,快快收藏吧,更多精彩不容错过!