Hämta cellvalidering i ODS filer med C++

Hämta cellvalidering i ODS-filer

Med Aspose.Cells for C++ kan du hämta den validering som är tillämpad på en cell i ODS-filer. API:et erbjuder metoden GetValidation i klassen Cell.

Följande kodexempel demonstrerar användningen av GetValidation-metoden genom att ladda filen source ODS och läsa valideringen av cell A9.

Exempelkod

#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;

int main()
{
    Aspose::Cells::Startup();

    // Source directory path
    U16String srcDir(u"..\\Data\\01_SourceDirectory\\");

    // Load source Excel file
    U16String inputFilePath = srcDir + u"SampleBook1.ods";
    Workbook workbook(inputFilePath);

    // Access first worksheet
    WorksheetCollection worksheets = workbook.GetWorksheets();
    Worksheet worksheet = worksheets.Get(0);

    // Access cell A9
    Cells cells = worksheet.GetCells();
    Cell cell = cells.Get(U16String(u"A9"));

    // Check validation existence
    Validation validation = cell.GetValidation();
    if (validation.IsNull() == false)
    {
        std::cout << "Validation type: " << static_cast<int>(validation.GetType()) << std::endl;
    }

    Aspose::Cells::Cleanup();
    return 0;
}