Aspose.Cells根据sheetName获取指定sheet
时间: 2023-08-07 18:02:32 浏览: 66
您可以使用 Aspose.Cells 提供的 Worksheets 集合中的索引或名称属性来获取指定的工作表。以下是根据工作表名称获取工作表的示例代码:
```
Workbook workbook = new Workbook("book1.xlsx");
Worksheet worksheet = workbook.Worksheets["Sheet1"]; // 根据名称获取工作表
```
或者,您可以使用以下示例代码根据索引获取工作表:
```
Workbook workbook = new Workbook("book1.xlsx");
Worksheet worksheet = workbook.Worksheets[0]; // 根据索引获取工作表
```
请注意,这些示例代码假定您已经加载了 Excel 文件。如果您还没有加载文件,请使用 Workbook 类的构造函数加载它。
相关问题
Aspose.Cells如何去掉Evaluation Warning sheet
Aspose.Cells 是一个强大的 Excel 文件处理 API,用于创建、读取、修改和转换 Excel 文件。当使用 Aspose.Cells 进行计算时,可能会出现 Evaluation Warning Sheet。这个 Sheet 是 Aspose.Cells 的一个特性,用于提醒用户使用的 API 是一个试用版本,它会在 Excel 文件中添加一个新的 Sheet,显示 Evaluation Warning 信息。
如果想要去掉 Evaluation Warning Sheet,可以使用 Aspose.Cells 提供的 License 类。License 类可以让用户使用 Aspose.Cells 的完整功能,而不会出现 Evaluation Warning Sheet。
以下是去掉 Evaluation Warning Sheet 的示例代码:
```java
// 创建 License 对象
com.aspose.cells.License license = new com.aspose.cells.License();
// 设置许可证文件路径
license.setLicense("Aspose.Cells.lic");
// 去掉 Evaluation Warning Sheet
com.aspose.cells.Workbook workbook = new com.aspose.cells.Workbook("input.xlsx");
workbook.getWorksheets().get("Evaluation Warning").setVisible(false);
workbook.save("output.xlsx");
```
在上述示例代码中,我们首先创建了一个 License 对象,并设置了许可证文件的路径。然后,我们使用 Workbook 类打开 Excel 文件,并将 Evaluation Warning Sheet 设置为不可见。最后,我们将修改后的 Excel 文件保存到一个新的文件中。
需要注意的是,为了去掉 Evaluation Warning Sheet,我们需要使用一个有效的 Aspose.Cells 许可证。如果没有许可证,可以在 Aspose 官网上申请一个试用许可证,试用期为 30 天。
aspose.cells sheet
Aspose.Cells is a .NET component that allows developers to create, modify, convert, and render Microsoft Excel spreadsheets without requiring Microsoft Office or Excel to be installed on the system.
Regarding sheets, Aspose.Cells provides a Sheet class that represents a worksheet in an Excel workbook. Developers can use this class to perform various operations on a worksheet, such as adding, deleting, or renaming sheets, hiding or showing sheets, setting sheet properties, and more.
Here's an example of creating a new sheet with Aspose.Cells:
```
// Instantiate a new workbook
Workbook workbook = new Workbook();
// Add a new sheet to the workbook
Worksheet worksheet = workbook.Worksheets.Add("My Sheet");
// Set some cell values on the sheet
worksheet.Cells["A1"].PutValue("Hello");
worksheet.Cells["B1"].PutValue("World");
// Save the workbook to a file
workbook.Save("MyWorkbook.xlsx");
```
In this example, we create a new workbook, add a new sheet named "My Sheet" to it, set some cell values on the sheet, and save the workbook to a file.
相关推荐
![jar](https://img-home.csdnimg.cn/images/20210720083455.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)