导出纸张时,对齐关闭。 下半行有一半的数据。 如何以编程方式对齐工作表并将其转换为pdf而不进行对齐。
我需要适合页面的东西。
答案 0 :(得分:0)
PDF的宽度取决于您的Excel打印设置,默认情况下,它将设置为A4纵向,因此导出PDF会将半数据留给下一行;如果将纸张尺寸设置为A3横向,然后导出为PDF,则会显示正确的格式。
答案 1 :(得分:0)
我遇到了同样的问题,所以我做了什么:
对于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;
转换我的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);
答案 2 :(得分:0)
为什么不使用FitToPagesWide和FitToPagesTall
xlWorkSheet.PageSetup.Zoom = False
xlWorkSheet.PageSetup.FitToPagesWide = 1
xlWorkSheet.PageSetup.FitToPagesTall = 1