ابدء
التركيب
قم بتثبيت 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 for .NET NuGet الحزمة
مزيد من الخطوات للحصول على التفاصيل
قم بتثبيت Aspose.Cells على الويندوز
- تنزيل Aspose.Cells.msi من الصفحة التالية: تنزيل Aspose.Cells.msi
- انقر نقرًا مزدوجًا فوق Aspose Cells msi واتبع التعليمات لتثبيته:
! [تثبيت Aspose Cells على windows] (install-on-windows.png)
مزيد من الخطوات للحصول على التفاصيل
قم بتثبيت Aspose.Cells على لينكس
في هذا المثال ، أستخدم Ubuntu لإظهار كيفية بدء استخدام Aspose.Cells على نظام Linux.
- قم بإنشاء تطبيق netcore ، باسم “AsposeCellsTest”.
- افتح الملف “AsposeCellsTest.csproj” ، أضف الأسطر التالية فيه للحصول على مراجع الحزمة Aspose.Cells:
<ItemGroup> <PackageReference Include="Aspose.Cells" Version="22.12" /> </ItemGroup>
- افتح المشروع باستخدام VSCode على Ubuntu: ! [تثبيت Aspose Cells على لينكس] (install-on-linux.png)
- قم بإجراء الاختبار باستخدام الكود التالي:
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 يمكنه دعم متطلباتك على نظام التشغيل Linux.
ينطبق على: NetStandard2.0 و NetCore2.1 و NetCore3.1 و Net5.0 و Net6.0 والإصدار المتقدم.
قم بتثبيت Aspose.Cells على MAC OS
في هذا المثال ، أستخدم macOS High Sierra لإظهار كيفية بدء استخدام Aspose.Cells على نظام تشغيل MAC.
- قم بإنشاء تطبيق netcore ، باسم “AsposeCellsTest”.
- افتح التطبيق باستخدام Visual Studio for Mac ، ثم قم بتثبيت Aspose Cells حتى NuGet: ! [تثبيت Aspose Cells على macOS] (install-on-mac-os.png)
- قم بإجراء الاختبار باستخدام الكود التالي:
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 يمكنه دعم متطلباتك على نظام تشغيل MAC.
ينطبق على: NetStandard2.0 و NetCore2.1 و NetCore3.1 و Net5.0 و Net6.0 والإصدار المتقدم.
[تشغيل Aspose Cells في Docker] (/ cells / net / how-to-run-aspose-cells-in-docker /)
كيفية استخدام مكتبة الرسومات على الأنظمة الأساسية التي لا تعمل بنظام Windows مع Net6
يستخدم Aspose.Cells لـ Net6 الآن SkiaSharp كمكتبة رسومات ، على النحو الموصى به فيبيان رسمي من Microsoft . لمزيد من التفاصيل حول استخدام Aspose.Cells مع NET6 ، يرجى مراجعةكيفية تشغيل Aspose.Cells لـ NET6.
إنشاء تطبيق Hello World
تؤدي الخطوات أدناه إلى إنشاء تطبيق Hello World باستخدام Aspose.Cells API:
- إذا كان لديك ترخيص ، إذنقم بتطبيقه. إذا كنت تستخدم الإصدار التقييمي ، فتخط سطور التعليمات البرمجية المتعلقة بالترخيص.
- قم بإنشاء مثيل لـدفتر العمل فئة لإنشاء ملف Excel جديد ، أو فتح ملف Excel موجود.
- قم بالوصول إلى أي خلية مرغوبة من ورقة العمل في ملف Excel.
- أدخل الكلماتHello World! في خلية تم الوصول إليها.
- قم بإنشاء ملف Excel Microsoft المعدل.
يتم توضيح تنفيذ الخطوات المذكورة أعلاه في الأمثلة أدناه.
نموذج التعليمات البرمجية: إنشاء مصنف جديد
يقوم المثال التالي بإنشاء مصنف جديد من البداية ، ويدرج “Hello World!” في الخلية 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"); |
نموذج التعليمات البرمجية: فتح ملف موجود
يفتح المثال التالي ملف قالب Excel Microsoft موجود “Sample.xlsx” ، ويدرج “Hello World!” في الخلية 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(); |