翻譯|使用教程|編輯:李顯亮|2020-07-15 11:28:02.593|閱讀 521 次
概述:默認情況下,所有Excel工作表都有網格線。它們有助于描繪單元格,以便輕松將數據輸入特定單元格。Aspose.Cells提供了一個Workbook類允許開發人員訪問每個工作表中的Excel文件,本文將介紹如何顯示和隱藏網格線和行列標題。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Aspose.Cells for .NET是Excel電子表格編程API,可加快電子表格管理和處理任務,支持構建具有生成,修改,轉換,呈現和打印電子表格功能的跨平臺應用程序。
在接下來的系列教程中,將為開發者帶來Aspose.Cells for .NET的一系列使用教程,例如關于加載保存轉換、字體、渲染、繪圖、智能標記等等。本文重點介紹如何顯示和隱藏行列和滾動條。
>>Aspose.Cells for .NET已經更新至v20.6,加載圖片/形狀的性能提升,支持在GridWeb中存儲會話信息的臨時文件,發現5處異常情況,點擊下載體驗
默認情況下,所有Excel工作表都有網格線。它們有助于描繪單元格,以便輕松將數據輸入特定單元格。網格線使我們能夠將工作表視為單元格的集合,其中每個單元格都易于識別。
Aspose.Cells提供了一個Workbook類,它允許開發人員訪問每個工作表中的Excel文件。為了控制網格線的可見性,使用的工作表 類IsGridlinesVisible 。IsGridlinesVisible 是布爾值屬性,這意味著它只能存儲true或false 值。
通過將Worksheet 類IsGridlinesVisible 屬性設置為true,使網格線可見。通過將Worksheet 類IsGridlinesVisible 屬性設置為false來隱藏網格線。
下面給出一個完整的示例,該示例 通過打開excel文件(book1.xls),隱藏第一個工作表上的網格線并將修改后的文件另存為output.xls來演示IsGridlinesVisible屬性 的使用。
// 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]; // Hiding the grid lines of the first worksheet of the Excel file worksheet.IsGridlinesVisible = false; // Saving the modified Excel file workbook.Save(dataDir + "output.xls"); // Closing the file stream to free all resources fstream.Close();
Excel文件中的所有工作表均由按行和列排列的單元格組成。所有行和列都有唯一的值,這些值用于標識它們和標識單個單元格。例如,行編號為– 1、2、3、4,等等–列的字母順序為– A,B,C,D等。行和列的值顯示在標題中。使用Aspose.Cells,開發人員可以控制這些行和列標題的可見性。
Aspose.Cells提供了一個Workbook類,它允許開發人員訪問每個工作表中的Excel文件。
通過將Worksheet 類IsRowColumnHeadersVisible 屬性設置為true,使行和列標題可見。通過將Worksheet 類IsRowColumnHeadersVisible 屬性設置為false來隱藏行標題和列標題。
下面給出一個完整的示例,該示例演示如何 通過打開excel文件(book1.xls), 隱藏第一個工作表上的行標題和列標題并將修改后的文件另存為output.xls來使用 IsRowColumnHeadersVisible屬性。
// 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]; // Hiding the headers of rows and columns worksheet.IsRowColumnHeadersVisible = false; // Saving the modified Excel file workbook.Save(dataDir + "output.xls"); // Closing the file stream to free all resources fstream.Close();
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn