Başlarken

Kurulum

Aspose.Cells’den NuGet’e yükleyin

NuGet Aspose.Cells for .NET indirip kurmanın en kolay yolu.

  1. Microsoft Visual Studio ve NuGet paket yöneticisini açın.
  2. İstediğiniz Aspose.Cells for .NET’i bulmak için “aspose.cells” araması yapın.
  3. “Yükle"ye tıklayın, Aspose.Cells for .NET indirilecek ve projenizde referans gösterilecektir. ![Aspose Cells ila NuGet’i yükleyin](nuget.png aracılığıyla yükleme)

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

  1. Aşağıdaki sayfadan Aspose.Cells.msi dosyasını indirin: Aspose.Cells.msi dosyasını indirin
  2. Aspose Cells msi dosyasına çift tıklayın ve yüklemek için talimatları izleyin:

Windows’ta Aspose Cells’i kurun

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.

  1. “AsposeCellsTest” adlı bir .netcore uygulaması oluşturun.
  2. “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>
  3. Projeyi Ubuntu’da VSCode ile açın: Linux’ta Aspose Cells’i kurun
  4. testi aşağıdaki kodla çalıştırın:
    // 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.

  1. “AsposeCellsTest” adlı bir .netcore uygulaması oluşturun.
  2. Uygulamayı Mac için Visual Studio ile açın, ardından Aspose Cells’den NuGet’e yükleyin: macOS’ta Aspose Cells’i yükleyin
  3. testi aşağıdaki kodla çalıştırın:
    // 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");
  4. Ç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:

  1. Ehliyetin varsa o zamanuygula. Değerlendirme sürümünü kullanıyorsanız, lisansla ilgili kod satırlarını atlayın.
  2. ö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.
  3. Excel dosyasındaki bir çalışma sayfasının istediğiniz herhangi bir hücresine erişin.
  4. kelimeleri ekleHello World! erişilen bir hücreye
  5. 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();