仅在一页打印Excel工作表(A4) [英] Print an excel sheet in one only page (A4)

查看:75
本文介绍了仅在一页打印Excel工作表(A4)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码将xls,xlsx文件转换为pdf


它工作得很好....


但是我一直在寻找一种方法来做同样的事情,但是将xls表中的内容放在pdf文件的一个唯一页面中。


这似乎应该是解决方案,但我不知道hoy要结合 使用代码:


.Zoom = False

.FitToPagesTall = 1

.FitToPagesWide = 1   


< pre class ="prettyprint"> $ path =" c:\ utilidades"

$ xlFixedFormat =" Microsoft.Office.Interop.Excel.xlFixedFormatType" -as [type]

$ filter = Get-ChildItem -Path $ path -include * .xlsx -recurse

$ objExcel = New-Object -ComObject excel.application

$ objExcel.visible = $ false

foreach($ filter in $ filter)

{

$ filepath = ($ wb.FullName -replace'.xlsx?$','。pdf')

$ workbook = $ objExcel.workbooks.open($ wb.fullname,3)

$ workbook.Saved = $ true

" saving $ filepath"

$ workbook.ExportAsFixedFormat($ xlFixedFormat :: xlTypePDF,$ filepath)

$ objExcel.Workbooks.close()

}

$ objExcel.Quit()




谢谢提前。

解决方案

这可能有所帮助:


https://social.msdn.microsoft.com/论坛/办公/ EN-US / abd9b628-4ba2-4f0b-aab7-e5caf1602a83 / PowerShell的商店整个工作簿,作为一种PDF文件?论坛= exceldev


I have this code to convert a xls, xlsx file to a pdf

It Works fine....

But i have been looking for a way to do the same but putting aln the content in the xls sheet in one unique page on the pdf file.

It seems that this should be the solution, but i dont know hoy to combine  with the code im using:

.Zoom = False
.FitToPagesTall = 1
.FitToPagesWide = 1   

$path = "c:\utilidades"

$xlFixedFormat = "Microsoft.Office.Interop.Excel.xlFixedFormatType" -as [type] 

$filter = Get-ChildItem -Path $path -include *.xlsx -recurse 

$objExcel = New-Object -ComObject excel.application 

$objExcel.visible = $false 

foreach($wb in $filter) 

{ 

$filepath = ($wb.FullName -replace '.xlsx?$', '.pdf')

$workbook = $objExcel.workbooks.open($wb.fullname, 3) 

$workbook.Saved = $true 

"saving $filepath" 

$workbook.ExportAsFixedFormat($xlFixedFormat::xlTypePDF, $filepath) 

$objExcel.Workbooks.close() 

} 

$objExcel.Quit()


thanks in advance.

解决方案

This might help:

https://social.msdn.microsoft.com/Forums/office/en-US/abd9b628-4ba2-4f0b-aab7-e5caf1602a83/powershell-store-entire-workbook-as-a-pdf-file?forum=exceldev


这篇关于仅在一页打印Excel工作表(A4)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆