sunil adhyaru
2009-11-09 10:00:39 UTC
Hi ,
I am reading range from excel in one of my function . The code I have
written is working in excel 2003 and version below it . But the same
code is not working excel 2007 . It is giving me value "0.000" in all
the cells of the range selected.
I am using excel sdk
following is the code I have written.
LPXLOPER __stdcall setOrcInstrument(int field1,LPSTR field2, LPSTR
field2, LPSTR field3, LPSTR field5, LPXLOPER fieldNameRange)
{
CArray<char* , char*> fieldNameArray;
if(fieldNameRange->xltype == xltypeMulti )
{
int nCellCountName = fieldNameRange->val.array.rows *
fieldNameRange->val.array.columns;
char* pTemp = new char[255];
sprintf(pTemp,"cell count name %d",nCellCountName);
//objLog->Log(pTemp);
AfxMessageBox(pTemp);
if(fieldNameRange->val.array.columns > 1 && fieldNameRange-
return NULL;
}
for (int i=1;i<=nCellCountName;i++)
{
if(fieldNameRange[i].xltype == xltypeStr)
{
char *cellValue = new char[255];
int len = fieldNameRange[i].val.str[0];
cellValue[0] = '|';
for(int k = 1; k<=len; k++)
{
cellValue[k] = fieldNameRange[i].val.str[k];
}
cellValue[len+1] = '\0';
//objLog->Log(cellValue);
fieldNameArray.Add(cellValue);
//AfxMessageBox(ansiValue[0]);
//free(ansiValue);
}
else if(fieldNameRange[i].xltype == xltypeNum)
{
char *pTemp = new char[255];
sprintf(pTemp,"|%f\0",fieldNameRange[i].val.num);
//objLog->Log(pTemp);
fieldNameArray.Add(pTemp);
}
else if(fieldNameRange[i].xltype == xltypeNil)
{
fieldNameArray.Add("| ");
}
}
}
}
with registration using
{" setOrcInstrument", " RICCCCP#", " setOrcInstrument", "
field1,field2, field3, field4, field5, FieldNameRange, " 1", " TI_OQL
Functions", " ", " TI_OQL.HLP!1017", " This function Inserts/Modifies
an instrument in ORC and returns its Tag."," "},
I am reading range from excel in one of my function . The code I have
written is working in excel 2003 and version below it . But the same
code is not working excel 2007 . It is giving me value "0.000" in all
the cells of the range selected.
I am using excel sdk
following is the code I have written.
LPXLOPER __stdcall setOrcInstrument(int field1,LPSTR field2, LPSTR
field2, LPSTR field3, LPSTR field5, LPXLOPER fieldNameRange)
{
CArray<char* , char*> fieldNameArray;
if(fieldNameRange->xltype == xltypeMulti )
{
int nCellCountName = fieldNameRange->val.array.rows *
fieldNameRange->val.array.columns;
char* pTemp = new char[255];
sprintf(pTemp,"cell count name %d",nCellCountName);
//objLog->Log(pTemp);
AfxMessageBox(pTemp);
if(fieldNameRange->val.array.columns > 1 && fieldNameRange-
val.array.rows > 1) // check for exactly 4 columns
{return NULL;
}
for (int i=1;i<=nCellCountName;i++)
{
if(fieldNameRange[i].xltype == xltypeStr)
{
char *cellValue = new char[255];
int len = fieldNameRange[i].val.str[0];
cellValue[0] = '|';
for(int k = 1; k<=len; k++)
{
cellValue[k] = fieldNameRange[i].val.str[k];
}
cellValue[len+1] = '\0';
//objLog->Log(cellValue);
fieldNameArray.Add(cellValue);
//AfxMessageBox(ansiValue[0]);
//free(ansiValue);
}
else if(fieldNameRange[i].xltype == xltypeNum)
{
char *pTemp = new char[255];
sprintf(pTemp,"|%f\0",fieldNameRange[i].val.num);
//objLog->Log(pTemp);
fieldNameArray.Add(pTemp);
}
else if(fieldNameRange[i].xltype == xltypeNil)
{
fieldNameArray.Add("| ");
}
}
}
}
with registration using
{" setOrcInstrument", " RICCCCP#", " setOrcInstrument", "
field1,field2, field3, field4, field5, FieldNameRange, " 1", " TI_OQL
Functions", " ", " TI_OQL.HLP!1017", " This function Inserts/Modifies
an instrument in ORC and returns its Tag."," "},