3

我正在使用dotNET C#Excel 2003进行通信。我正在尝试更改文档的打印边距,但我输入的值与 Excel 然后使用的边距值不对应......

xls.PageSetup setup = ws.PageSetup;
setup.Orientation = xls.XlPageOrientation.xlLandscape;

//Standard margins (Top - Bottom - Left - Right):
//                  2.5 - 2.5 - 1.9 - 1.9


setup.BottomMargin = 1.0;
setup.TopMargin = 1.0;
setup.LeftMargin = 1.0;
setup.RightMargin = 1.0;
//Excel gives me: 0.0 - 0.0 - 0.0 - 0.0

setup.BottomMargin = 20.0;
setup.TopMargin = 20.0;
setup.LeftMargin = 20.0;
setup.RightMargin = 20.0;
//Now Excel gives me: 0.7 - 0.7 - 0.7 - 0.7

setup.BottomMargin = 30.0;
setup.TopMargin = 30.0;
setup.LeftMargin = 30.0;
setup.RightMargin = 30.0;
//Now Excel gives me: 1.1 - 1.1 - 1.1 - 1.1

正如你所看到的,Excel 确实改变了它的边距,但它与我输入的双精度不对应。我错过了一个因素吗?

非常感谢您的反馈!

4

1 回答 1

3

来自http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.pagesetup.rightmargin(v=office.11​​).aspx

边距以点为单位设置或返回。使用InchesToPoints方法或CentimetersToPoints方法从英寸或厘米转换测量值。

希望这可以帮助

于 2013-05-22T23:01:39.350 回答