仅在一页打印Excel工作表(A4) [英] Print an excel sheet in one only page (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屋!