如何在不使用 Microsoft Office 的情況下用 C# 開啟 Excel 文件
IronXL允許您在不安裝 Microsoft Office 的情況下,用 C# 開啟和讀取 Excel 檔案——只需安裝 NuGet 包,載入工作簿,即可存取任何工作表、儲存格或區域,並自動偵測輸入值和格式。
如果您曾經嘗試過在沒有 Microsoft Office 的情況下以程式設計方式開啟 Excel 文件,您就會知道傳統的互通方法有多麼棘手。 Interop 依賴 Excel 本身的安裝,需要複雜的 COM 引用,並且經常導致版本衝突——尤其是在 Office 不可用的伺服器或雲端環境中。
IronXL是一個現代化的 .NET 庫,可讓您直接讀取 XLSX、XLS、CSV 和 TSV 文件,無需任何 Office 依賴項。 您可以編寫簡潔可靠的 C# 程式碼,在 Windows、Linux 或雲端處理 Excel 文件,並避免 COM 自動化帶來的所有麻煩。 本指南詳細介紹了從安裝到生產就緒模式的開啟和讀取 Excel 工作簿的所有內容。
如何在.NET專案中安裝IronXL?
開始使用只需幾秒鐘。 打開您的專案並使用以下套件管理器之一:
Install-Package IronXL
dotnet add package IronXL
Install-Package IronXL
dotnet add package IronXL
或者,開啟 Visual Studio,右鍵點擊您的項目,選擇"管理 NuGet 套件",搜尋"IronXL",然後按一下"安裝"。 安裝指南涵蓋所有支援的環境,包括 Docker 和 Azure。
Visual Studio NuGet 套件管理器顯示 IronXL.Excel 套件(版本 2025.9.1)可供安裝
安裝完成後,在檔案頂部新增命名空間:
using IronXL;
using IronXL;
Imports IronXL
你只需要這一句話就夠了。 沒有複雜的 COM 引用,沒有 Office 依賴項,也沒有特定版本的組件。 如需免費評估金鑰,請造訪IronXL 試用授權頁面。
為什麼 IronXL 比傳統的互通性更容易?
傳統 Excel 互通性要求執行程式碼的每台機器上都必須安裝 Microsoft Office。 對於伺服器部署、AWS Lambda 函數和容器化應用程式來說,這是不切實際的。 IronXL 在內部處理所有 Excel 檔案解析,提供簡潔的 API,無需任何外部相依性即可運作。
使用 Interop 時,還需要仔細管理 COM 物件的生命週期以防止記憶體洩漏—每個 Application、Workbook 和 Worksheet 物件都必須明確釋放,否則 Excel 進程會在後台累積。 IronXL 使用標準的 .NET 垃圾回收機制,因此您無需考慮 COM 清理問題。
本函式庫支援 .NET Framework 4.6.2 及更高版本,以及 .NET 5、6、7、8 和 10。它無需修改即可在 Windows、macOS 和 Linux 上運行。 如果您的目標是跨平台場景,僅憑這一點,IronXL 就比僅適用於 Windows 的 Office Interop 更合適得多。
如何驗證安裝是否成功?
安裝完成後,透過載入任意 Excel 檔案並列印儲存格值來建立一個簡單的測試。 如果專案建置過程中沒有出現錯誤,且輸出結果與預期資料相符,則設定完成。 IronXL 文件包含一個快速入門部分,其中詳細介紹了此驗證步驟。
安裝過程中常見的錯誤是在將工作簿載入到生產環境之前忘記應用許可證金鑰。 在試用模式下,該庫會在生成的任何文件中添加一個小浮水印。 在應用程式啟動時設定 IronXL.License.LicenseKey,以便所有操作從一開始就在正確的許可證下運行。
如何開啟Excel工作簿並讀取儲存格值?
核心API非常簡單明了。 載入工作簿,選擇工作表,然後按位址或迭代存取儲存格。
using IronXL;
// Load any Excel file -- XLSX, XLS, CSV, or TSV
WorkBook workbook = WorkBook.Load("example.xlsx");
// Access the second worksheet (zero-indexed)
WorkSheet worksheet = workbook.WorkSheets[1];
// Read a specific cell value
decimal revenue = worksheet["E2"].DecimalValue;
Console.WriteLine($"Order Total: {revenue}");
// Iterate over a range of cells
foreach (var cell in worksheet["C2:C6"])
{
Console.WriteLine($"Product: {cell.Text}");
}
using IronXL;
// Load any Excel file -- XLSX, XLS, CSV, or TSV
WorkBook workbook = WorkBook.Load("example.xlsx");
// Access the second worksheet (zero-indexed)
WorkSheet worksheet = workbook.WorkSheets[1];
// Read a specific cell value
decimal revenue = worksheet["E2"].DecimalValue;
Console.WriteLine($"Order Total: {revenue}");
// Iterate over a range of cells
foreach (var cell in worksheet["C2:C6"])
{
Console.WriteLine($"Product: {cell.Text}");
}
Imports IronXL
' Load any Excel file -- XLSX, XLS, CSV, or TSV
Dim workbook As WorkBook = WorkBook.Load("example.xlsx")
' Access the second worksheet (zero-indexed)
Dim worksheet As WorkSheet = workbook.WorkSheets(1)
' Read a specific cell value
Dim revenue As Decimal = worksheet("E2").DecimalValue
Console.WriteLine($"Order Total: {revenue}")
' Iterate over a range of cells
For Each cell In worksheet("C2:C6")
Console.WriteLine($"Product: {cell.Text}")
Next
WorkBook.Load() 自動偵測檔案格式 -- 無需指定檔案是 XLS 還是 XLSX。 使用 workbook.GetWorkSheet("Sheet1") 依索引或名稱存取工作表。 每個單元格都公開類型屬性,例如 IntValue、DecimalValue、日期時間Value 和 Text。
有關開啟檔案的更多選項,請參閱開啟工作簿操作指南。
分割畫面顯示:左側是包含訂單資料的 Excel 電子表格,右側則是顯示擷取資料的 Visual Studio 偵錯控制台。
如何按名稱存取工作表?
使用工作表名稱比使用數位索引更易於維護,尤其是在其他人編輯工作簿時。 以下範例顯示如何按名稱尋找工作表並遍歷所有工作表:
using IronXL;
WorkBook workbook = WorkBook.Load("inventory.xlsx");
// Access worksheet by exact name
WorkSheet salesSheet = workbook.GetWorkSheet("Sales Data");
Console.WriteLine($"Sales sheet rows: {salesSheet.RowCount}");
// Iterate all worksheets in the workbook
foreach (WorkSheet sheet in workbook.WorkSheets)
{
if (sheet.Name.Contains("Inventory"))
{
Console.WriteLine($"Found inventory sheet: {sheet.Name}");
}
}
using IronXL;
WorkBook workbook = WorkBook.Load("inventory.xlsx");
// Access worksheet by exact name
WorkSheet salesSheet = workbook.GetWorkSheet("Sales Data");
Console.WriteLine($"Sales sheet rows: {salesSheet.RowCount}");
// Iterate all worksheets in the workbook
foreach (WorkSheet sheet in workbook.WorkSheets)
{
if (sheet.Name.Contains("Inventory"))
{
Console.WriteLine($"Found inventory sheet: {sheet.Name}");
}
}
Imports IronXL
Dim workbook As WorkBook = WorkBook.Load("inventory.xlsx")
' Access worksheet by exact name
Dim salesSheet As WorkSheet = workbook.GetWorkSheet("Sales Data")
Console.WriteLine($"Sales sheet rows: {salesSheet.RowCount}")
' Iterate all worksheets in the workbook
For Each sheet As WorkSheet In workbook.WorkSheets
If sheet.Name.Contains("Inventory") Then
Console.WriteLine($"Found inventory sheet: {sheet.Name}")
End If
Next
讀取 Excel 檔案指南解釋了其他工作表存取模式,包括使用具有動態產生工作表名稱的工作簿。
如何從Excel儲存格讀取不同類型的資料?
IronXL 為每種常見的 Excel 資料類型提供了類型化存取器。 您可以讀取字串、整數、小數、日期、布林值和公式結果,無需任何手動解析。
using IronXL;
WorkBook wb = WorkBook.Load(@"C:\Data\Inventory.xlsx");
WorkSheet ws = wb.GetWorkSheet("Products");
// Read different data types directly
細繩 productName = ws["A2"].StringValue;
int quantity = ws["B2"].IntValue;
decimal price = ws["C2"].DecimalValue;
日期時間 updated = ws["D2"].日期時間Value;
// Use aggregate functions on ranges for performance
decimal totalStock = ws["B2:B100"].Sum();
decimal maxPrice = ws["C2:C100"].Max();
Console.WriteLine($"Product: {productName}, Qty: {quantity}, Price: {price:C}");
Console.WriteLine($"Total stock units: {totalStock}, Highest price: {maxPrice:C}");
using IronXL;
WorkBook wb = WorkBook.Load(@"C:\Data\Inventory.xlsx");
WorkSheet ws = wb.GetWorkSheet("Products");
// Read different data types directly
細繩 productName = ws["A2"].StringValue;
int quantity = ws["B2"].IntValue;
decimal price = ws["C2"].DecimalValue;
日期時間 updated = ws["D2"].日期時間Value;
// Use aggregate functions on ranges for performance
decimal totalStock = ws["B2:B100"].Sum();
decimal maxPrice = ws["C2:C100"].Max();
Console.WriteLine($"Product: {productName}, Qty: {quantity}, Price: {price:C}");
Console.WriteLine($"Total stock units: {totalStock}, Highest price: {maxPrice:C}");
Imports IronXL
Dim wb As WorkBook = WorkBook.Load("C:\Data\Inventory.xlsx")
Dim ws As WorkSheet = wb.GetWorkSheet("Products")
' Read different data types directly
Dim productName As String = ws("A2").StringValue
Dim quantity As Integer = ws("B2").IntValue
Dim price As Decimal = ws("C2").DecimalValue
Dim updated As DateTime = ws("D2").DateTimeValue
' Use aggregate functions on ranges for performance
Dim totalStock As Decimal = ws("B2:B100").Sum()
Dim maxPrice As Decimal = ws("C2:C100").Max()
Console.WriteLine($"Product: {productName}, Qty: {quantity}, Price: {price:C}")
Console.WriteLine($"Total stock units: {totalStock}, Highest price: {maxPrice:C}")
下表總結了可用的類型化存取器:
| 訪問器 | 返回類型 | 注意事項 |
|---|---|---|
StringValue |
細繩 | 即使對於數值單元格,也始終傳回字串。 |
IntValue |
int | 截斷小數 |
DecimalValue |
decimal | 最適合用於財務數據 |
DoubleValue |
double | 對於科學計數法或浮點數值 |
日期時間Value |
日期時間 | 自動解析 Excel 序號 |
BoolValue |
布林值 | 讀取 TRUE/FALSE 單元格 |
Formula |
細繩 | 傳回公式文本,例如=SUM(A2:D2) |
有關讀取和寫入單元格資料的完整詳細信息,請參閱單元格格式指南和匯入資料操作指南。
! Excel 電子表格顯示了產品庫存數據,包含產品、數量、價格和上次更新時間等列,同時 Visual Studio 偵錯控制台顯示了使用 C# 以程式設計方式讀取的相同數據。
如何安全地處理空白儲存格或無效儲存格?
在實際的 Excel 檔案中,空白儲存格很常見。 在讀取類型化存取器之前,請使用 IsEmpty 屬性或檢查 Value 是否為 null:
using IronXL;
WorkBook workbook = WorkBook.Load("data.xlsx");
WorkSheet ws = workbook.DefaultWorkSheet;
// Check if a cell is empty before reading
if (!ws["A1"].IsEmpty)
{
Console.WriteLine(ws["A1"].StringValue);
}
// Provide a fallback value using a null-coalescing pattern
細繩 cellText = ws["A1"].StringValue ?? "Default Value";
// Iterate a range and skip empty cells
foreach (var cell in ws["A1:A20"])
{
if (!cell.IsEmpty)
{
Console.WriteLine(cell.Text);
}
}
using IronXL;
WorkBook workbook = WorkBook.Load("data.xlsx");
WorkSheet ws = workbook.DefaultWorkSheet;
// Check if a cell is empty before reading
if (!ws["A1"].IsEmpty)
{
Console.WriteLine(ws["A1"].StringValue);
}
// Provide a fallback value using a null-coalescing pattern
細繩 cellText = ws["A1"].StringValue ?? "Default Value";
// Iterate a range and skip empty cells
foreach (var cell in ws["A1:A20"])
{
if (!cell.IsEmpty)
{
Console.WriteLine(cell.Text);
}
}
Imports IronXL
Dim workbook As WorkBook = WorkBook.Load("data.xlsx")
Dim ws As WorkSheet = workbook.DefaultWorkSheet
' Check if a cell is empty before reading
If Not ws("A1").IsEmpty Then
Console.WriteLine(ws("A1").StringValue)
End If
' Provide a fallback value using a null-coalescing pattern
Dim cellText As String = If(ws("A1").StringValue, "Default Value")
' Iterate a range and skip empty cells
For Each cell In ws("A1:A20")
If Not cell.IsEmpty Then
Console.WriteLine(cell.Text)
End If
Next
讀取 Excel 文件文件涵蓋了處理稀疏資料的其他模式,包括如何偵測工作表中最後使用的行和列。
處理空單元格時還需要考慮真正的空白單元格和包含空字串的單元格之間的差異。 IsEmpty 僅當儲存格完全不包含任何值時才傳回 true,而 StringValue 對於空白儲存格和明確設定為 "" 的儲存格都傳回空字串。 如果您的資料中有格式為文字但顯示為空的儲存格,請同時檢查 IsEmpty 和 細繩.IsNullOrWhiteSpace(cell.StringValue) 以獲得最準確的結果。
如何建立一個可用於生產環境的 Excel 讀取器?
一個真正實用的 Excel 閱讀器需要具備文件驗證、錯誤處理、多工作表支援和可選的輸出產生功能。 以下範例在一個類別中演示了所有這些模式:
using IronXL;
using System.IO;
// Validate and load the file
static List<細繩> CheckLowStock(細繩 filePath)
{
var lowStockItems = new List<細繩>();
if (!File.Exists(filePath))
{
Console.WriteLine($"File not found: {filePath}");
return lowStockItems;
}
細繩 ext = Path.GetExtension(filePath).ToLower();
if (ext is not (".xlsx" or ".xls" or ".csv"))
{
Console.WriteLine($"Unsupported file type: {ext}");
return lowStockItems;
}
try
{
WorkBook workbook = WorkBook.Load(filePath);
foreach (WorkSheet sheet in workbook.WorkSheets)
{
Console.WriteLine($"Checking sheet: {sheet.Name}");
for (int row = 2; row <= sheet.RowCount; row++)
{
細繩 itemName = sheet[$"A{row}"].StringValue;
int stockLevel = sheet[$"B{row}"].IntValue;
if (stockLevel < 10 && !細繩.IsNullOrEmpty(itemName))
{
lowStockItems.Add($"{itemName} -- {stockLevel} units ({sheet.Name})");
}
}
}
}
catch (Exception ex)
{
Console.WriteLine($"Error reading Excel file: {ex.Message}");
}
return lowStockItems;
}
// Export results to a new workbook
static void ExportReport(List<細繩> items, 細繩 outputPath)
{
WorkBook report = WorkBook.Create();
WorkSheet sheet = report.CreateWorkSheet("Low Stock Report");
sheet["A1"].Value = "Item Description";
sheet["B1"].Value = "Source Sheet";
sheet["A1:B1"].Style.Font.Bold = true;
sheet["A1:B1"].Style.BackgroundColor = "#4472C4";
sheet["A1:B1"].Style.Font.Color = "#FFFFFF";
int rowIndex = 2;
foreach (細繩 item in items)
{
sheet[$"A{rowIndex}"].Value = item;
rowIndex++;
}
report.SaveAs(outputPath);
Console.WriteLine($"Report saved to: {outputPath}");
}
// Run
var lowStockItems = CheckLowStock("inventory.xlsx");
ExportReport(lowStockItems, "low-stock-report.xlsx");
using IronXL;
using System.IO;
// Validate and load the file
static List<細繩> CheckLowStock(細繩 filePath)
{
var lowStockItems = new List<細繩>();
if (!File.Exists(filePath))
{
Console.WriteLine($"File not found: {filePath}");
return lowStockItems;
}
細繩 ext = Path.GetExtension(filePath).ToLower();
if (ext is not (".xlsx" or ".xls" or ".csv"))
{
Console.WriteLine($"Unsupported file type: {ext}");
return lowStockItems;
}
try
{
WorkBook workbook = WorkBook.Load(filePath);
foreach (WorkSheet sheet in workbook.WorkSheets)
{
Console.WriteLine($"Checking sheet: {sheet.Name}");
for (int row = 2; row <= sheet.RowCount; row++)
{
細繩 itemName = sheet[$"A{row}"].StringValue;
int stockLevel = sheet[$"B{row}"].IntValue;
if (stockLevel < 10 && !細繩.IsNullOrEmpty(itemName))
{
lowStockItems.Add($"{itemName} -- {stockLevel} units ({sheet.Name})");
}
}
}
}
catch (Exception ex)
{
Console.WriteLine($"Error reading Excel file: {ex.Message}");
}
return lowStockItems;
}
// Export results to a new workbook
static void ExportReport(List<細繩> items, 細繩 outputPath)
{
WorkBook report = WorkBook.Create();
WorkSheet sheet = report.CreateWorkSheet("Low Stock Report");
sheet["A1"].Value = "Item Description";
sheet["B1"].Value = "Source Sheet";
sheet["A1:B1"].Style.Font.Bold = true;
sheet["A1:B1"].Style.BackgroundColor = "#4472C4";
sheet["A1:B1"].Style.Font.Color = "#FFFFFF";
int rowIndex = 2;
foreach (細繩 item in items)
{
sheet[$"A{rowIndex}"].Value = item;
rowIndex++;
}
report.SaveAs(outputPath);
Console.WriteLine($"Report saved to: {outputPath}");
}
// Run
var lowStockItems = CheckLowStock("inventory.xlsx");
ExportReport(lowStockItems, "low-stock-report.xlsx");
Imports IronXL
Imports System.IO
' Validate and load the file
Private Shared Function CheckLowStock(filePath As String) As List(Of String)
Dim lowStockItems As New List(Of String)()
If Not File.Exists(filePath) Then
Console.WriteLine($"File not found: {filePath}")
Return lowStockItems
End If
Dim ext As String = Path.GetExtension(filePath).ToLower()
If ext IsNot ".xlsx" AndAlso ext IsNot ".xls" AndAlso ext IsNot ".csv" Then
Console.WriteLine($"Unsupported file type: {ext}")
Return lowStockItems
End If
Try
Dim workbook As WorkBook = WorkBook.Load(filePath)
For Each sheet As WorkSheet In workbook.WorkSheets
Console.WriteLine($"Checking sheet: {sheet.Name}")
For row As Integer = 2 To sheet.RowCount
Dim itemName As String = sheet($"A{row}").StringValue
Dim stockLevel As Integer = sheet($"B{row}").IntValue
If stockLevel < 10 AndAlso Not String.IsNullOrEmpty(itemName) Then
lowStockItems.Add($"{itemName} -- {stockLevel} units ({sheet.Name})")
End If
Next
Next
Catch ex As Exception
Console.WriteLine($"Error reading Excel file: {ex.Message}")
End Try
Return lowStockItems
End Function
' Export results to a new workbook
Private Shared Sub ExportReport(items As List(Of String), outputPath As String)
Dim report As WorkBook = WorkBook.Create()
Dim sheet As WorkSheet = report.CreateWorkSheet("Low Stock Report")
sheet("A1").Value = "Item Description"
sheet("B1").Value = "Source Sheet"
sheet("A1:B1").Style.Font.Bold = True
sheet("A1:B1").Style.BackgroundColor = "#4472C4"
sheet("A1:B1").Style.Font.Color = "#FFFFFF"
Dim rowIndex As Integer = 2
For Each item As String In items
sheet($"A{rowIndex}").Value = item
rowIndex += 1
Next
report.SaveAs(outputPath)
Console.WriteLine($"Report saved to: {outputPath}")
End Sub
' Run
Dim lowStockItems As List(Of String) = CheckLowStock("inventory.xlsx")
ExportReport(lowStockItems, "low-stock-report.xlsx")
本範例使用頂級語句,涵蓋完整的工作流程:驗證檔案路徑和副檔名、載入工作簿、遍歷所有工作表、應用業務邏輯,並將結果寫入新檔案。有關寫入和儲存工作簿的更多信息,請參閱"寫入 Excel 文件"指南和"匯出 Excel 文件"指南。
請注意,ExportReport 方法會建立一個新的工作簿,而不是修改原始檔。將原始檔案和輸出檔案分開是良好的審計追蹤實踐,並且可以避免意外覆蓋其他進程所依賴的資料。 如果需要將資料追加到現有工作簿中,請使用 WorkBook.Load() 載入它,向對應的工作表新增行,然後呼叫 SaveAs() 到新路徑或就地覆寫。
如何有效率地處理大型Excel檔案?
對於包含數千行的文件,聚合函數比手動循環性能更好,因為它們在內部運行,而無需將每個單元格物化為單獨的物件:
using IronXL;
WorkBook workbook = WorkBook.Load("large-dataset.xlsx");
WorkSheet ws = workbook.DefaultWorkSheet;
// Fast: aggregate functions operate on the range directly
decimal total = ws["B2:B5000"].Sum();
decimal average = ws["B2:B5000"].Avg();
int count = ws["B2:B5000"].Count();
Console.WriteLine($"Total: {total:C}, Average: {average:C}, Rows: {count}");
// Export the worksheet to a DataSet for LINQ or database operations
var dataSet = workbook.ToDataSet();
Console.WriteLine($"DataSet tables: {dataSet.Tables.Count}");
using IronXL;
WorkBook workbook = WorkBook.Load("large-dataset.xlsx");
WorkSheet ws = workbook.DefaultWorkSheet;
// Fast: aggregate functions operate on the range directly
decimal total = ws["B2:B5000"].Sum();
decimal average = ws["B2:B5000"].Avg();
int count = ws["B2:B5000"].Count();
Console.WriteLine($"Total: {total:C}, Average: {average:C}, Rows: {count}");
// Export the worksheet to a DataSet for LINQ or database operations
var dataSet = workbook.ToDataSet();
Console.WriteLine($"DataSet tables: {dataSet.Tables.Count}");
Imports IronXL
Dim workbook As WorkBook = WorkBook.Load("large-dataset.xlsx")
Dim ws As WorkSheet = workbook.DefaultWorkSheet
' Fast: aggregate functions operate on the range directly
Dim total As Decimal = ws("B2:B5000").Sum()
Dim average As Decimal = ws("B2:B5000").Avg()
Dim count As Integer = ws("B2:B5000").Count()
Console.WriteLine($"Total: {total:C}, Average: {average:C}, Rows: {count}")
' Export the worksheet to a DataSet for LINQ or database operations
Dim dataSet = workbook.ToDataSet()
Console.WriteLine($"DataSet tables: {dataSet.Tables.Count}")
當您需要在多個工作表上執行 LINQ 查詢或將資料載入至關聯式資料庫時,轉換為 DataSet 尤其有效。 每個工作表都變成 DataTable 內部的一個 DataSet,這使得與現有的資料存取程式碼互動變得簡單。 請參閱Excel 轉資料集指南以了解完整詳情。
如何獲得許可證並部署到生產環境?
IronXL 是一個商業庫,提供免費試用版,允許在開發和測試期間使用全部功能。 對於生產環境部署,您需要有效的許可證金鑰。 有關許可證級別的詳細信息,包括開發者、團隊和企業選項,請參閱IronXL 許可頁面。
若要套用許可證金鑰,請在呼叫任何 IronXL 函數之前設定它:
IronXL.License.LicenseKey = "YOUR-LICENSE-KEY-HERE";
IronXL.License.LicenseKey = "YOUR-LICENSE-KEY-HERE";
Imports IronXL
IronXL.License.LicenseKey = "YOUR-LICENSE-KEY-HERE"
IronXL 功能概述總結了所有功能,從讀取和寫入檔案到建立圖表、應用條件格式以及使用命名範圍。 建立 Excel 檔案指南和合併儲存格操作方法對於編寫新的工作簿來說是很有用的起點。
對於 C# Excel 自動化的社群討論和問題, Microsoft QA 論壇和Stack Overflow都是很好的資源。 官方NuGet 套件頁面提供版本歷史記錄和下載統計資料。
在 C# 中開啟 Excel 檔案有哪些關鍵要點?
IronXL完全消除了對 Microsoft Office 的依賴,使得在伺服器、容器和雲端函數中處理 Excel 檔案成為可能。 這個 API 遵循一個簡單的模式:載入工作簿,按名稱或索引存取工作表,並使用類型化的存取器讀取儲存格。 聚合函數如 Sum()、Avg() 和 Max() 可以處理大型資料集,而無需手動迭代的開銷。
該程式庫支援 XLSX、XLS、CSV 和 TSV 格式,可在 .NET 10 和所有最新的 .NET 版本上運行,並且具有跨平台性。 錯誤處理很簡單,因為 IronXL 會拋出標準的 .NET 異常,您可以使用熟悉的 try/catch 模式捕獲這些異常 -- 無需解碼 COM 互通錯誤代碼。 若要了解所有可用選項,請從IronXL 文件主頁開始,或嘗試使用開放式工作簿操作指南進行逐步參考。
立即開始免費試用 IronXL,在您自己的專案中評估該庫,無需任何承諾。
!{--01001100010010010100001001010010010000010101001001011001010111110100011101000101010101 01000101111101010011010101000100000101010010010101000100010101000100010111110101011101001000110 1010101000100100001011111010100000101001001001111010001000101010101010000110101010100101010101011 10101010001010010010010010010000010100110001011111010000100100110001001111101000011010010111111010000110100101110--
常見問題解答
如何在 VB.NET 中開啟不需要 Microsoft Office 的 Excel 檔案?
您可以使用 IronXL 庫在 VB.NET 中開啟和讀取 Excel 檔案,而無需 Microsoft Office。IronXL 提供了一種簡單的方式來處理 Excel 檔案,無需 Microsoft Office 或複雜的 Interop 方法。
在 VB.NET 中使用 IronXL 進行 Excel 處理的好處是什麼?
IronXL 通過消除對 Microsoft Office 的需求以及避免複雜的 COM 參考,簡化了 VB.NET 中的 Excel 處理。它確保了不同環境(如伺服器和雲平台)中的兼容性,並有助於防止版本衝突。
可以使用 IronXL 處理 XLSX 和 XLS 檔案嗎?
可以,IronXL 支援處理 XLSX 和 XLS 檔案格式,允許您在 VB.NET 應用中開啟、讀取和操作這些 Excel 檔案。
使用 IronXL 是否需要安裝任何其他軟體?
不用,使用 IronXL 進行 VB.NET 中的 Excel 檔案處理不需要任何其他軟體。IronXL 是一個獨立的庫,直接整合到您的 VB.NET 專案中。
IronXL 能在雲端環境中使用嗎?
可以,IronXL 被設計為無縫運行於雲端環境,避免了傳統 Excel Interop 方法在伺服器或雲平台中常遇到的版本衝突問題。
IronXL 如何處理 Excel 檔案兼容性?
IronXL 通過支援多種 Excel 檔案格式如 XLSX 和 XLS 來確保兼容性,並提供強大的功能來操作和處理這些檔案,而無需依賴 Microsoft Office。
IronXL 與不同版本的 VB.NET 兼容嗎?
IronXL 與各版本的 VB.NET 兼容,這使其成為開發者在不同的 .NET 框架版本中使用的多功能解決方案。
使用傳統 Interop 方法處理 VB.NET 中的 Excel 時的常見挑戰是什麼?
傳統的 Interop 方法通常需要 Microsoft Office,涉及複雜的 COM 參考,並且在伺服器或雲端環境中特別容易發生版本衝突。IronXL 透過提供一種更可靠和簡單的方法來解決這些挑戰。
IronXL 可以用來操作 Excel 檔案,例如編輯或匯出資料嗎?
可以,IronXL 不僅提供讀取 Excel 文件的功能,還提供編輯和匯出資料的功能,使其成為 VB.NET 中 Excel 檔案操作的綜合工具。
在哪裡可以找到使用 IronXL 的 VB.NET 工作程式碼範例?
您可以在 IronXL 文檔和教程中找到使用 IronXL 的 VB.NET 工作程式碼範例,這些文檔和教程提供了處理不需要 Microsoft Office 的 Excel 檔案的逐步指導。


