解析 C# 中的 ODS 格式
使用服务器端 Aspose.Cells for .NET API 进行本机和高性能 ODS 文档解析,无需使用任何软件(如 Microsoft 或 Adobe PDF)。
如何使用 C# 解析 ODS 文件
为了解析 ODS 文件,我们将使用 Aspose.Cells for .NET API 是一款功能丰富、功能强大且易于使用的文档操作 API,适用于 C# 平台。打开 NuGet 包管理器,搜索Aspose.Cells并安装。您也可以从程序包管理器控制台使用以下命令。
命令
PM> Install-Package Aspose.Cells
解析 C# 中的 ODS 文件的步骤
一个基本的文档解析 Aspose.Cells for .NET 只需几行代码即可完成 API。解析 Microsoft Excel XLS、XLSX、XLSM、XLSB 和 OpenDocument ODS 文件中的文本和图像。
加载ODS文档。
- 选择工作表。
- 获取图片和图像类型。
- 保存图像。
- 保存文档
系统要求
我们的 API 在所有主流平台和操作系统上均受支持。在执行以下代码之前,请确保您的系统满足以下先决条件。
- Microsoft Windows 或与 .NET Framework、.NET Core、Mono 或 Xamarin 平台兼容的操作系统
- 开发环境如 Microsoft Visual Studio
- 在您的项目中添加对 Aspose.Cells for .NET DLL 的引用 - 使用上面的下载按钮从 NuGet 安装
解析 ODS 文件 - C#
// extract images from Worksheets
// open a template Excel file
Workbook workbook = new Workbook("sampleExtractImagesFromWorksheets.ods");
// get the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
// get the first Picture in the first worksheet
Aspose.Cells.Drawing.Picture pic = worksheet.Pictures[0];
// set the output image file path
string picformat = pic.ImageType.ToString();
// Note: you may evaluate the image format before specifying the image path
// define ImageOrPrintOptions
Aspose.Cells.Rendering.ImageOrPrintOptions printoption = new Aspose.Cells.Rendering.ImageOrPrintOptions();
// specify the image format
printoption.ImageType = Aspose.Cells.Drawing.ImageType.Jpeg;
// save the image
pic.ToImage("outputExtractImagesFromWorksheets.jpg", printoption);
关于 Aspose.Cells for .NET API
Aspose.Cells API 可用于创建、编辑、转换和呈现 Microsoft Excel 格式为不同格式。此外,它还可用于在软件应用程序中进行全面的图表绘制、可扩展的报告和可靠的计算。Aspose.Cells 是一个独立的 API,它不需要任何软件,如 Microsoft 或 OpenOffice。在线 ODS 解析器现场演示
立即访问我们的 现场演示网站 现场演示有以下好处
ODS 什么是ODS文件格式
扩展名为 ODS 的文件代表用户可编辑的开放文档电子表格文档格式。数据以行和列的形式存储在 ODF 文件中。它是一种基于 XML 的格式,是开放文档格式 (ODF) 系列中的几种子类型之一。该格式是 OASIS 发布和维护的 ODF 1.2 规范的一部分。Windows 以及其他操作系统上的许多应用程序都可以打开 ODS 文件进行编辑和操作,包括 Microsoft Excel、NeoOffice 和 LibreOffice。ODS 文件也可以通过不同的应用程序转换为其他电子表格格式,如 XLS、XLSX 和其他格式。
阅读更多