البدء
التثبيت
ثبت Aspose.Cells عبر NuGet
NuGet هو أسهل طريقة لتنزيل وتثبيت Aspose.Cells for .NET.
- افتح Microsoft Visual Studio ومدير حزم NuGet.
- ابحث عن “aspose.cells” للعثور على Aspose.Cells for .NET المطلوبة.
- انقر فوق “تثبيت”، سيتم تنزيل Aspose.Cells for .NET والإشارة إليها في مشروعك.
يمكنك أيضًا تنزيله من صفحة الويب nuget ل aspose.cells: حزمة NuGet Aspose.Cells for .NET
ثبت Aspose.Cells على نظام التشغيل Windows
- قم بتنزيل Aspose.Cells.msi من الصفحة التالية: تنزيل Aspose.Cells.msi
- انقر نقرًا مزدوجًا على Aspose Cells msi واتبع التعليمات لتثبيته:
تثبيت Aspose.Cells على نظام التشغيل لينكس
في هذا المثال، استخدم Ubuntu لأظهر كيفية البدء باستخدام Aspose.Cells على نظام التشغيل لينكس.
- قم بإنشاء تطبيق .netcore، وسمه “AsposeCellsTest”.
- افتح ملف “AsposeCellsTest.csproj”، وأضف الأسطر التالية إليه للإشارة إلى حزمة Aspose.Cells:
<ItemGroup> <PackageReference Include="Aspose.Cells" Version="24.7" /> </ItemGroup>
- افتح المشروع باستخدام VSCode على Ubuntu:
- قم بتشغيل الاختبار باستخدام الكود التالي:
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");
ملاحظة: Aspose.Cells لـ .NetStandard يمكن أن تدعم متطلباتك على نظام التشغيل لينكس.
ينطبق على: NetStandard2.0، NetCore2.1، NetCore3.1، Net5.0، Net6.0 والإصدار المتقدم.
تثبيت Aspose.Cells على نظام التشغيل macOS
في هذا المثال، استخدم macOS High Sierra لأظهر كيفية البدء باستخدام Aspose.Cells على نظام التشغيل macOS.
- قم بإنشاء تطبيق .netcore، وسمه “AsposeCellsTest”.
- افتح التطبيق باستخدام Visual Studio for Mac، ثم قم بتثبيت Aspose Cells من خلال NuGet:
- قم بتشغيل الاختبار باستخدام الكود التالي:
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"); - إذا كنت بحاجة إلى استخدام ميزات تتعلق بالرسومات، يرجى تثبيت libgdiplus في نظام التشغيل macOS، انظر: كيفية تثبيت libgdiplus في نظام التشغيل macOS
ملاحظة: Aspose.Cells لـ .NetStandard يمكن أن تدعم متطلباتك على نظام التشغيل macOS.
ينطبق على: NetStandard2.0، NetCore2.1، NetCore3.1، Net5.0، Net6.0 والإصدار المتقدم.
Run Aspose Cells in Docker
كيفية استخدام مكتبة الرسومات على منصات غير ويندوز مع Net6
يستخدم Aspose.Cells for Net6 الآن SkiaSharp كمكتبة الرسومات، كما هو موصى به في بيان رسمي من مايكروسوفت. لمزيد من التفاصيل حول استخدام Aspose.Cells مع NET6، يرجى الاطلاع على كيفية تشغيل Aspose.Cells لـ .Net6.
إنشاء تطبيق مرحبًا بالعالم
تقوم الخطوات التالية بإنشاء تطبيق مرحبًا بالعالم باستخدام واجهة برمجة التطبيقات لـ Aspose.Cells:
- إذا كان لديك ترخيص، ثم قم بتطبيقه. إذا كنت تستخدم النسخة التجريبية، فتخطى خطوط الكود المتعلقة بالترخيص.
- إنشاء مثيل من فئة Workbook لإنشاء ملف إكسل جديد، أو فتح ملف إكسل موجود. ١. الوصول إلى أي خلية مرغوبة في ورقة العمل في ملف إكسل.
- إدراج كلمات Hello World! في الخلية التي تم الوصول إليها.
- إنشاء ملف Microsoft Excel المعدل.
يتم توضيح تنفيذ الخطوات أعلاه في الأمثلة أدناه.
مثال على الشفرة: إنشاء مصنف جديد
يُنشئ المثال التالي مصنفًا جديدًا من البداية، يدرج “مرحبا بالعالم!” في الخلية A1 في الصفحة العمل الأولى، ويحفظ كملف Excel.
// 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"); |
مثال على الشفرة: فتح ملف موجود
يُفتح المثال التالي ملف قالب Microsoft Excel موجود “Sample.xlsx”، يدرج “مرحبا بالعالم!” في الخلية A1 في الصفحة العمل الأولى، ويحفظ كملف Excel.
// 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(); |