البحث عن البيانات أو البحث عنها
Contents
[
Hide
]
البحث عن البيانات أو البحث عنها
يمكنك استخدام Aspose.Cells للبحث عن البيانات أو البحث عنها بعدة طرق باستخدام الطريقة التالية. هذه الطرق تجد البيانات حسب أسمائها.
- FindNumber
- FindFormula
- FindFormula يحتوي على
- FindString
- FindStringContains
- FindStringStartsWith
- FindStringEndsWith
يوضح نموذج التعليمات البرمجية التالي استخدام الأساليب المذكورة أعلاه باستخدامنموذج ملف اكسل كما هو موضح في لقطة الشاشة هذه.
عينة من الرموز
This file contains hidden or 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-C | |
//Path of input excel file | |
StringPtr sampleFindOrSearchData = dirPath->StringAppend(new String("sampleFindOrSearchData.xlsx")); | |
//Load sample excel file into a workbook object | |
intrusive_ptr<IWorkbook> wb = Factory::CreateIWorkbook(sampleFindOrSearchData); | |
//Get first worksheet of the workbook | |
intrusive_ptr<IWorksheet> ws = wb->GetIWorksheets()->GetObjectByIndex(0); | |
//Finding the cell containing the number 80 | |
intrusive_ptr<ICell> cell = ws->GetICells()->FindNumber(80, NULL); | |
//Printing the name of the cell found after searching worksheet | |
StringPtr str1 = new String(L"Name of the cell containing the number 80: "); | |
Console::WriteLine(str1->StringAppend(cell->GetName())); | |
//Finding the cell containing the specified formula | |
cell = ws->GetICells()->FindFormula(new String("=SUM(A5:A10)"), NULL); | |
//Printing the name of the cell found after searching worksheet | |
StringPtr str2 = new String(L"Name of the cell containing formula =SUM(A5:A10): "); | |
Console::WriteLine(str2->StringAppend(cell->GetName())); | |
//Finding the cell containing the formula that contains CHA | |
cell = ws->GetICells()->FindFormulaContains(new String("CHA"), NULL); | |
//Printing the name of the cell found after searching worksheet | |
StringPtr str3 = new String(L"Name of the cell containing the formula that contains CHA: "); | |
Console::WriteLine(str3->StringAppend(cell->GetName())); | |
//Finding the cell containing the specified string | |
cell = ws->GetICells()->FindString(new String("SampleData"), NULL); | |
//Printing the name of the cell found after searching worksheet | |
StringPtr str4 = new String(L"Name of the cell containing specified string: "); | |
Console::WriteLine(str4->StringAppend(cell->GetName())); | |
//Finding the cell containing the string that contains Two | |
cell = ws->GetICells()->FindStringContains(new String("Two"), NULL); | |
//Printing the name of the cell found after searching worksheet | |
StringPtr str5 = new String(L"Name of the cell containing the string that contains Two: "); | |
Console::WriteLine(str5->StringAppend(cell->GetName())); | |
//Finding the cell containing the string that starts with AAA | |
cell = ws->GetICells()->FindStringStartsWith(new String("AAA"), NULL); | |
//Printing the name of the cell found after searching worksheet | |
StringPtr str6 = new String(L"Name of the cell containing the string that starts with AAA: "); | |
Console::WriteLine(str6->StringAppend(cell->GetName())); | |
//Finding the cell containing the string that ends with BBB | |
cell = ws->GetICells()->FindStringEndsWith(new String("BBB"), NULL); | |
//Printing the name of the cell found after searching worksheet | |
StringPtr str7 = new String(L"Name of the cell containing the string that ends with BBB: "); | |
Console::WriteLine(str7->StringAppend(cell->GetName())); |
إخراج وحدة التحكم
هذا هو إخراج وحدة التحكم لنموذج التعليمات البرمجية أعلاه عند تنفيذه مع المعطىنموذج ملف اكسل.
Name of the cell containing the number 80: A8
Name of the cell containing formula =SUM(A5:A10): C6
Name of the cell containing the formula that contains CHA: C7
Name of the cell containing specified string: C8
Name of the cell containing the string that contains Two: C9
Name of the cell containing the string that starts with AAA: C10
Name of the cell containing the string that ends with BBB: C11