繁体   English   中英

为什么设置要打印的页面的宽度和高度不能应用?

[英]Why does setting the width and height of pages to print not get applied?

我有这个代码来设置各种打印选项:

private void ConfigureByCustomerForPrinting()
{
    _xlSheet.PageSetup.PrintArea = "A1:" + 
        GetExcelTextColumnName(
            _xlSheet.UsedRange.Columns.Count) + 
            _xlSheet.UsedRange.Rows.Count;
    _xlSheet.PageSetup.Orientation = Excel.XlPageOrientation.xlLandscape;
    _xlSheet.PageSetup.FitToPagesWide = 1;
    _xlSheet.PageSetup.FitToPagesTall = 100;
    _xlSheet.PageSetup.Zoom = false;

    _xlSheet.PageSetup.LeftMargin = _xlApp.Application.InchesToPoints(0.5);
    _xlSheet.PageSetup.RightMargin = _xlApp.Application.InchesToPoints(0.5);
    _xlSheet.PageSetup.TopMargin = _xlApp.Application.InchesToPoints(0.5);
    _xlSheet.PageSetup.BottomMargin = _xlApp.Application.InchesToPoints(0.5);
    _xlSheet.PageSetup.HeaderMargin = _xlApp.Application.InchesToPoints(0.5);
    _xlSheet.PageSetup.FooterMargin = _xlApp.Application.InchesToPoints(0.5);
}

生成工作表时,它会考虑横向方向值,但如下所示:

在此输入图像描述

...虽然宽度(宽)和高度(高)分别设置为1和100,但不是所选的单选按钮。 而是设置并选择“调整到 - %正常大小”。 为什么? 我认为这可能很好,但用户希望它设置为1和100。

在设置FitToPagesWideFitToPagesTall之前,您需要将Zoom属性设置为false

_xlSheet.PageSetup.Zoom = false;
_xlSheet.PageSetup.FitToPagesWide = 1;
_xlSheet.PageSetup.FitToPagesTall = 100;

来自MSDN:

如果Zoom属性为True,则忽略FitToPagesWide属性。

如果Zoom属性为True,则忽略FitToPagesTall属性。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM