c# Excel打印页边距
本文关键字:页边距 打印 Excel | 更新日期: 2023-09-27 18:03:05
我想调整我用c#编写的程序生成的Excel文件的打印设置。我希望设置为:"页面适合(或适合)1页"。(荷兰语是Blad passend maken voor 1 pagina):p你可以在以下位置选择:截图
我知道边距是通过PageSetup
对象设置的,但我就是找不到怎么做。
请帮我一下:)
这可能有帮助?
osheet.PageSetup.PrintArea = "$A$5:$G$" & curLine + 1
osheet.PageSetup.PrintTitleColumns = "$A:$A"
osheet.PageSetup.PrintTitleRows = "$1:$4"
osheet.PageSetup.Orientation = XlPageOrientation.xlLandscape
osheet.PageSetup.CenterFooter = "SomeText"
obook.CustomViews.Add("Print Top Left", True, True)
您可以使用Office主互操作程序集来操作Excel设置
更具体地说,这个链接告诉你如何使用Excel Interop (Office PIA的一部分)操作页面设置
试试这个:
sheet.PageSetup.TopMargin = 1;
sheet.PageSetup.BottomMargin = 1;
sheet.PageSetup.LeftMargin = 1;
sheet.PageSetup.RightMargin = 1;