我试图将excel文件导出为pdf但是对齐正在进行中?

问题描述 投票:1回答:3

导出纸张时,对齐关闭。下半行有一半的数据。如何以编程方式对齐工作表并将其转换为pdf而不进行对齐。

我需要适合页面的东西。

vb.net excel formatting automation export-to-pdf
3个回答
0
投票

PDF的宽度取决于您的Excel打印设置,默认情况下,它将设置为A4纵向,因此导出PDF将把半数据留给下一行;如果将纸张尺寸设置为A3横向,然后导出为PDF,则会显示正确的格式。


0
投票

我遇到过同样的问题,所以我做了什么:

  1. 对于excel文件表,我设置以下内容 xlWorkbook = xlApps.Workbooks.Add(missing); xlWorkSheet = (Excel.Worksheet)xlWorkbook.Worksheets.get_Item(1); xlApps.ActiveWindow.View = Excel.XlWindowView.xlPageLayoutView; //pagelayout view xlWorkSheet.PageSetup.PaperSize = Excel.XlPaperSize.xlPaperA4; //set paper to A4 xlWorkSheet.PageSetup.Orientation = Excel.XlPageOrientation.xlPortrait; //set to portrait //margins 'Narrow' xlWorkSheet.PageSetup.LeftMargin = 0.65; //55 xlWorkSheet.PageSetup.RightMargin = 0.25; xlWorkSheet.PageSetup.BottomMargin = 0.75; xlWorkSheet.PageSetup.TopMargin = 0.75; //60 xlWorkSheet.PageSetup.HeaderMargin = 0;
  2. 转换我的excel文件并缩放大小。 (只需更改120以适合您的文档) //here is the scaling Worksheet xlmsheet = excelWorkBook.Sheets[1]; xlmsheet.PageSetup.Zoom = 120; // Save it in the target format. if (excelWorkBook != null) excelWorkBook.ExportAsFixedFormat(XlFixedFormatType.xlTypePDF, paramExportFilePath, XlFixedFormatQuality.xlQualityStandard, true, true, Type.Missing, Type.Missing, false, paramMissing);

0
投票

为什么不使用FitToPagesWide和FitToPagesTall

    xlWorkSheet.PageSetup.Zoom = False
    xlWorkSheet.PageSetup.FitToPagesWide = 1
    xlWorkSheet.PageSetup.FitToPagesTall = 1
© www.soinside.com 2019 - 2024. All rights reserved.