Başlarken
Kurulum
Aspose.Cells’den NuGet’e yükleyin
NuGet Aspose.Cells for .NET indirip kurmanın en kolay yolu.
- Microsoft Visual Studio ve NuGet paket yöneticisini açın.
- İstediğiniz Aspose.Cells for .NET’i bulmak için “aspose.cells” araması yapın.
- “Yükle"ye tıklayın, Aspose.Cells for .NET indirilecek ve projenizde referans gösterilecektir. 
aspose.cells için nuget web sayfasından da indirebilirsiniz: Aspose.Cells for .NET NuGet Paket
Ayrıntılar için daha fazla adım
Aspose.Cells’i pencerelere yükleyin
- Aşağıdaki sayfadan Aspose.Cells.msi dosyasını indirin: Aspose.Cells.msi dosyasını indirin
- Aspose Cells msi dosyasına çift tıklayın ve yüklemek için talimatları izleyin:
Ayrıntılar için daha fazla adım
Aspose.Cells’i Linux’a kurun
Bu örnekte, Linux’ta Aspose.Cells’i kullanmaya nasıl başlayacağımı göstermek için Ubuntu kullanıyorum.
- “AsposeCellsTest” adlı bir .netcore uygulaması oluşturun.
- “AsposeCellsTest.csproj” dosyasını açın, Aspose.Cells paket referansları için içine aşağıdaki satırları ekleyin:
<ItemGroup> <PackageReference Include="Aspose.Cells" Version="22.12" /> </ItemGroup>
- Projeyi Ubuntu’da VSCode ile açın:
- testi aşağıdaki kodla çalıştırın:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET Aspose.Cells.Workbook wb1 = new Aspose.Cells.Workbook(); wb1.Worksheets.Add("linux"); wb1.Worksheets["linux"].Cells[0, 0].Value = "Using Aspose Cells on linux with VS Code."; wb1.Save("linux.xlsx");
Not: Aspose.Cells .NetStandard için linux gereksinimlerinizi destekleyebilir.
Şunlar için geçerlidir: NetStandard2.0, NetCore2.1, NetCore3.1, Net5.0, Net6.0 ve gelişmiş sürüm.
Aspose.Cells’i MAC OS’ye kurun
Bu örnekte, MAC OS’de Aspose.Cells’i kullanmaya nasıl başlayacağımı göstermek için macOS High Sierra kullanıyorum.
- “AsposeCellsTest” adlı bir .netcore uygulaması oluşturun.
- Uygulamayı Mac için Visual Studio ile açın, ardından Aspose Cells’den NuGet’e yükleyin:
- testi aşağıdaki kodla çalıştırın:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET Aspose.Cells.Workbook wb1 = new Aspose.Cells.Workbook(); wb1.Worksheets.Add("macOS"); wb1.Worksheets["macOS"].Cells[0, 0].Value = "Using Aspose Cells on macOS with Visual Studio For MAC."; wb1.Save("macOS.xlsx"); - Çizimle ilgili özellikleri kullanmanız gerekiyorsa, lütfen macOS’ta libgdiplus’ı yükleyin, bkz.: macOS’ta libgdiplus nasıl kurulur
Not: Aspose.Cells .NetStandard, MAC OS gereksinimlerinizi destekleyebilir.
Şunlar için geçerlidir: NetStandard2.0, NetCore2.1, NetCore3.1, Net5.0, Net6.0 ve gelişmiş sürüm.
Aspose Cells’i Docker’da çalıştırın
Net6 ile Windows dışı platformlarda grafik kitaplığı nasıl kullanılır?
Net6 için Aspose.Cells, şu bölümde önerildiği gibi artık grafik kitaplığı olarak SkiaSharp’ı kullanıyor:resmi açıklama Microsoft . Aspose.Cells’i NET6 ile kullanma hakkında daha fazla ayrıntı için lütfen bkz..Net6 için Aspose.Cells Nasıl Çalıştırılır.
Hello World Uygulamasını Oluşturma
Aşağıdaki adımlar, Aspose.Cells API’i kullanarak Hello World uygulamasını oluşturur:
- Ehliyetin varsa o zamanuygula. Değerlendirme sürümünü kullanıyorsanız, lisansla ilgili kod satırlarını atlayın.
- örneğini oluşturunÇalışma kitabı Yeni bir Excel dosyası oluşturmak veya mevcut bir Excel dosyasını açmak için sınıfı kullanın.
- Excel dosyasındaki bir çalışma sayfasının istediğiniz herhangi bir hücresine erişin.
- kelimeleri ekleHello World! erişilen bir hücreye
- Değiştirilen Microsoft Excel dosyasını oluşturun.
Yukarıdaki adımların uygulanması aşağıdaki örneklerde gösterilmektedir.
Kod Örneği: Yeni Bir Çalışma Kitabı Oluşturma
Aşağıdaki örnek sıfırdan yeni bir çalışma kitabı oluşturur ve “Hello World!” ekler. ilk çalışma sayfasındaki A1 hücresine girer ve Excel dosyası olarak kaydeder.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
try | |
{ | |
// Create a License object | |
License license = new License(); | |
// Set the license of Aspose.Cells to avoid the evaluation limitations | |
license.SetLicense(dataDir + "Aspose.Cells.lic"); | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine(ex.Message); | |
} | |
// Instantiate a Workbook object that represents Excel file. | |
Workbook wb = new Workbook(); | |
// When you create a new workbook, a default "Sheet1" is added to the workbook. | |
Worksheet sheet = wb.Worksheets[0]; | |
// Access the "A1" cell in the sheet. | |
Cell cell = sheet.Cells["A1"]; | |
// Input the "Hello World!" text into the "A1" cell | |
cell.PutValue("Hello World!"); | |
// Save the Excel file. | |
wb.Save(dataDir + "MyBook_out.xlsx"); |
Kod Örneği: Mevcut Bir Dosyayı Açma
Aşağıdaki örnek, mevcut bir Microsoft Excel şablon dosyası olan “Sample.xlsx"i açar, “Hello World!” ekler. ilk çalışma sayfasındaki A1 hücresine girer ve Excel dosyası olarak kaydeder.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
try | |
{ | |
// Create a License object | |
License license = new License(); | |
// Set the license of Aspose.Cells to avoid the evaluation limitations | |
license.SetLicense("Aspose.Cells.lic"); | |
} | |
catch (Exception ex) | |
{ | |
Console.WriteLine(ex.Message); | |
} | |
// Creating a file stream containing the Excel file to be opened | |
FileStream fstream = new FileStream(dataDir + "Sample.xlsx", FileMode.Open); | |
// Instantiate a Workbook object that represents the existing Excel file | |
Workbook workbook = new Workbook(fstream); | |
// Get the reference of "A1" cell from the cells collection of a worksheet | |
Cell cell = workbook.Worksheets[0].Cells["A1"]; | |
// Put the "Hello World!" text into the "A1" cell | |
cell.PutValue("Hello World!"); | |
// Save the Excel file | |
workbook.Save(dataDir + "HelloWorld_out.xlsx"); | |
// Closing the file stream to free all resources | |
fstream.Close(); |