Wie man Excel-Dateien in C# liest (Entwickler-Tutorial)
In diesem Tutorial wird erklärt, wie man eine Excel-Datei in C# liest und alltägliche Aufgaben wie Datenvalidierung, Datenbankkonvertierung, Web-API-Integrationen und Formeländerungen durchführt. Dieser Artikel verweist auf Codebeispiele, die die IronXL for .NET Excel-Bibliothek verwenden.
Übersicht
How to Read Excel File in C#
- Laden Sie die C#-Bibliothek herunter, um Excel-Dateien zu lesen
- Laden und Lesen einer Excel-Datei (Arbeitsmappe)
- Erstellen einer Excel-Arbeitsmappe in CSV oder XLSX
- Bearbeiten von Zellwerten in einem Bereich von Zellen
- Tabellenkalkulationsdaten validieren
- Daten mit Entity Framework exportieren
IronXL erleichtert das Lesen und Bearbeiten von Microsoft Excel-Dokumenten mit C#. IronXL benötigt weder Microsoft Excel noch Interop. Tatsächlich bietet IronXL eine schnellere und intuitivere API als Microsoft.Office.Interop.Excel
.
IronXL Enthält&Kolon;
- Engagierte Produktunterstützung durch unsere .NET-Ingenieure
- Einfache Installation über Microsoft Visual Studio
-
Kostenloser Probetest für die Entwicklung. Lizenzen ab $749.
Das Lesen und Erstellen von Excel-Dateien in C# und VB.NET ist mit der IronXL-Softwarebibliothek einfach.
Lesen von .XLS- und .XLSX-Excel-Dateien mit IronXL
Nachfolgend finden Sie eine Zusammenfassung des gesamten Arbeitsablaufs beim Lesen von Excel-Dateien mit IronXL:
-
Installieren Sie die IronXL-Excel-Bibliothek. Wir können dies mit unserem NuGet-Paket oder durch Herunterladen der .Net Excel DLL tun.
-
Verwenden Sie die
WorkBook.Load
-Methode, um ein beliebiges XLS-, XLSX- oder CSV-Dokument zu lesen. - Erhalten Sie Zellwerte mit intuitiver Syntax:
sheet ["A11"].DecimalValue
:path=/static-assets/excel/content-code-examples/tutorials/how-to-read-excel-file-csharp-1.cs
using IronXL;
using System;
using System.Linq;
// Supported spreadsheet formats for reading include: XLSX, XLS, CSV and TSV
WorkBook workBook = WorkBook.Load("test.xlsx");
WorkSheet workSheet = workBook.WorkSheets.First();
// Select cells easily in Excel notation and return the calculated value
int cellValue = workSheet["A2"].IntValue;
// Read from Ranges of cells elegantly.
foreach (var cell in workSheet["A2:A10"])
{
Console.WriteLine("Cell {0} has value '{1}'", cell.AddressString, cell.Text);
}
// Advanced Operations
// Calculate aggregate values such as Min, Max and Sum
decimal sum = workSheet["A2:A10"].Sum();
// Linq compatible
decimal max = workSheet["A2:A10"].Max(c => c.DecimalValue);
Imports IronXL
Imports System
Imports System.Linq
' Supported spreadsheet formats for reading include: XLSX, XLS, CSV and TSV
Private workBook As WorkBook = WorkBook.Load("test.xlsx")
Private workSheet As WorkSheet = workBook.WorkSheets.First()
' Select cells easily in Excel notation and return the calculated value
Private cellValue As Integer = workSheet("A2").IntValue
' Read from Ranges of cells elegantly.
For Each cell In workSheet("A2:A10")
Console.WriteLine("Cell {0} has value '{1}'", cell.AddressString, cell.Text)
Next cell
' Advanced Operations
' Calculate aggregate values such as Min, Max and Sum
Dim sum As Decimal = workSheet("A2:A10").Sum()
' Linq compatible
Dim max As Decimal = workSheet("A2:A10").Max(Function(c) c.DecimalValue)
Die in den nächsten Abschnitten dieses Tutorials verwendeten Codebeispiele (zusammen mit dem Beispielprojektcode) werden auf drei Excel-Tabellen funktionieren (siehe unten für eine visuelle Darstellung):
Tutorial
1. Laden Sie die IronXL C# Bibliothek kostenlos herunter
Beginnen Sie noch heute mit der Verwendung von IronXL in Ihrem Projekt mit einer kostenlosen Testversion.
Das Erste, was wir tun müssen, ist die IronXL.Excel
-Bibliothek zu installieren, um Excel-Funktionalität zum .NET Framework hinzuzufügen.
Die Installation von IronXL.Excel
erfolgt am einfachsten über unser NuGet-Paket. Sie können jedoch auch das DLL manuell in Ihrem Projekt oder im globalen Assembly-Cache installieren.
Installieren des IronXL NuGet-Pakets
-
Klicken Sie in Visual Studio mit der rechten Maustaste auf das Projekt und wählen Sie "Manage NuGet Packages ..."
-
Suchen Sie nach dem IronXL.Excel-Paket und klicken Sie auf die Schaltfläche Installieren, um es dem Projekt hinzuzufügen
Eine weitere Möglichkeit, die IronXL-Bibliothek zu installieren, ist die Verwendung der NuGet Package Manager Console:
-
Öffnen Sie die Paketmanager-Konsole
- Geben Sie
> Install-Package IronXL.Excel
ein
PM > Install-Package IronXL.Excel
Außerdem können Sie das Paket auf der NuGet-Website ansehen
Manuelle Installation
Alternativ können wir beginnen, indem wir die IronXL .NET Excel DLL herunterladen und manuell in Visual Studio installieren.
2. Laden einer Excel-Arbeitsmappe
Die WorkBook
-Klasse stellt ein Excel-Blatt dar. Um eine Excel-Datei mit C# zu öffnen, verwenden wir die Methode WorkBook.Load
, wobei wir den Pfad der Excel-Datei angeben.
:path=/static-assets/excel/content-code-examples/tutorials/how-to-read-excel-file-csharp-2.cs
WorkBook workBook = WorkBook.Load(@"Spreadsheets\\GDP.xlsx");
Dim workBook As WorkBook = WorkBook.Load("Spreadsheets\\GDP.xlsx")
Beispiel: ExcelToDBProcessor
Jedes WorkBook
kann mehrere WorkSheet
-Objekte haben. Jedes dieser Blätter steht für ein einzelnes Excel-Arbeitsblatt im Excel-Dokument. Verwenden Sie die WorkBook.GetWorkSheet
-Methode, um eine Referenz auf ein bestimmtes Excel-Arbeitsblatt abzurufen.
:path=/static-assets/excel/content-code-examples/tutorials/how-to-read-excel-file-csharp-3.cs
Beispiel: ExcelToDB
Neue Excel-Dokumente erstellen
Um ein neues Excel-Dokument zu erstellen, konstruieren Sie ein neues WorkBook
-Objekt mit einem gültigen Dateityp.
:path=/static-assets/excel/content-code-examples/tutorials/how-to-read-excel-file-csharp-4.cs
WorkBook workBook = new WorkBook(ExcelFileFormat.XLSX);
Dim workBook As New WorkBook(ExcelFileFormat.XLSX)
Beispiel: ApiToExcelProcessor
Hinweis: Verwenden Sie ExcelFileFormat.XLS
, um ältere Versionen von Microsoft Excel (95 und früher) zu unterstützen.
Einem Excel-Dokument ein Arbeitsblatt hinzufügen
Wie bereits zuvor erklärt, enthält ein IronXL WorkBook
eine Sammlung von einem oder mehreren WorkSheet
s.
Um ein neues WorkSheet
zu erstellen, rufen Sie WorkBook.CreateWorkSheet
mit dem Namen des Arbeitsblatts auf.
:path=/static-assets/excel/content-code-examples/tutorials/how-to-read-excel-file-csharp-5.cs
WorkSheet workSheet = workBook.GetWorkSheet("GDPByCountry");
Dim workSheet As WorkSheet = workBook.GetWorkSheet("GDPByCountry")
3. Zugriff auf Zellenwerte
Lesen und Bearbeiten einer einzelnen Zelle
Der Zugriff auf die Werte einzelner Tabellenkalkulationszellen erfolgt, indem die gewünschte Zelle aus ihrem WorkSheet
abgerufen wird. wie unten dargestellt:
:path=/static-assets/excel/content-code-examples/tutorials/how-to-read-excel-file-csharp-16.cs
WorkBook workBook = WorkBook.Load("test.xlsx");
WorkSheet workSheet = workBook.DefaultWorkSheet;
IronXL.Cell cell = workSheet["B1"].First();
Dim workBook As WorkBook = WorkBook.Load("test.xlsx")
Dim workSheet As WorkSheet = workBook.DefaultWorkSheet
Dim cell As IronXL.Cell = workSheet("B1").First()
Die Cell
-Klasse von IronXL repräsentiert eine einzelne Zelle in einer Excel-Tabelle. Sie enthält Eigenschaften und Methoden, mit denen der Benutzer direkt auf den Wert der Zelle zugreifen und ihn ändern kann.
Jedes WorkSheet
-Objekt verwaltet einen Index von Cell
-Objekten, die jedem Zellwert in einem Excel-Arbeitsblatt entsprechen. Im obigen Quellcode beziehen wir uns auf die gewünschte Zelle durch ihren Zeilen- und Spaltenindex (in diesem Fall die Zelle B1) unter Verwendung der standardmäßigen Array-Indizierungssyntax.
Mit einem Verweis auf das Cell-Objekt können wir Daten aus und in eine Tabellenkalkulationszelle lesen und schreiben:
:path=/static-assets/excel/content-code-examples/tutorials/how-to-read-excel-file-csharp-17.cs
IronXL.Cell cell = workSheet["B1"].First();
string value = cell.StringValue; // Read the value of the cell as a string
Console.WriteLine(value);
cell.Value = "10.3289"; // Write a new value to the cell
Console.WriteLine(cell.StringValue);
Dim cell As IronXL.Cell = workSheet("B1").First()
Dim value As String = cell.StringValue ' Read the value of the cell as a string
Console.WriteLine(value)
cell.Value = "10.3289" ' Write a new value to the cell
Console.WriteLine(cell.StringValue)
Lesen und Schreiben eines Bereichs von Zellwerten
Die Range
-Klasse repräsentiert eine zweidimensionale Sammlung von Cell
-Objekten. Diese Sammlung bezieht sich auf einen wörtlichen Bereich von Excel-Zellen. Erhalten Sie Bereiche, indem Sie den String-Indexer auf einem WorkSheet
-Objekt verwenden.
Das Argumenttext ist entweder die Koordinate einer Zelle (z. B. "A1", wie zuvor gezeigt) oder ein Bereich von Zellen von links nach rechts oben nach unten (z. B. "B2:E5"). Es ist auch möglich, GetRange
auf einem WorkSheet
aufzurufen.
:path=/static-assets/excel/content-code-examples/tutorials/how-to-read-excel-file-csharp-6.cs
Range range = workSheet["D2:D101"];
Dim range As Range = workSheet("D2:D101")
Beispiel: Datenvalidierung
Es gibt mehrere Möglichkeiten, die Werte von Zellen innerhalb eines Bereichs zu lesen oder zu bearbeiten. Wenn die Anzahl bekannt ist, verwenden Sie eine For-Schleife.
:path=/static-assets/excel/content-code-examples/tutorials/how-to-read-excel-file-csharp-7.cs
// Iterate through the rows
for (var y = 2; y <= 101; y++)
{
var result = new PersonValidationResult { Row = y };
results.Add(result);
// Get all cells for the person
var cells = workSheet[$"A{y}:E{y}"].ToList();
// Validate the phone number (1 = B)
var phoneNumber = cells[1].Value;
result.PhoneNumberErrorMessage = ValidatePhoneNumber(phoneNumberUtil, (string)phoneNumber);
// Validate the email address (3 = D)
result.EmailErrorMessage = ValidateEmailAddress((string)cells[3].Value);
// Get the raw date in the format of Month Day[suffix], Year (4 = E)
var rawDate = (string)cells[4].Value;
result.DateErrorMessage = ValidateDate(rawDate);
}
' Iterate through the rows
For y = 2 To 101
Dim result = New PersonValidationResult With {.Row = y}
results.Add(result)
' Get all cells for the person
Dim cells = workSheet($"A{y}:E{y}").ToList()
' Validate the phone number (1 = B)
Dim phoneNumber = cells(1).Value
result.PhoneNumberErrorMessage = ValidatePhoneNumber(phoneNumberUtil, CStr(phoneNumber))
' Validate the email address (3 = D)
result.EmailErrorMessage = ValidateEmailAddress(CStr(cells(3).Value))
' Get the raw date in the format of Month Day[suffix], Year (4 = E)
Dim rawDate = CStr(cells(4).Value)
result.DateErrorMessage = ValidateDate(rawDate)
Next y
Beispiel: Datenvalidierung
Formel zu einem Arbeitsblatt hinzufügen
Setzen Sie die Formel von Cell
s mit der Formula
-Eigenschaft.
Der folgende Code durchläuft jeden Zustand und gibt in Spalte C einen Gesamtprozentsatz an.
:path=/static-assets/excel/content-code-examples/tutorials/how-to-read-excel-file-csharp-13.cs
// Iterate through all rows with a value
for (var y = 2 ; y < i ; y++)
{
// Get the C cell
Cell cell = workSheet[$"C{y}"].First();
// Set the formula for the Percentage of Total column
cell.Formula = $"=B{y}/B{i}";
}
' Iterate through all rows with a value
Dim y = 2
Do While y < i
' Get the C cell
Dim cell As Cell = workSheet($"C{y}").First()
' Set the formula for the Percentage of Total column
cell.Formula = $"=B{y}/B{i}"
y += 1
Loop
Beispiel: AddFormulaeProcessor
Tabellenkalkulationsdaten validieren
Verwenden Sie IronXL zur Validierung eines Datenblatts. Das DataValidation
-Beispiel verwendet libphonenumber-csharp
, um Telefonnummern zu validieren, und nutzt standardmäßige C#-APIs, um E-Mail-Adressen und Daten zu validieren.
:path=/static-assets/excel/content-code-examples/tutorials/how-to-read-excel-file-csharp-8.cs
// Iterate through the rows
for (var i = 2; i <= 101; i++)
{
var result = new PersonValidationResult { Row = i };
results.Add(result);
// Get all cells for the person
var cells = worksheet[$"A{i}:E{i}"].ToList();
// Validate the phone number (1 = B)
var phoneNumber = cells[1].Value;
result.PhoneNumberErrorMessage = ValidatePhoneNumber(phoneNumberUtil, (string)phoneNumber);
// Validate the email address (3 = D)
result.EmailErrorMessage = ValidateEmailAddress((string)cells[3].Value);
// Get the raw date in the format of Month Day[suffix], Year (4 = E)
var rawDate = (string)cells[4].Value;
result.DateErrorMessage = ValidateDate(rawDate);
}
' Iterate through the rows
For i = 2 To 101
Dim result = New PersonValidationResult With {.Row = i}
results.Add(result)
' Get all cells for the person
Dim cells = worksheet($"A{i}:E{i}").ToList()
' Validate the phone number (1 = B)
Dim phoneNumber = cells(1).Value
result.PhoneNumberErrorMessage = ValidatePhoneNumber(phoneNumberUtil, CStr(phoneNumber))
' Validate the email address (3 = D)
result.EmailErrorMessage = ValidateEmailAddress(CStr(cells(3).Value))
' Get the raw date in the format of Month Day[suffix], Year (4 = E)
Dim rawDate = CStr(cells(4).Value)
result.DateErrorMessage = ValidateDate(rawDate)
Next i
Der obige Code durchläuft jede Zeile der Kalkulationstabelle in einer Schleife und erfasst die Zellen als Liste. Jede validates-Methode überprüft den Wert einer Zelle und gibt eine Fehlermeldung zurück, wenn der Wert ungültig ist.
Dieser Code erstellt ein neues Blatt, gibt Kopfzeilen an und gibt die Ergebnisse der Fehlermeldung aus, so dass es ein Protokoll der ungültigen Daten gibt.
:path=/static-assets/excel/content-code-examples/tutorials/how-to-read-excel-file-csharp-9.cs
var resultsSheet = workBook.CreateWorkSheet("Results");
resultsSheet["A1"].Value = "Row";
resultsSheet["B1"].Value = "Valid";
resultsSheet["C1"].Value = "Phone Error";
resultsSheet["D1"].Value = "Email Error";
resultsSheet["E1"].Value = "Date Error";
for (var i = 0; i < results.Count; i++)
{
var result = results[i];
resultsSheet[$"A{i + 2}"].Value = result.Row;
resultsSheet[$"B{i + 2}"].Value = result.IsValid ? "Yes" : "No";
resultsSheet[$"C{i + 2}"].Value = result.PhoneNumberErrorMessage;
resultsSheet[$"D{i + 2}"].Value = result.EmailErrorMessage;
resultsSheet[$"E{i + 2}"].Value = result.DateErrorMessage;
}
workBook.SaveAs(@"Spreadsheets\\PeopleValidated.xlsx");
Dim resultsSheet = workBook.CreateWorkSheet("Results")
resultsSheet("A1").Value = "Row"
resultsSheet("B1").Value = "Valid"
resultsSheet("C1").Value = "Phone Error"
resultsSheet("D1").Value = "Email Error"
resultsSheet("E1").Value = "Date Error"
For i = 0 To results.Count - 1
Dim result = results(i)
resultsSheet($"A{i + 2}").Value = result.Row
resultsSheet($"B{i + 2}").Value = If(result.IsValid, "Yes", "No")
resultsSheet($"C{i + 2}").Value = result.PhoneNumberErrorMessage
resultsSheet($"D{i + 2}").Value = result.EmailErrorMessage
resultsSheet($"E{i + 2}").Value = result.DateErrorMessage
Next i
workBook.SaveAs("Spreadsheets\\PeopleValidated.xlsx")
4. Daten mit Entity Framework exportieren
Mit IronXL können Sie Daten in eine Datenbank exportieren oder eine Excel-Tabelle in eine Datenbank konvertieren. Das ExcelToDB
-Beispiel liest eine Tabelle mit dem BIP nach Ländern und exportiert diese Daten dann in eine SQLite.
Es verwendet EntityFramework
, um die Datenbank zu erstellen und dann die Daten Zeile für Zeile zu exportieren.
Fügen Sie die SQLite Entity Framework NuGet-Pakete hinzu.
EntityFramework
ermöglicht es Ihnen, ein Modellobjekt zu erstellen, das Daten in die Datenbank exportieren kann.
:path=/static-assets/excel/content-code-examples/tutorials/how-to-read-excel-file-csharp-10.cs
public class Country
{
[Key]
public Guid Key { get; set; }
public string Name { get; set; }
public decimal GDP { get; set; }
}
Public Class Country
<Key>
Public Property Key() As Guid
Public Property Name() As String
Public Property GDP() As Decimal
End Class
Um eine andere Datenbank zu verwenden, installieren Sie das entsprechende NuGet-Paket und finden Sie das Äquivalent von UseSqLite()
:path=/static-assets/excel/content-code-examples/tutorials/how-to-read-excel-file-csharp-11.cs
public class CountryContext : DbContext
{
public DbSet<Country> Countries { get; set; }
public CountryContext()
{
//TODO: Make async
Database.EnsureCreated();
}
/// <summary>
/// Configure context to use Sqlite
/// </summary>
/// <param name="optionsBuilder"></param>
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
var connection = new SqliteConnection($"Data Source=Country.db");
connection.Open();
var command = connection.CreateCommand();
//Create the database if it doesn't already exist
command.CommandText = $"PRAGMA foreign_keys = ON;";
command.ExecuteNonQuery();
optionsBuilder.UseSqlite(connection);
base.OnConfiguring(optionsBuilder);
}
}
Public Class CountryContext
Inherits DbContext
Public Property Countries() As DbSet(Of Country)
Public Sub New()
'TODO: Make async
Database.EnsureCreated()
End Sub
''' <summary>
''' Configure context to use Sqlite
''' </summary>
''' <param name="optionsBuilder"></param>
Protected Overrides Sub OnConfiguring(ByVal optionsBuilder As DbContextOptionsBuilder)
Dim connection = New SqliteConnection($"Data Source=Country.db")
connection.Open()
Dim command = connection.CreateCommand()
'Create the database if it doesn't already exist
command.CommandText = $"PRAGMA foreign_keys = ON;"
command.ExecuteNonQuery()
optionsBuilder.UseSqlite(connection)
MyBase.OnConfiguring(optionsBuilder)
End Sub
End Class
Erstellen Sie einen CountryContext
, iterieren Sie durch den Bereich, um jeden Datensatz zu erstellen, und verwenden Sie dann SaveAsync
, um die Daten in der Datenbank zu speichern.
:path=/static-assets/excel/content-code-examples/tutorials/how-to-read-excel-file-csharp-12.cs
public async Task ProcessAsync()
{
//Get the first worksheet
var workbook = WorkBook.Load(@"Spreadsheets\\GDP.xlsx");
var worksheet = workbook.GetWorkSheet("GDPByCountry");
//Create the database connection
using (var countryContext = new CountryContext())
{
//Iterate through all the cells
for (var i = 2; i <= 213; i++)
{
//Get the range from A-B
var range = worksheet[$"A{i}:B{i}"].ToList();
//Create a Country entity to be saved to the database
var country = new Country
{
Name = (string)range[0].Value,
GDP = (decimal)(double)range[1].Value
};
//Add the entity
await countryContext.Countries.AddAsync(country);
}
//Commit changes to the database
await countryContext.SaveChangesAsync();
}
}
Public Async Function ProcessAsync() As Task
'Get the first worksheet
Dim workbook = WorkBook.Load("Spreadsheets\\GDP.xlsx")
Dim worksheet = workbook.GetWorkSheet("GDPByCountry")
'Create the database connection
Using countryContext As New CountryContext()
'Iterate through all the cells
For i = 2 To 213
'Get the range from A-B
Dim range = worksheet($"A{i}:B{i}").ToList()
'Create a Country entity to be saved to the database
Dim country As New Country With {
.Name = CStr(range(0).Value),
.GDP = CDec(CDbl(range(1).Value))
}
'Add the entity
Await countryContext.Countries.AddAsync(country)
Next i
'Commit changes to the database
Await countryContext.SaveChangesAsync()
End Using
End Function
Beispiel: ExcelToDB
5. Herunterladen von Daten aus einer API in eine Tabellenkalkulation
Der folgende Aufruf führt einen REST-Aufruf mit RestClient.Net aus. Es lädt JSON herunter und konvertiert es in eine "Liste" des Typs RestCountry
. Es ist dann einfach, die einzelnen Länder zu durchlaufen und die Daten von der REST-API in einer Excel-Tabelle zu speichern.
:path=/static-assets/excel/content-code-examples/tutorials/how-to-read-excel-file-csharp-14.cs
var client = new Client(new Uri("https://restcountries.eu/rest/v2/"));
List<RestCountry> countries = await client.GetAsync<List<RestCountry>>();
Dim client As New Client(New Uri("https://restcountries.eu/rest/v2/"))
Dim countries As List(Of RestCountry) = Await client.GetAsync(Of List(Of RestCountry))()
Beispiel: ApiToExcel
So sehen die JSON-Daten der API aus.
Der folgende Code durchläuft die Länder und setzt den Namen, die Bevölkerung, die Region, den NumericCode und die 3 wichtigsten Sprachen in das Arbeitsblatt.
:path=/static-assets/excel/content-code-examples/tutorials/how-to-read-excel-file-csharp-15.cs
for (var i = 2; i < countries.Count; i++)
{
var country = countries[i];
//Set the basic values
workSheet[$"A{i}"].Value = country.name;
workSheet[$"B{i}"].Value = country.population;
workSheet[$"G{i}"].Value = country.region;
workSheet[$"H{i}"].Value = country.numericCode;
//Iterate through languages
for (var x = 0; x < 3; x++)
{
if (x > (country.languages.Count - 1)) break;
var language = country.languages[x];
//Get the letter for the column
var columnLetter = GetColumnLetter(4 + x);
//Set the language name
workSheet[$"{columnLetter}{i}"].Value = language.name;
}
}
For i = 2 To countries.Count - 1
Dim country = countries(i)
'Set the basic values
workSheet($"A{i}").Value = country.name
workSheet($"B{i}").Value = country.population
workSheet($"G{i}").Value = country.region
workSheet($"H{i}").Value = country.numericCode
'Iterate through languages
For x = 0 To 2
If x > (country.languages.Count - 1) Then
Exit For
End If
Dim language = country.languages(x)
'Get the letter for the column
Dim columnLetter = GetColumnLetter(4 + x)
'Set the language name
workSheet($"{columnLetter}{i}").Value = language.name
Next x
Next i
Objektreferenz und Ressourcen
Sie finden möglicherweise auch die [IronXL-Klassendokumentation](/csharp/excel/object-reference/api/" target="_blank) im Objektverweis von großem Wert.
Zusätzlich gibt es weitere Tutorials, die Licht auf andere Aspekte von IronXL.Excel
werfen können, darunter Erstellen, Öffnen, Schreiben, Bearbeiten, Speichern und Exportieren von XLS-, XLSX- und CSV-Dateien, ohne Excel Interop zu verwenden.
Zusammenfassung
IronXL.Excel ist eine reine .NET-Softwarebibliothek zum Lesen einer Vielzahl von Tabellenkalkulationsformaten. Es erfordert nicht, dass Microsoft Excel installiert ist, und ist nicht von Interop abhängig.
Wenn Sie die .NET-Bibliothek nützlich zum Ändern von Excel-Dateien finden, könnten Sie auch daran interessiert sein, die Google Sheets API Client Library für .NET zu erkunden, die es Ihnen ermöglicht, Google Sheets zu ändern.
Tutorial Schnellzugriff
Download this Tutorial as C# Source Code
The full free C# for Excel Source Code for this tutorial is available to download as a zipped Visual Studio 2017 project file.
DownloadErkunden Sie dieses Tutorial auf GitHub
The source code for this project is available in C# and VB.NET on GitHub.
Verwenden Sie diesen Code als einfache Möglichkeit, um in nur wenigen Minuten loszulegen. Das Projekt wird als Microsoft Visual Studio 2017 Projekt gespeichert, ist aber mit jeder .NET IDE kompatibel.
How to Read Excel File in C# on GitHubAnsicht der API-Referenz
Entdecken Sie die API-Referenz für IronXL, die Details zu allen Funktionen, Namespaces, Klassen, Methoden, Feldern und Enums von IronXL enthält.
Ansicht der API-Referenz