[英]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。
在設置FitToPagesWide
和FitToPagesTall
之前,您需要將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.