gpt4 book ai didi

C# Excel (2003) 互操作 - 边距与输入值不对应?

转载 作者:行者123 更新时间:2023-11-30 16:17:54 24 4
gpt4 key购买 nike

我正在使用 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 确实改变了它的边距,但它与我输入的双倍不对应。有没有我遗漏的因素?

非常感谢您的反馈!

最佳答案

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

Margins are set or returned in points. Use the InchesToPoints method or the CentimetersToPoints method to convert measurements from inches or centimeters.

希望对你有帮助

关于C# Excel (2003) 互操作 - 边距与输入值不对应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16686373/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com