Başlarken

Kurulum

NuGet üzerinden Aspose Cells kurun

NuGet, Aspose.Cells for C++‘ı indirmenin ve yüklemenin en kolay yoludur.

  1. C++ için bir Microsoft Visual Studio projesi oluşturun.
  2. “Aspose.Cells.h” başlık dosyasını dahil edin.
  3. Microsoft Visual Studio ve NuGet paket yöneticisini açın.
  4. Aramak için “aspose.cells.cpp” yazın, istenen Aspose.Cells for C++‘i bulun.
  5. “Yükle”‘ye tıklayın, Aspose.Cells for C++ indirilecek ve projenizde referans olarak alınacaktır.

Aspose Cells’u NuGet Üzerinden Yükleyin

Aspose.Cells için nuget web sayfasından da indirebilirsiniz: Aspose.Cells for C++ NuGet Paketi

Detaylar için daha fazla adım

Windows’ta Aspose.Cells for C++ kullanımı için bir demo

  1. Aspose.Cells for C++‘yi aşağıdaki sayfadan indirin: Aspose.Cells for C++‘i İndir (Windows)
  2. Paketi açın ve Aspose.Cells for C++‘i nasıl kullanılacağına dair bir örnek bulacaksınız.
  3. Visual Studio 2017 veya daha yeni sürümü ile example.sln dosyasını açın
  4. main.cpp: Bu dosya Aspose.Cells for C++‘i test etmek için nasıl kod yazılacağını gösterir

Linux’ta Aspose.Cells for C++ kullanımı için bir demo

  1. Aspose.Cells for C++‘yi aşağıdaki sayfadan indirin: Aspose.Cells for C++‘i İndir (Linux)
  2. Paketi açın ve Aspose.Cells for C++‘i nasıl kullanılacağına dair bir örnek bulacaksınız.
  3. Örnek dosyasının bulunduğu dizinde olduğunuzdan emin olun.
  4. “cmake -S example -B example/build -DCMAKE_BUILD_TYPE=Release” komutunu çalıştırın
  5. “cmake -S example -B example/build -DCMAKE_BUILD_TYPE=Release” komutunu çalıştırın

Mac OS’ta Aspose.Cells for C++ kullanımı için bir demo

  1. Aspose.Cells for C++‘yi aşağıdaki sayfadan indirin: Aspose.Cells for C++‘i İndir (MacOS)
  2. Paketi açın ve Aspose.Cells for C++‘i nasıl kullanılacağına dair bir örnek bulacaksınız.
  3. Örnek dosyasının bulunduğu dizinde olduğunuzdan emin olun.
  4. “cmake -S example -B example/build -DCMAKE_BUILD_TYPE=Release” komutunu çalıştırın
  5. “cmake -S example -B example/build -DCMAKE_BUILD_TYPE=Release” komutunu çalıştırın

Merhaba Dünya Uygulamasını Oluşturma

Aşağıdaki adımlar, Aspose.Cells API’sini kullanarak Merhaba Dünya uygulamasını oluşturur:

Aşağıdaki adımlar, Aspose.Cells API’sini kullanarak Hello World uygulamasını oluşturur:

  1. Workbook sınıfından bir örnek oluşturun. Eğer değerlendirme sürümünü kullanıyorsanız, lisansla ilgili kod satırlarını atlayın.
  2. Excel dosyasındaki istenen hücreye erişin.
  3. Hücreye erişildiğinde “Merhaba Dünya!” kelimesini ekleyin.
  4. 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, baştan yeni bir çalışma kitabı oluşturur, ilk çalışma sayfasındaki A1 hücresine “Merhaba Dünya!” ekler ve Excel dosyasını kaydeder.

#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main(void)
{
Aspose::Cells::Startup();
try
{
// Create a License object
License license;
// Set the license of Aspose.Cells to avoid the evaluation limitations
license.SetLicense(u"Aspose.Cells.lic");
// Instantiate a Workbook object that represents Excel file.
Workbook wb;
// When you create a new workbook, a default "Sheet1" is added to the workbook.
Worksheet sheet = wb.GetWorksheets().Get(0);
// Access the "A1" cell in the sheet.
Cell cell = sheet.GetCells().Get(u"A1");
// Input the "Hello World!" text into the "A1" cell
cell.PutValue(u"Hello World!");
// Save the Excel file.
wb.Save(u"MyBook_out.xlsx");
}
catch (const CellsException& ex)
{
std::cout << ex.GetErrorMessage().ToUtf8() << std::endl;
}
Aspose::Cells::Cleanup();
}

Kod Örneği: Mevcut Bir Dosyayı Açma

Aşağıdaki örnek, mevcut bir Microsoft Excel şablon dosyasını açar, bir hücre alır ve A1 hücresindeki değeri kontrol eder.

#include "Aspose.Cells.h"
using namespace Aspose::Cells;
/*Check result*/
#define EXPECT_TRUE(condition) \
if (condition) printf("--%s,line:%d -> Ok --\n", __FUNCTION__, __LINE__); \
else printf("--%s,line:%d->>>> Failed!!!! <<<<--\n", __FUNCTION__, __LINE__);
int main(void)
{
Aspose::Cells::Startup();
try
{
// Create a License object
License license;
// Set the license of Aspose.Cells to avoid the evaluation limitations
//license.SetLicense(u"Aspose.Cells.lic");
// Instantiate a Workbook object that represents Excel file.
Workbook wb;//(u"MyBook_out.xlsx");
// When you create a new workbook, a default "Sheet1" is added to the workbook.
Worksheet sheet = wb.GetWorksheets().Get(0);
// Access the "A1" cell in the sheet.
Cell cell = sheet.GetCells().Get(u"A1");
U16String strRet = cell.GetStringValue();
//check value
EXPECT_TRUE(strRet == u"Hello World!");
// Save the Excel file.
wb.Save(u"MyBook_out.xlsx");
}
catch (const CellsException& ex)
{
std::cout << ex.GetErrorMessage().ToUtf8() << std::endl;
}
Aspose::Cells::Cleanup();
}