翻譯|使用教程|編輯:李顯亮|2020-05-12 11:32:17.293|閱讀 791 次
概述:Aspose.Cells for .NET是Excel電子表格編程API,可加快電子表格管理和處理任務,支持構建具有生成,修改,轉換,呈現和打印電子表格功能的跨平臺應用程序。 本文重點介紹如何使用分頁預覽和頁面縮放功能。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Aspose.Cells for .NET是Excel電子表格編程API,可加快電子表格管理和處理任務,支持構建具有生成,修改,轉換,呈現和打印電子表格功能的跨平臺應用程序。
在接下來的系列教程中,將為開發者帶來Aspose.Cells for .NET的一系列使用教程,例如關于加載保存轉換、字體、渲染、繪圖、智能標記等等。本文重點介紹如何如何使用分頁預覽和頁面縮放功能。
>>Aspose.Cells for .NET已經更新至v20.4,支持多個單元作為范圍的并集,添加用于更新PowerQueryFormulaItems的源字段的選項,支持ODS的數據欄,色標和圖標集條件格式,修復諸多Bug,點擊下載體驗
普通視圖是工作表的默認視圖。分頁符預覽是一個編輯視圖,它顯示將要打印的工作表。分頁預覽顯示了每頁上將要顯示的數據,因此您可以調整打印區域和分頁符。使用Aspose.Cells開發人員可以啟用常規視圖或分頁預覽模式。
Aspose.Cells提供了一個代表Microsoft Excel文件的 Workbook類。該工作簿 類包含一個工作表 集合允許訪問每個工作表中的Excel文件。工作表由Worksheet 類表示。的工作表 類提供了一個寬范圍的性質和用于管理工作表的方法的。若要啟用普通或分頁預覽模式,請使用Worksheet 類IsPageBreakPreview 屬性。IsPageBreakPreview 是一個布爾屬性,這意味著它只能存儲true或 false值。
啟用普通視圖
通過將Worksheet類IsPageBreakPreview屬性設置為false,將工作表設置為普通視圖。
啟用分頁預覽
通過將Worksheet 類IsPageBreakPreview 屬性設置為true,可以將任何工作表設置為分頁預覽。這樣做會將工作表從普通視圖切換到分頁預覽。
下面提供了一個完整的示例,該示例演示如何使用IsPageBreakPreview 屬性為Excel文件的第一個工作表啟用分頁符預覽模式。通過創建Workbook類的實例來打開book1.xls文件。通過將IsPageBreakPreview 屬性設置為 true,可以將視圖切換到第一個工作表的分頁預覽。修改后的文件另存為output.xls。
// The path to the documents directory. string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); // Creating a file stream containing the Excel file to be opened FileStream fstream = new FileStream(dataDir + "book1.xls", FileMode.Open); // Instantiating a Workbook object // Opening the Excel file through the file stream Workbook workbook = new Workbook(fstream); // Accessing the first worksheet in the Excel file Worksheet worksheet = workbook.Worksheets[0]; // Displaying the worksheet in page break preview worksheet.IsPageBreakPreview = true; // Saving the modified Excel file workbook.Save(dataDir + "output.xls"); // Closing the file stream to free all resources fstream.Close();
Aspose.Cells提供了一個 代表Microsoft Excel文件的 Workbook類。該工作簿 類包含一個工作表 集合允許訪問每個工作表中的Excel文件。
工作表由Worksheet 類表示。的工作表 類提供了一個寬范圍的性質和用于管理工作表的方法的。要設置工作表的縮放系數,請使用Worksheet 類的Zoom 屬性。通過將數字(整數)值分配給Zoom屬性來設置縮放系數 。
下面提供了一個完整的示例,該示例演示如何使用 Zoom屬性設置Excel文件的第一個工作表的縮放系數。通過創建Workbook 類的實例來打開book1.xls文件 。第一個工作表的縮放系數設置為75,修改后的文件另存為output.xls。
// The path to the documents directory. string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); // Creating a file stream containing the Excel file to be opened FileStream fstream = new FileStream(dataDir + "book1.xls", FileMode.Open); // Instantiating a Workbook object // Opening the Excel file through the file stream Workbook workbook = new Workbook(fstream); // Accessing the first worksheet in the Excel file Worksheet worksheet = workbook.Worksheets[0]; // Setting the zoom factor of the worksheet to 75 worksheet.Zoom = 75; // Saving the modified Excel file workbook.Save(dataDir + "output.xls"); // Closing the file stream to free all resources fstream.Close();
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn