我一直在尝试使用 C# 在 Excel 2007 的 Microsoft Visual Studio 项目中设置 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;
}
PaperSise 和 Orientation 的行运行良好,但我无法使 Excel 将数据适合一页。
难道我做错了什么 ?
MSDN http://msdn.microsoft.com/en-us/library/ms272408%28v=Office.11%29.aspx没有多大帮助,因为他们还没有这种语言的代码示例。
我应该清楚地阅读我提到的页面上的备注部分。它指出:
“如果 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;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)