代码之家  ›  专栏  ›  技术社区  ›  adopilot

Excel 2007 PageSetup.fittopageswide问题

  •  11
  • adopilot  · 技术社区  · 15 年前

    一直以来,我都在尝试使用c设置microsoftvisualstudioprojectforexcel2007中excel页面的缩放比例。#

    代码如下所示

    private void Sheet1_Startup(object sender, System.EventArgs e)
    {
        PageSetup.FitToPagesWide = 1;  
        PageSetup.FitToPagesTall = 1;
        PageSetup.Orientation = Microsoft.Office.Interop.Excel.XlPageOrientation.xlLandscape;
        PageSetup.PaperSize = Microsoft.Office.Interop.Excel.XlPaperSize.xlPaperA4;
    }
    

    纸张和方向行工作得很好,但是我不能让excel把数据放在一个页面上。

    我做错什么了吗?

    MSDN 没有太大帮助,因为他们还没有这种语言的代码示例。

    1 回复  |  直到 11 年前
        1
  •  21
  •   nanobar    11 年前

    我应该清楚地阅读我提到的那页上的评论部分。它指出:

    如果zoom属性为true,fittopagestall属性将被忽略。

    我的代码现在看起来像这样,很有魅力

    private void Sheet1_Startup(object sender, System.EventArgs e)
    {
        PageSetup.Zoom = false;
        PageSetup.FitToPagesWide = 1;
        PageSetup.FitToPagesTall = 1;
        PageSetup.Orientation = Microsoft.Office.Interop.Excel.XlPageOrientation.xlLandscape;
        PageSetup.PaperSize = Microsoft.Office.Interop.Excel.XlPaperSize.xlPaperA4;         
    }