翻譯|使用教程|編輯:李顯亮|2020-07-28 10:28:08.630|閱讀 1246 次
概述:Aspose.Cells提供了一個Workbook類,提供了PAGESETUP用于設置工作表的頁面設置選項屬性。所述PAGESETUP 屬性是的目的PAGESETUP類,使開發一種用于印刷工作表設置不同的頁面布局選項。該PAGESETUP類提供用于設置頁面設置選項的各種屬性和方法。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Aspose.Cells for .NET是Excel電子表格編程API,可加快電子表格管理和處理任務,支持構建具有生成,修改,轉換,呈現和打印電子表格功能的跨平臺應用程序。
在接下來的系列教程中,將為開發者帶來Aspose.Cells for .NET的一系列使用教程,例如關于加載保存轉換、字體、渲染、繪圖、智能標記等等。本文重點介紹如何設置頁面邊距。
>>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 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");
可以在頁面上水平和垂直居中放置某些內容。為此,PageSetup 類有一些有用的成員CenterHorizontally 和CenterVertically。
// 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");
使用PageSetup 類成員(例如HeaderMargin 和FooterMargin)設置頁眉和頁腳頁邊距。
// 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 Header / Footer margins pageSetup.HeaderMargin = 2; pageSetup.FooterMargin = 2; // Save the Workbook. workbook.Save(dataDir + "CenterOnPage_out.xls");
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn