Friday, July 3, 2009

Cach chuoi voi while

//Lay tung sheet tu LimitedSheets="Sheet1*B:C,6:6?Sheet3*11:15"
bool checkStatus = false;

wstring strLimitedSheetsTemp = SysAllocString(LimitedSheets);
char* original = new char[strLimitedSheetsTemp.length() + 1];
wsprintfA(original, "%S", strLimitedSheetsTemp.c_str());

char *split1 = new char[1024];
int i = 0;
int j = 0;

while (original[i] != '\0')
{
if (original[i] == '?' || original[i] == '\0')
{
split1[j++] = '\0';

checkStatus = ExcelCheckLimitedCopyLevel2(split1, sheetName);
if (checkStatus) break;

delete [] split1;
split1 = new char[1024];
j=0;
}
else
{
split1[j++] = original[i];
}
i++;
}
if (original[i] == '\0')
{
split1[j++] = '\0';
checkStatus = ExcelCheckLimitedCopyLevel2(split1, sheetName);
}
//free memory
delete [] split1;

No comments: