翻譯|使用教程|編輯:李顯亮|2020-09-03 10:52:24.547|閱讀 1420 次
概述:Aspose.Cells支持Microsoft Excel提供的所有打印選項,開發(fā)人員可以使用PageSetup 類提供的屬性輕松地為工作表配置這些選項。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Aspose.Cells for .NET是Excel電子表格編程API,可加快電子表格管理和處理任務(wù),支持構(gòu)建具有生成,修改,轉(zhuǎn)換,呈現(xiàn)和打印電子表格功能的跨平臺應(yīng)用程序。
在接下來的系列教程中,將為開發(fā)者帶來Aspose.Cells for .NET的一系列使用教程,例如關(guān)于加載保存轉(zhuǎn)換、字體、渲染、繪圖、智能標(biāo)記等等。本文重點(diǎn)介紹如何設(shè)置打印選項。
>>Aspose.Cells for .NET已經(jīng)更新至v20.8,支持Excel表格切片器,支持添加/刪除GridWeb的超鏈接,支持Aspose.Cells API的OTF字體類型以進(jìn)行渲染,支持將工作簿轉(zhuǎn)換為幻燈片為圖片的PPTX,發(fā)現(xiàn)15處異常情況,點(diǎn)擊下載體驗
Aspose.Cells支持Microsoft Excel提供的所有打印選項,開發(fā)人員可以使用PageSetup 類提供的屬性輕松地為工作表配置這些選項。下面將詳細(xì)討論如何使用這些屬性。
默認(rèn)情況下,打印區(qū)域合并了工作表中包含數(shù)據(jù)的所有區(qū)域。開發(fā)人員可以建立工作表的特定打印區(qū)域。若要選擇特定的打印區(qū)域,請使用PageSetup 類的PrintArea 屬性。將定義打印區(qū)域的單元格范圍分配給該屬性。
// The path to the documents directory. string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); // Instantiating a Workbook object Workbook workbook = new Workbook(); // Obtaining the reference of the PageSetup of the worksheet PageSetup pageSetup = workbook.Worksheets[0].PageSetup; // Specifying the cells range (from A1 cell to T35 cell) of the print area pageSetup.PrintArea = "A1:T35"; // Save the workbook. workbook.Save(dataDir + "SetPrintArea_out.xls");
Aspose.Cells允許您指定行標(biāo)題和列標(biāo)題以在打印的工作表的所有頁面上重復(fù)。為此,請使用PageSetup 類的PrintTitleColumns 和PrintTitleRows 屬性。
通過傳遞行或列號來定義將要重復(fù)的行或列。例如,行定義為$ 1:$ 2,列定義為$ A:$ B。
// The path to the documents directory. string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); // Instantiating a Workbook object Workbook workbook = new Workbook(); // Obtaining the reference of the PageSetup of the worksheet Aspose.Cells.PageSetup pageSetup = workbook.Worksheets[0].PageSetup; // Defining column numbers A & B as title columns pageSetup.PrintTitleColumns = "$A:$B"; // Defining row numbers 1 & 2 as title rows pageSetup.PrintTitleRows = "$1:$2"; // Save the workbook. workbook.Save(dataDir + "SetPrintTitle_out.xls");
該P(yáng)AGESETUP 類還提供了其他幾個屬性來設(shè)置一般打印選項如下:
為了設(shè)置PrintComments 和PrintErrors 屬性,Aspose.Cells還提供了兩個枚舉PrintCommentsType 和PrintErrorsType ,這些枚舉包含分別分配給PrintComments 和PrintErrors 屬性的預(yù)定義值。下面列出了PrintCommentsType枚舉中的預(yù)定義值及其說明。
Print Comments Types | Description |
---|---|
PrintInPlace | 指定打印工作表上顯示的注釋。 |
PrintNoComments | 指定不打印注釋。 |
PrintSheetEnd | 指定在工作表的末尾打印注釋。 |
下面列出了PrintErrorsType枚舉的預(yù)定義值及其說明。
Print Errors Types | Description |
---|---|
PrintErrorsBlank | 指定不打印錯誤。 |
PrintErrorsDash | 指定將錯誤打印為“ –”。 |
PrintErrorsDisplayed | 指定打印顯示的錯誤。 |
PrintErrorsNA | 指定將錯誤打印為“#N / A”。 |
// The path to the documents directory. string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); // Instantiating a Workbook object Workbook workbook = new Workbook(); // Obtaining the reference of the PageSetup of the worksheet PageSetup pageSetup = workbook.Worksheets[0].PageSetup; // Allowing to print gridlines pageSetup.PrintGridlines = true; // Allowing to print row/column headings pageSetup.PrintHeadings = true; // Allowing to print worksheet in black & white mode pageSetup.BlackAndWhite = true; // Allowing to print comments as displayed on worksheet pageSetup.PrintComments = PrintCommentsType.PrintInPlace; // Allowing to print worksheet with draft quality pageSetup.PrintDraft = true; // Allowing to print cell errors as N/A pageSetup.PrintErrors = PrintErrorsType.PrintErrorsNA; // Save the workbook. workbook.Save(dataDir + "OtherPrintOptions_out.xls");
該PAGESETUP 類提供的訂單 要打印所使用到工作表的順序多個頁面屬性。可以按照以下兩種方式訂購頁面。
Aspose.Cells提供了一個枚舉PrintOrderType ,該枚舉包含要分配給Go 屬性的所有預(yù)定義的訂單類型。下面列出了PrintOrderType枚舉的預(yù)定義值。
打印訂單類型 | 描述 |
---|---|
DownThenOver | 將打印順序表示為先降后高。 |
OverThenDown | 將打印順序表示為從上到下。 |
// The path to the documents directory. string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); // Instantiating a Workbook object Workbook workbook = new Workbook(); // Obtaining the reference of the PageSetup of the worksheet PageSetup pageSetup = workbook.Worksheets[0].PageSetup; // Setting the printing order of the pages to over then down pageSetup.Order = PrintOrderType.OverThenDown; // Save the workbook. workbook.Save(dataDir + "SetPageOrder_out.xls");
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn