Excel 2007 PageSetup.FitToPagesWide问题 [英] Excel 2007 PageSetup.FitToPagesWide issue
问题描述
因为当我一直在尝试使用C#在Excel 2007的Microsoft Visual Studio项目中设置页面缩放Excel页面
For while I have been trying to set the Page Scaling of Excel page in a Microsoft Visual Studio project for Excel 2007 using C#
代码看起来像这样
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;
}
PaperSise和Orientation的线条运行正常,但是我无法做出Excel将数据合并到一个页面上。
The lines for PaperSise and Orientation are working well, however I can't make Excel fit data onto one page.
我做错了什么?
MSDN 没有太多帮助,因为它们还没有代码示例
MSDN did not help much because they do not yet have a code sample for this language.
推荐答案
我应该清楚阅读我提到的页面中的备注部分。它指出:
I should have clearly read the Remarks section on the page I mentioned. It states:
如果缩放属性为True,则会忽略FitToPagesTall属性。
我的代码现在看起来像这样,像charm一样工作
And my code now looks like this, works like charm
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;
}
这篇关于Excel 2007 PageSetup.FitToPagesWide问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!