البدء

التثبيت

تثبيت Aspose Cells من خلال NuGet

NuGet هو أسهل طريقة لتنزيل وتثبيت Aspose.Cells for C++.

  1. إنشاء مشروع Microsoft Visual Studio لـ C++.
  2. تضمين ملف الرأس “Aspose.Cells.h”.
  3. فتح Microsoft Visual Studio ومدير حزمة NuGet.
  4. البحث عن “aspose.cells.cpp” للعثور على Aspose.Cells for C++ المطلوبة.
  5. انقر فوق “تثبيت”، سيتم تنزيل Aspose.Cells for C++ والإشارة إليه في مشروعك.

تثبيت Aspose Cells من خلال NuGet

يمكنك أيضًا تنزيله من صفحة الويب nuget ل aspose.cells: حزمة NuGet لـ Aspose.Cells for C++

مزيد من الخطوات للتفاصيل

عرض توضيحي لاستخدام Aspose.Cells for C++ على Windows

  1. قم بتنزيل Aspose.Cells for C++ من الصفحة التالية: تنزيل Aspose.Cells for C++(Windows)
  2. قم بفك الضغط عن الحزمة وستجد مثالًا حول كيفية استخدام Aspose.Cells for C++.
  3. افتح ملف example.sln باستخدام Visual Studio 2017 أو أحدث.
  4. main.cpp: يظهر هذا الملف كيفية كتابة الاختبار لـ Aspose.Cells for C++.

عرض توضيحي لاستخدام Aspose.Cells for C++ على Linux.

  1. قم بتنزيل Aspose.Cells for C++ من الصفحة التالية: تنزيل Aspose.Cells for C++ (Linux)
  2. قم بفك الضغط عن الحزمة وستجد مثالًا حول كيفية استخدام Aspose.Cells for C++ على Linux.
  3. تأكد من أنك في المسار الذي يقع فيه المثال.
  4. قم بتشغيل “cmake -S example -B example/build -DCMAKE_BUILD_TYPE=Release”
  5. قم بتشغيل “cmake –build example/build”

عرض توضيحي لاستخدام Aspose.Cells for C++ على نظام Mac OS.

  1. قم بتنزيل Aspose.Cells for C++ من الصفحة التالية: تنزيل Aspose.Cells for C++ (MacOS)
  2. قم بفك الضغط عن الحزمة وستجد مثالًا حول كيفية استخدام Aspose.Cells for C++ على نظام MacOS.
  3. تأكد من أنك في المسار الذي يقع فيه المثال.
  4. قم بتشغيل “cmake -S example -B example/build -DCMAKE_BUILD_TYPE=Release”
  5. قم بتشغيل “cmake –build example/build”

إنشاء تطبيق مرحبًا بالعالم

تقوم الخطوات التالية بإنشاء تطبيق مرحبًا بالعالم باستخدام واجهة برمجة التطبيقات لـ Aspose.Cells:

  1. أنشئ نسخة من فئة Workbook.
  2. إذا كان لديك ترخيص، ثم قم بتطبيقه. إذا كنت تستخدم النسخة التجريبية، فتخطى خطوط الكود المتعلقة بالترخيص. ١. الوصول إلى أي خلية مرغوبة في ورقة العمل في ملف إكسل.
  3. أدخل عبارة “مرحبًا بالعالم!” في الخلية المستخدمة.
  4. إنشاء ملف Microsoft Excel المعدل.

يتم توضيح تنفيذ الخطوات أعلاه في الأمثلة أدناه.

مثال على الشفرة: إنشاء مصنف جديد

المثال التالي يقوم بإنشاء مصنف جديد من البداية، يقوم بإدراج “مرحبًا بالعالم!” في الخلية A1 في ورقة العمل الأولى، ويحفظ ملف Excel.

#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();
}

مثال على الشفرة: فتح ملف موجود

المثال التالي يفتح ملف قالب Microsoft Excel موجود، يحصل على خلية ويتحقق من القيمة في الخلية A1.

#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();
}