设置边距
Contents
[
Hide
]
Aspose.Cells 完全支持 Microsoft Excel 的页面设置选项。开发人员可能需要为工作表配置页面设置以控制打印过程。本主题讨论如何使用 Aspose.Cells 配置页边距。
设置边距
Aspose.Cells提供了一个类,工作簿 , 表示一个 Excel 文件。这工作簿类包含工作表允许访问 Excel 文件中每个工作表的集合。工作表由工作表班级。
这工作表类提供了页面设置用于设置工作表页面设置选项的属性。这页面设置属性是一个对象页面设置使开发人员能够为打印的工作表设置不同页面布局选项的类。这页面设置类提供用于设置页面设置选项的各种属性和方法。
页边距
使用设置页边距(左、右、上、下)页面设置班级成员。下面列出了一些用于指定页边距的方法:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create a workbook object | |
Workbook workbook = new Workbook(); | |
// Get the worksheets in the workbook | |
WorksheetCollection worksheets = workbook.Worksheets; | |
// Get the first (default) worksheet | |
Worksheet worksheet = worksheets[0]; | |
// Get the pagesetup object | |
PageSetup pageSetup = worksheet.PageSetup; | |
// Set bottom,left,right and top page margins | |
pageSetup.BottomMargin = 2; | |
pageSetup.LeftMargin = 1; | |
pageSetup.RightMargin = 1; | |
pageSetup.TopMargin = 3; | |
// Save the Workbook. | |
workbook.Save(dataDir + "SetMargins_out.xls"); |
页面居中
可以在页面上水平和垂直居中某些内容。为此,有一些有用的成员页面设置班级,水平居中和垂直居中.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create a workbook object | |
Workbook workbook = new Workbook(); | |
// Get the worksheets in the workbook | |
WorksheetCollection worksheets = workbook.Worksheets; | |
// Get the first (default) worksheet | |
Worksheet worksheet = worksheets[0]; | |
// Get the pagesetup object | |
PageSetup pageSetup = worksheet.PageSetup; | |
// Specify Center on page Horizontally and Vertically | |
pageSetup.CenterHorizontally = true; | |
pageSetup.CenterVertically = true; | |
// Save the Workbook. | |
workbook.Save(dataDir + "CenterOnPage_out.xls"); |