C# Excel Öğretici: IronXL Kütüphanesini Kullanmayı Öğrenin (Interop Yok)

A Guide to Reading and Writing Excel Files in C

This article was translated from English: Does it need improvement?
Translated
View the article in English

C# ve diğer .NET dillerinde Excel (XLS, XLSX ve CSV) dosyalarını okumak ve oluşturmak, Iron Software tarafından sağlanan IronXL yazılım kütüphanesi ile kolaydır.

IronXL'nun sunucunuzda Excel Interop'un kurulu olmasını gerektirmez. IronXL, Microsoft.Office.Interop.Excel'den daha hızlı ve sezgisel bir API sağlar.

IronXL, aşağıdaki platformlarda çalışır:

  • Windows ve Azure için .NET Framework 4.6.2 ve üstü
  • Windows, Linux, MacOS ve Azure için .NET Core 2 ve üstü
  • .NET 5, .NET 6, .NET 7, .NET 8, Mono, Maui ve Xamarin

IronXL Yükle

Firstly install IronXL, using our NuGet package or by downloading the DLL. IronXL classes can be found in the IronXL namespace.

IronXL'i kurmanın en kolay yolu, Visual Studio için NuGet Paket Yöneticisi'ni kullanmaktır: Paket adı IronXl.Excel.

Install-Package IronXL.Excel

https://www.nuget.org/packages/ironxl.excel/

Bir Excel Belgesi Okuma

IronXL ile, bir Excel dosyasından veri çıkarmak sadece birkaç satır kodda yapılabilir.

:path=/static-assets/excel/content-code-examples/get-started/get-started-1.cs
using IronXL;

// Supported spreadsheet formats for reading include: XLSX, XLS, CSV and TSV
WorkBook workBook = WorkBook.Load("data.xlsx");
WorkSheet workSheet = workBook.WorkSheets.First();

// Select cells easily in Excel notation and return the calculated value, date, text or formula
int cellValue = workSheet["A2"].IntValue;

// Read from Ranges of cells elegantly.
foreach (var cell in workSheet["A2:B10"])
{
    Console.WriteLine("Cell {0} has value '{1}'", cell.AddressString, cell.Text);
}
Imports IronXL

' Supported spreadsheet formats for reading include: XLSX, XLS, CSV and TSV
Private workBook As WorkBook = WorkBook.Load("data.xlsx")
Private workSheet As WorkSheet = workBook.WorkSheets.First()

' Select cells easily in Excel notation and return the calculated value, date, text or formula
Private cellValue As Integer = workSheet("A2").IntValue

' Read from Ranges of cells elegantly.
For Each cell In workSheet("A2:B10")
	Console.WriteLine("Cell {0} has value '{1}'", cell.AddressString, cell.Text)
Next cell
$vbLabelText   $csharpLabel

Yeni Excel Belgeleri Oluşturma

IronXL, C# veya VB.NET kullanarak hızlı ve kolay bir Excel belge oluşturma arayüzü sunar.

:path=/static-assets/excel/content-code-examples/get-started/get-started-2.cs
using IronXL;

// Create new Excel WorkBook document.
WorkBook workBook = WorkBook.Create(ExcelFileFormat.XLSX);
workBook.Metadata.Author = "IronXL";

// Add a blank WorkSheet
WorkSheet workSheet = workBook.CreateWorkSheet("main_sheet");

// Add data and styles to the new worksheet
workSheet["A1"].Value = "Hello World";
workSheet["A2"].Style.BottomBorder.SetColor("#ff6600");
workSheet["A2"].Style.BottomBorder.Type = IronXL.Styles.BorderType.Double;

// Save the excel file
workBook.SaveAs("NewExcelFile.xlsx");
Imports IronXL

' Create new Excel WorkBook document.
Private workBook As WorkBook = WorkBook.Create(ExcelFileFormat.XLSX)
workBook.Metadata.Author = "IronXL"

' Add a blank WorkSheet
Dim workSheet As WorkSheet = workBook.CreateWorkSheet("main_sheet")

' Add data and styles to the new worksheet
workSheet("A1").Value = "Hello World"
workSheet("A2").Style.BottomBorder.SetColor("#ff6600")
workSheet("A2").Style.BottomBorder.Type = IronXL.Styles.BorderType.Double

' Save the excel file
workBook.SaveAs("NewExcelFile.xlsx")
$vbLabelText   $csharpLabel

CSV, XLS, XLSX, JSON veya XML olarak Dışa Aktarma

IronXL ayrıca verilerinizi popüler yapısal hesap tablosu formatlarına kaydetmenize veya dışa aktarmanıza olanak tanır.

:path=/static-assets/excel/content-code-examples/get-started/get-started-3.cs
// Export to many formats with fluent saving
workSheet.SaveAs("NewExcelFile.xls");
workSheet.SaveAs("NewExcelFile.xlsx");
workSheet.SaveAsCsv("NewExcelFile.csv");
workSheet.SaveAsJson("NewExcelFile.json");
workSheet.SaveAsXml("NewExcelFile.xml");
' Export to many formats with fluent saving
workSheet.SaveAs("NewExcelFile.xls")
workSheet.SaveAs("NewExcelFile.xlsx")
workSheet.SaveAsCsv("NewExcelFile.csv")
workSheet.SaveAsJson("NewExcelFile.json")
workSheet.SaveAsXml("NewExcelFile.xml")
$vbLabelText   $csharpLabel

Hücreleri ve Aralıkları Stilleme

Excel hücrelerine ve aralıklarına biçimlendirme uygulayabilirsiniz IronXl.Range.Style nesnesini kullanarak.

:path=/static-assets/excel/content-code-examples/get-started/get-started-4.cs
// Set cell's value and styles
workSheet["A1"].Value = "Hello World";
workSheet["A2"].Style.BottomBorder.SetColor("#ff6600");
workSheet["A2"].Style.BottomBorder.Type = IronXL.Styles.BorderType.Double;
' Set cell's value and styles
workSheet("A1").Value = "Hello World"
workSheet("A2").Style.BottomBorder.SetColor("#ff6600")
workSheet("A2").Style.BottomBorder.Type = IronXL.Styles.BorderType.Double
$vbLabelText   $csharpLabel

Aralıkları Sıralama

IronXL ile, Aralık nesnesini kullanarak Excel hücrelerinin bir aralığını kolayca sıralayabilirsiniz.

:path=/static-assets/excel/content-code-examples/get-started/get-started-5.cs
using IronXL;
using Range = IronXL.Range;

WorkBook workBook = WorkBook.Load("test.xls");
WorkSheet workSheet = workBook.WorkSheets.First();

// This is how we get range from Excel worksheet
Range range = workSheet["A2:A8"];

// Sort the range in the sheet
range.SortAscending();
workBook.Save();
Imports IronXL

Dim workBook As WorkBook = WorkBook.Load("test.xls")
Dim workSheet As WorkSheet = workBook.WorkSheets.First()

' This is how we get range from Excel worksheet
Dim range As Range = workSheet("A2:A8")

' Sort the range in the sheet
range.SortAscending()
workBook.Save()
$vbLabelText   $csharpLabel

Formülleri Düzenleme

Bir Excel formülünü değiştirmek, başına '=' işaretiyle başlayan bir değer atamak kadar basittir. Formül anında hesaplanır.

:path=/static-assets/excel/content-code-examples/get-started/get-started-6.cs
// Set a formula
workSheet["A1"].Value = "=SUM(A2:A10)";

// Get the calculated value
decimal sum = workSheet["A1"].DecimalValue;
' Set a formula
workSheet("A1").Value = "=SUM(A2:A10)"

' Get the calculated value
Dim sum As Decimal = workSheet("A1").DecimalValue
$vbLabelText   $csharpLabel

Neden IronXL'i Seçmelisiniz?

IronXL, .NET'te Excel belgelerini okuma ve yazma için geliştirici-dostu bir API sunar. Microsoft Excel ya da Excel Interop'un sunucuda kurulu olmasını gerektirmeden, Excel dosya işlemlerini hızlı, hafif ve sorunsuz hale getirir.

İlerleme

Daha fazla özellik ve yetenek keşfetmek için, .NET API Referansını incelemenizi öneririz; MSDN belgelerine benzer biçimde formatlanmıştır.

Curtis Chau
Teknik Yazar

Curtis Chau, Bilgisayar Bilimleri alanında Lisans Derecesine (Carleton Üniversitesi) sahip ve Node.js, TypeScript, JavaScript ve React konularında uzmanlaşmış ön uç geliştirmeyle ilgileniyor. Sezgisel ve estetik açıdan hoş kullanıcı arayüzleri oluşturma tutkunu, Curtis modern çerçevelerle çalışmayı ve iyi yapı...

Daha Fazla Oku
Başlamaya Hazır mısınız?
Nuget İndirmeler 2,052,917 | Sürüm: 2026.6 just released
Still Scrolling Icon

Hâlâ Kaydırıyor Musunuz?

Hızlıca kanıt ister misiniz? PM > Install-Package IronXL.Excel
örnek çalıştır verinizin bir hesap tablosu haline geldiğini izleyin.