Başlarken
Kurulum
Aspose.Cells’i NuGet üzerinden yükleyin
NuGet, Aspose.Cells for .NET indirmenin ve yüklemenin en kolay yoludur.
- Microsoft Visual Studio’yu açın ve NuGet paket yöneticisini açın.
- Arama yapın “aspose.cells” istenen Aspose.Cells for .NET bulmak için.
- “Yükle” üzerine tıklayın, Aspose.Cells for .NET projenizde indirilip referans olarak eklenir.
Aspose.Cells için nuget web sayfasından da indirebilirsiniz: Aspose.Cells for .NET NuGet Paketi
Windows üzerinde Aspose.Cells’i Yükle
- Aşağıdaki sayfadan Aspose.Cells.msi’yi indirin: Aspose.Cells.msi’yi İndirin
- Aspose Cells msi dosyasına çift tıklayın ve kurulum talimatlarını takip edin:
Linux’ta Aspose.Cells’i Yükle
Bu örnekte, Ubuntu kullanarak Linux’ta Aspose.Cells nasıl kullanılacağını gösteriyorum.
- “AsposeCellsTest” adında bir .netcore uygulaması oluşturun.
- “AsposeCellsTest.csproj” dosyasını açın, Aspose.Cells paket referansları için aşağıdaki satırları ekleyin:
<ItemGroup> <PackageReference Include="Aspose.Cells" Version="24.7" /> </ItemGroup>
- Ubuntu’da projeyi VSCode ile açın:
- Aşağıdaki kodla testi ç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 For .NetStandard, linux’ta ihtiyacınızı destekleyebilir.
Uygulanabilir: NetStandard2.0, NetCore2.1, NetCore3.1, Net5.0, Net6.0 ve gelişmiş sürüm.
MAC OS’ta Aspose.Cells’i Yükle
Bu örnekte, Aspose.Cells’i MAC OS üzerinde nasıl kullanmaya başlayacağımı göstermek için macOS High Sierra’yı kullanıyorum.
- “AsposeCellsTest” adında bir .netcore uygulaması oluşturun.
- Visual Studio for Mac ile uygulamayı açın, daha sonra Aspose Cells’i NuGet ile yükleyin:
- Aşağıdaki kodla testi ç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 Yüklenir
Not: Aspose.Cells For .NetStandard MAC OS’ta gereksiniminizi destekleyebilir.
Uygulanabilir: NetStandard2.0, NetCore2.1, NetCore3.1, Net5.0, Net6.0 ve gelişmiş sürüm.
Run Aspose Cells in Docker
Net6 ile grafik kütüphanesinin kullanımı
Aspose.Cells for Net6 artık grafiğin kütüphanesi olarak Microsoft’ın resmi açıklamasında önerildiği gibi SkiaSharp kullanıyor. NET6 ile Aspose.Cells kullanımı hakkında daha fazla bilgi için Aspose.Cells for .Net6 Çalıştırma Nasıl Yapılır sayfasına bakınız.
Merhaba Dünya Uygulamasını Oluşturma
Aşağıdaki adımlar, Aspose.Cells API’sini kullanarak Merhaba Dünya uygulamasını oluşturur:
- Bir lisansınız varsa, uygulayın. Eğer değerlendirme sürümünü kullanıyorsanız, lisansla ilgili kod satırlarını atlayın.
- Yeni bir Excel dosyası oluşturmak veya mevcut bir Excel dosyasını açmak için Workbook sınıfından bir örnek oluşturun.
- Excel dosyasındaki istenen hücreye erişin.
- Erişilen bir hücreye Merhaba Dünya! kelimesini ekleyin.
- Değiştirilmiş Microsoft Excel dosyasını oluşturun.
Yukarıdaki adımların uygulanışı aşağıdaki örneklerde gösterilmektedir.
Kod Örneği: Yeni Bir Workbook Oluşturma
Aşağıdaki örnek, sıfırdan yeni bir çalışma kitabı oluşturur, ilk çalışma sayfasındaki A1 hücresine “Merhaba Dünya!” ekler 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ını açar, ilk çalışma sayfasındaki A1 hücresine “Merhaba Dünya!” ekler 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(); |