PNG JPG BMP TIFF TXT
Aspose.Cells  for .NET

搜尋 TXT C# 中的格式

使用伺服器端 Aspose.Cells for .NET API 進行本機高效能 TXT 文件搜索,無需使用 Microsoft 或 Adobe PDF 等任何軟體。

如何使用 C# 搜尋 TXT 文件

為了搜尋 TXT 文件,我們將使用

Aspose.Cells for .NET

API這是一個功能豐富、功能強大且易於使用的文件搜尋API for C#平台。打開

NuGet

套件管理器,搜尋 Aspose.Cells 並安裝。您也可以從套件管理器控制台使用以下命令。

命令


PM> Install-Package Aspose.Cells

搜尋 C# 中的 TXT 文件的步驟

基本文件搜尋

Aspose.Cells for .NET

只需幾行程式碼即可完成 API。

使用 Workbook 類別載入 TXT 檔案。 取得相關工作表中的儲存格。

  • 使用查找方法搜尋 Numbers、日期和文本

系統需求

我們的 API 在所有主要平台和作業系統上均受支援。在執行下面的程式碼之前,請確保您的系統符合以下先決條件。

  • Microsoft Windows 或具有 .NET Framework、.NET Core、Mono 或 Xamarin 平台的相容作業系統
  • 開發環境如Microsoft Visual Studio
  • 在專案中新增對 Aspose.Cells for .NET DLL 的引用 - 使用上面的下載按鈕從 NuGet 安裝
 

搜尋 TXT 文件 - C#

// searching cells containing specified string value or number
Workbook workbook = new Workbook("book1.txt");

// get cells collection
Cells cells = workbook.Worksheets[0].Cells;

FindOptions opts = new FindOptions();
opts.LookInType = LookInType.Values;
opts.LookAtType = LookAtType.EntireContent;

// find the cell with the input integer or double
Cell cell1 = cells.Find(205, null, opts);

if (cell1 != null){
    Console.WriteLine("Name of the cell containing the value: " + cell1.Name);
}else{
    Console.WriteLine("Record not found ");
}

// find the cell with the input string
Aspose.Cells.Cell cell2 = cells.Find("Items A", null, opts);

if (cell2 != null){
    Console.WriteLine("Name of the cell containing the value: " + cell2.Name);
}else{
    Console.WriteLine("Record not found ");
}

// find the cell containing with the input string
opts.LookAtType = LookAtType.Contains;
Cell cell3 = cells.Find("Data", null, opts);

if (cell3 != null){
    Console.WriteLine("Name of the cell containing the value: " + cell3.Name);
}else{
    Console.WriteLine("Record not found ");
}  
 
  • 關於 Aspose.Cells for .NET API

    Aspose.Cells API 可用於建立、編輯、轉換和渲染 Microsoft Excel 格式為不同的格式。此外,它還可用於軟體應用程式中的全面圖表、可擴展報告和可靠計算。 Aspose.Cells 是一個獨立的 API,它不需要任何像 Microsoft 或 OpenOffice 這樣的軟體。

    線上 TXT 搜尋現場演示

    立即造訪我們的 TXT 文件中搜尋文字、單字、片語 現場示範網站 。現場演示有以下好處

      無需下載Aspose API。
      無需編寫任何程式碼。
      只需上傳您的 TXT 文件即可。
      搜尋結果立即出現。

    TXT 什麼是 TXT 文件格式

    副檔名為 .TXT 的檔案表示包含行形式的純文字的文字文件。文字文件中的段落由回車符識別,用於更好地排列文件內容。標準文字文件可以在不同作業系統上的任何文字編輯器或文字處理應用程式中開啟。此類文件中包含的所有文字都是人類可讀的格式,並由字元序列表示。

    閱讀更多

    其他支援的搜尋格式

    使用C#,還可以搜尋其他格式,包括。

    CSV (逗號分隔值)
    ODS (OpenDocument 電子表格文件)
    TSV (製表符分隔值)
    XLS (Excel 二進位格式)
    XLSB (二進位 Excel 工作簿文件)
    XLSM (試算表文件)