Compare Data in Two Worksheets


Version Info

Minimum Origin Version Required: Origin 8 SR0


This example shows how to compare the data in two worksheets if full match.

static void _get_all_data_from_wks(Worksheet& wks, vector& vec)
        foreach(Column col in wks.Columns)
                vector& vecCol = col.GetDataObject();

bool compare_worksheet_data(Worksheet& wks1, Worksheet& wks2, double dTolerance = 1e-10)
        if( wks1.GetNumRows() != wks2.GetNumRows() || wks1.GetNumCols() != wks2.GetNumCols() )
                return false;
        vector vec1, vec2;
        _get_all_data_from_wks(wks1, vec1);
        _get_all_data_from_wks(wks2, vec2);   
        if( vec1.GetSize() != vec2.GetSize() )
                return false;
        bool bIsSame;
        int nn = ocmath_compare_data(vec1.GetSize(), vec1, vec2, &bIsSame, dTolerance);
        return bIsSame;