繁体   English   中英

使用 Excel Interop VB.Net 在 Excel 中设置边距

[英]Set Margins In Excel Using Excel Interop VB.Net

任何人都有使用 excel interop 和 vb.net 设置边距(上、左、右、下)的代码。 我认为它必须是工作表对象的一部分,但可能是工作簿对象。 很难找到一个例子。 提前致谢。

我发现它是工作表对象的一部分......

IE

xlWorkSheet.PageSetup.TopMargin=0.5

边距是通过从WorkSheet.PageSetup属性获得的PageSetup对象设置的。

保证金值必须以点数提及。 使用 InchesToPoints(Double) 或 CentimetersToPoints(Double) 指定值。

Eg: 

Microsoft.Office.Interop.Excel.Application _ExcelAppl = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook _ExcelWorkBook = oXL.Workbooks.Add(missing);
Microsoft.Office.Interop.Excel.Worksheet _ExcelWorkSheet = oWB.ActiveSheet as Microsoft.Office.Interop.Excel.Worksheet;
_ExcelWorkSheet.PageSetup.TopMargin = _ExcelAppl.InchesToPoints(0.25);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM