lpDisp=books. The Open (strFilePath, covOptional, covOptional,
CovOptional, covOptional, covOptional, covOptional, covOptional,
CovOptional, covOptional, covOptional, covOptional, covOptional,
CovOptional, covOptional);
Book. AttachDispatch (lpDisp);
Sheets. AttachDispatch (book. Get_Worksheets ());
//sheet=sheets. Get_Item (COleVariant ((short) 1));
LpDisp=book. Get_ActiveSheet ();
Sheet. AttachDispatch (lpDisp);
Range. AttachDispatch (sheet. Get_Cells (), TRUE);
If (FUTUREa==0 & amp; & Var1! {
=L "")for (int i=0; I & lt; 1000; I++) {
Range. AttachDispatch (range. Get_Item (COleVariant ((long) I + 1), COleVariant ((long) varr1)). PdispVal);//the first variable is the line, the second variable is the column of
VResult=range. Get_Value2 ();
If (vResult. N==VT_BSTR)//string
{
Str1 [I]=vResult. BstrVal;
}
Else if (vResult. N==VT_R8 | | vResult. N==VT_R4)//8 | | digital 4 bytes
{
Str1 [I]. The Format (_T (" % f "), vResult. DblVal);
}
Else if (vResult. N==VT_I4) {
Str1 [I]. The Format (_T (" % d "), vResult. DblVal);
}
If (str1 [I]==L "" | | str1==" "[I]) {
FUTUREa=1;
J=I - 1;
break;
}
SetDlgItemText (IDC_EDIT7, str1 [I]);
}
}
If (FUTUREa==1 & amp; & Var2! {
=L "")for (int i=0; I & lt; 1000; I++) {
Range. AttachDispatch (range. Get_Item (COleVariant ((long) I + 1), COleVariant ((long) varr2)). PdispVal);//the first variable is the line, the second variable is the column of
VResult=range. Get_Value2 ();
If (vResult. N==VT_BSTR)//string
{
Str2 [I]=vResult. BstrVal;
}
Else if (vResult. N==VT_R8)//8 byte number
{
Str2 [I]. The Format (_T (" % f "), vResult. DblVal);
}
If (str2 [I]==L "" | | str2 [I]==" ") {
FUTUREa +=1;
break;
}
}
}
This is two loops are used to read the contents of the first column and the second column, but when I after the program is running, the str1 array only [the first round, one, three, six] being read to, and str2 array is empty, all the second column did not read all
CodePudding user response:
Range. AttachDispatch (range. Get_Item (COleVariant ((long) I + 1), COleVariant ((long) varr1)). PdispVal);In front of the chosen after the execution unit is useless
With a new unit,
Range2. AttachDispatch (range. Get_Item (COleVariant ((long) I + 1), COleVariant ((long) varr1)). PdispVal);
CodePudding user response: