如何:设置页边距

如何:指定打印设置

// Set page orientation to landscape.
worksheet.ActiveView.Orientation = PageOrientation.Landscape;
// Select paper size.
worksheet.ActiveView.PaperKind = System.Drawing.Printing.PaperKind.A4;
// Access an object that contains print options.
WorksheetPrintOptions printOptions = worksheet.PrintOptions;
// Do not print gridlines.
printOptions.PrintGridlines = false;
// Scale the worksheet to fit within the width of one page.
printOptions.FitToPage = true;
printOptions.FitToWidth = 1;
// Print in black and white.
printOptions.BlackAndWhite = true;
// Print a dash instead of a cell error message.
printOptions.ErrorsPrintMode = ErrorsPrintMode.Dash;

如何:定义打印区域

// Define a print area on a worksheet.
CellRange printArea = worksheet["B1:F39"];
worksheet.SetPrintRange(printArea);

// Enlarge the print area by adding adjacent cells.
// An additional print area is created if you add non-adjacent cells to the print area.
worksheet.AddPrintRange(worksheet["B40:F50"]);

// Uncomment the following line to clear the print area and print the entire worksheet.
// worksheet.ClearPrintRange();

如何:在工作表中插入分页符

// Insert a page break after the "F" column.
worksheet.VerticalPageBreaks.Add(6);
// Insert a page break below the 14th row.
worksheet.HorizontalPageBreaks.Add(14);

Use the Worksheet.ActiveView property to specify the following page options:

PropertyDescription
WorksheetView.Margins定义页边距
WorksheetView.Orientation指定页面方向。
WorksheetView.PaperKind指定纸张大小。
WorksheetView.SetCustomPaperSize指定工作表的自定义纸张大小。

Use the Worksheet.PrintOptions property to configure print options. Print options include the following:

PropertyDescription
WorksheetPrintOptions.FitToPage指示是否缩放工作表以使其数据适合指定页数。
WorksheetPrintOptions.FitToWidth指定工作表应水平容纳的页数。
WorksheetPrintOptions.FitToHeight指定工作表在垂直方向上应容纳的页数。
WorksheetPrintOptions.Scale指定缩放工作表内容的百分比。
WorksheetPrintOptions.PrintGridlines指定是否打印工作表网格线。
WorksheetPrintOptions.PrintHeadings指定是否打印行标题和列标题。
WorksheetPrintOptions.PrintTitles允许您在打印页面上重复特定的行和列。
WorksheetPrintOptions.BlackAndWhite允许您以黑白方式打印工作表。
WorksheetPrintOptions.PageOrder指定打印页面的顺序。
WorksheetPrintOptions.PageNumbering允许您指定第一页码。
WorksheetPrintOptions.CenterHorizontally指定是否在打印页面上水平居中数据。
WorksheetPrintOptions.CenterVertically指定是否在打印页面上垂直居中数据。
WorksheetPrintOptions.ErrorsPrintMode指定如何打印单元格错误。

如何:设置页边距

// Set the page orientation to Landscape.
workbook.Worksheets[0].ActiveView.Orientation = PageOrientation.Landscape;


自定义纸张尺寸

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值