Aspose.Cells for .NET是Excel电子表格编程API,可加快电子表格管理和处理任务,支持构建具有生成,修改,转换,呈现和打印电子表格功能的跨平台应用程序。
>>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 openedFileStream fstream = new FileStream(dataDir + "book1.xls", FileMode.Open);// Instantiating a Workbook object// Opening the Excel file through the file streamWorkbook workbook = new Workbook(fstream);// Accessing the first worksheet in the Excel fileWorksheet worksheet = workbook.Worksheets[0];// Hiding the grid lines of the first worksheet of the Excel fileworksheet.IsGridlinesVisible = false;// Saving the modified Excel fileworkbook.Save(dataDir + "output.xls");// Closing the file stream to free all resourcesfstream.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 openedFileStream fstream = new FileStream(dataDir + "book1.xls", FileMode.Open);// Instantiating a Workbook object// Opening the Excel file through the file streamWorkbook workbook = new Workbook(fstream);// Accessing the first worksheet in the Excel fileWorksheet worksheet = workbook.Worksheets[0];// Hiding the headers of rows and columnsworksheet.IsRowColumnHeadersVisible = false;// Saving the modified Excel fileworkbook.Save(dataDir + "output.xls");// Closing the file stream to free all resourcesfstream.Close();
还想要更多吗可以点击阅读【2020 · Aspose最新资源整合】,查找需要的教程资源。如果您有任何疑问或需求,请随时加入Aspose技术交流群(),我们很高兴为您提供查询和咨询。
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!