我如何“按表"将Excel工作簿保存或导出为PDF文件? [英] How do I "sheetwise" save or export an Excel workbook as a PDF file?

查看:289
本文介绍了我如何“按表"将Excel工作簿保存或导出为PDF文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码存在的问题是它要么保存工作簿中所有工作表中的所有页面,要么仅保存"from"和"to"参数指定的范围内的页面.

The problem with the code I have is that either it saves all the pages in all the worksheets in the workbook or it saves only the pages in the range specified by the "from" and "to" arguments.

我正在使用的excel文件有7个工作表,每个工作表可以有任意数量的页面.例如,如果我指定要导出从1到4",则仅将第一个工作表的前4页导出为PDF文档,而不是将前4个工作表的所有页导出.

The excel files I am working with have 7 worksheets, and each worksheet can have any amount of pages. If I specify that I want to export "from 1 to 4", for example, then only the first 4 pages of the first worksheet would be exported as a PDF document, not all the pages of the first 4 worksheets.

有人可以告诉我如何实现我的目标吗?下面的代码不是我想要的:

Can someone tell me how to achieve what I'm trying to do? The code below is not what I want:

application.ActiveWorkbook.ExportAsFixedFormat(
      Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF,
      path,
      Excel.XlFixedFormatQuality.xlQualityStandard,
      true,
      true,
      1,
      4,
      false,
      Missing.Value);

推荐答案

答案是:ActiveSheet.PageSetup.Pages.Count

Here's the answer: ActiveSheet.PageSetup.Pages.Count

这篇关于我如何“按表"将Excel工作簿保存或导出为PDF文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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