Aspose.Cells提供了一个Workbook类,提供了PAGESETUP用于设置工作表的页面设置选项属性。所述PAGESETUP 属性是的目的PAGESETUP类,使开发一种用于印刷工作表设置不同的页面布局选项。该PAGESETUP类提供用于设置页面设置选项的各种属性和方法。
Aspose.Cells for .NET是Excel电子表格编程API,可加快电子表格管理和处理任务,支持构建具有生成,修改,转换,呈现和打印电子表格功能的跨平台应用程序。
>>Aspose.Cells for .NET已经更新至v20.7,添加FilterString()条件支持,支持对所有PivotField进行循环,提升Worksheet.Cells.RemoveDuplicates工作性能,发现4处异常情况,体验
第八章:关于页面功能设置
▲第一节:设置边距
页边距
使用PageSetup 类成员设置页边距(左,右,上,下)。下面列出了一些用于指定页边距的方法:
// The path to the documents directory.string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);// Create a workbook objectWorkbook workbook = new Workbook();// Get the worksheets in the workbookWorksheetCollection worksheets = workbook.Worksheets;// Get the first (default) worksheetWorksheet worksheet = worksheets[0];// Get the pagesetup objectPageSetup pageSetup = worksheet.PageSetup;// Set bottom,left,right and top page marginspageSetup.BottomMargin = 2;pageSetup.LeftMargin = 1;pageSetup.RightMargin = 1;pageSetup.TopMargin = 3;// Save the Workbook.workbook.Save(dataDir + "SetMargins_out.xls");
页面中心
可以在页面上水平和垂直居中放置某些内容。为此,PageSetup 类有一些有用的成员CenterHorizontally 和CenterVertically。
// The path to the documents directory.string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);// Create a workbook objectWorkbook workbook = new Workbook();// Get the worksheets in the workbookWorksheetCollection worksheets = workbook.Worksheets;// Get the first (default) worksheetWorksheet worksheet = worksheets[0];// Get the pagesetup objectPageSetup pageSetup = worksheet.PageSetup;// Specify Center on page Horizontally and VerticallypageSetup.CenterHorizontally = true;pageSetup.CenterVertically = true;// Save the Workbook.workbook.Save(dataDir + "CenterOnPage_out.xls");
页眉和页脚边距
使用PageSetup 类成员(例如HeaderMargin 和FooterMargin)设置页眉和页脚页边距。
// The path to the documents directory.string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);// Create a workbook objectWorkbook workbook = new Workbook();// Get the worksheets in the workbookWorksheetCollection worksheets = workbook.Worksheets;// Get the first (default) worksheetWorksheet worksheet = worksheets[0];// Get the pagesetup objectPageSetup pageSetup = worksheet.PageSetup;// Specify Header / Footer marginspageSetup.HeaderMargin = 2;pageSetup.FooterMargin = 2;// Save the Workbook.workbook.Save(dataDir + "CenterOnPage_out.xls");
还想要更多吗可以点击阅读【2020 · Aspose最新资源整合】,查找需要的教程资源。如果您有任何疑问或需求,请随时加入Aspose技术交流群(),我们很高兴为您提供查询和咨询。
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!