如何使用VB.NET将XLS中的单张纸转换为PDF [英] How to convert single sheet in XLS to PDF using VB.NET

查看:96
本文介绍了如何使用VB.NET将XLS中的单张纸转换为PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有可以将xls转换为pdf的工作代码,但是,该代码可以转换整个工作簿,我真的只需要从工作簿中选择一张纸即可,但是我不知道该怎么做.

I have working code that will convert an xls to pdf, however, the code converts the whole workbook and I really just need to select a single sheet out of the workbook, but I can't figure out how to do it.

我当前使用的代码是:

Dim fileName As String = "filepath\filename"
Dim xlsApp = New Microsoft.Office.Interop.Excel.Application
xlsApp.ScreenUpdating = False
Dim xlsBook As Microsoft.Office.Interop.Excel.Workbook
Dim paramExportFormat As XlFixedFormatType = XlFixedFormatType.xlTypePDF
Dim paramExportQuality As XlFixedFormatQuality = XlFixedFormatQuality.xlQualityStandard
Dim paramOpenAfterPublish As Boolean = False
Dim paramIncludeDocProps As Boolean = True
Dim paramIgnorePrintAreas As Boolean = True
Dim paramFromPage As Object = Type.Missing
Dim paramToPage As Object = Type.Missing
xlsBook = xlsApp.Workbooks.Open(fileName & ".xls", UpdateLinks:=False, ReadOnly:=False)
xlsBook.ExportAsFixedFormat(paramExportFormat, fileName & ".pdf", paramExportQuality, paramIncludeDocProps, paramIgnorePrintAreas, paramFromPage, paramToPage, paramOpenAfterPublish)
xlsBook.Close(SaveChanges:=False)
xlsApp.Quit()

我需要在代码中的哪个位置指定工作簿中的工作表?请注意,我需要这样做,以便根据应用程序中提供的选项来更改工作表,尽管我认为这不会有所作为,但我想我会以任何一种方式提及它.

Where in the code do I need to specify the sheet in the workbook? Note that I will need to make it so that depending on an option fed into the app, the sheet will change, though I don't think that should make a difference, but I thought I'd mention it either way.

推荐答案

尝试使用

这篇关于如何使用VB.NET将XLS中的单张纸转换为PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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