Veri Bulma veya Arama
Contents
[
Hide
]
Veri Bulma veya Arama
Aşağıdaki yöntemi kullanarak Aspose.Cells kullanarak farklı şekillerde veri bulabilir veya arayabilirsiniz.
- GetEnumerator
- GetFormula
- GetType
- GetStringValue
- GetIntValue
- GetBoolValue
- GetDateTimeValue
- GetDoubleValue
- GetFloatValue
Daha fazla yöntemini görüntüle.
Aşağıdaki örnek kod, bu ekran görüntüsünde gösterildiği gibi örnek excel dosyasını kullanarak yukarıdaki yöntemlerin kullanımını anlatır.
Örnek Kod
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
Aspose::Cells::Startup(); | |
//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C | |
//Path of input | |
U16String dirPath(u""); | |
//Path of output | |
U16String outPath(u""); | |
//Path of input excel file | |
U16String sampleFindOrSearchData = testPath + u"sampleFindOrSearchData.xlsx"; | |
//Load sample excel file into a workbook object | |
Workbook wb(sampleFindOrSearchData); | |
//Get first worksheet of the workbook | |
Worksheet ws = wb.GetWorksheets().Get(0); | |
Enumerator<Cell> enCell = ws.GetCells().GetEnumerator(); | |
while (enCell.MoveNext()) | |
{ | |
Cell cell = enCell.GetCurrent(); | |
U16String fmlVal = cell.GetFormula(); | |
//Finding the cell containing the specified formula | |
if (!fmlVal.IsEmpty() && u"=SUM(A5:A10)" == cell.GetFormula()) | |
{ | |
//Printing the name of the cell found after searching worksheet | |
std::cout << "Name of the cell containing formula =SUM(A5:A10): " << cell.GetName().ToUtf8() << std::endl; | |
} | |
//Finding the cell containing the formula that contains CHA | |
else if (!fmlVal.IsEmpty() && cell.GetFormula().IndexOf(u"CHA") > -1) | |
{ | |
//Printing the name of the cell found after searching worksheet | |
std::cout << "Name of the cell containing the formula that contains CHA: " << cell.GetName().ToUtf8() << std::endl; | |
} | |
else | |
{ | |
switch (cell.GetType()) | |
{ | |
case CellValueType::IsString: | |
{ | |
U16String strVal = cell.GetStringValue(); | |
//Finding the cell containing the specified string | |
if (!strVal.IsEmpty() && cell.GetStringValue().IndexOf("SampleData") > -1) | |
{ | |
//Printing the name of the cell found after searching worksheet | |
std::cout << "Name of the cell containing specified string: " << cell.GetName().ToUtf8() << std::endl; | |
} | |
//Finding the cell containing the string that contains "Two" | |
else if (!strVal.IsEmpty() && cell.GetStringValue().IndexOf("Two") > -1) | |
{ | |
//Printing the name of the cell found after searching worksheet | |
std::cout << "Name of the cell containing the string that contains Two: " << cell.GetName().ToUtf8() << std::endl; | |
} | |
//Finding the cell containing the string that starts with AAA | |
else if (!strVal.IsEmpty() && cell.GetStringValue().IndexOf("AAA") == 0) | |
{ | |
//Printing the name of the cell found after searching worksheet | |
std::cout << "Name of the cell containing the string that starts with AAA: " << cell.GetName().ToUtf8() << std::endl; | |
} | |
//Finding the cell containing the string that ends with BBB | |
else if (!strVal.IsEmpty() && cell.GetStringValue().IndexOf("BBB") == cell.GetStringValue().GetLength() - 3) | |
{ | |
//Printing the name of the cell found after searching worksheet | |
std::cout << "Name of the cell containing the string that ends with BBB: " << cell.GetName().ToUtf8() << std::endl; | |
} | |
} | |
break; | |
//Finding the cell containing the number 80 | |
case CellValueType::IsNumeric: | |
{ | |
if (80 == cell.GetIntValue()) | |
{ | |
//Printing the name of the cell found after searching worksheet | |
std::cout << "Name of the cell containing the number 80: " << cell.GetName().ToUtf8() << std::endl; | |
} | |
} | |
break; | |
default: | |
break; | |
} | |
} | |
} | |
Aspose::Cells::Cleanup(); |
Konsol Çıktısı
Verilen örnek excel dosyası ile yukarıdaki örnek kodun konsol çıktısı.
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 the number 80: A8
Name of the cell containing specified string: C8
Name of the cell containing the string that contains Two: C9
Name of the cell containing specified string: C10
Name of the cell containing specified string: C11