Hi,
I am trying to write data into a particular cell in an excel. when i am looking into example program i felt bit difficult to understand.
i have wriiten code to read data from particular cell which works well. I am facing difficulties in writing data to cell. pls someone help.
// to read a data from cell which works
status = Excel_RangeGetItem (rangeHandle, NULL, CA_VariantInt (i+1), CA_VariantInt (j+1), &MyVariant);
// Get the DISPATCH pointer
status = CA_VariantGetDispatch (&MyVariant, &MyDispatch);
// Create a new Range Object from DISPATCH pointer
status = CA_CreateObjHandleFromIDispatch (MyDispatch, 0, &ExcelSingleCellRangeHandle);
// Get the value of the Single Cell Range
status = Excel_GetProperty (ExcelSingleCellRangeHandle, NULL, Excel_RangeValue2, CAVT_VARIANT, &MyVariant);
status= CA_VariantGetCString(&MyVariant,&val);
strcpy(cellvalue,val);
// to write data into a cell
status = Excel_RangeSetItem (rangeHandle, NULL, CA_VariantInt (i+1), CA_VariantInt (j+1), MyVariant);
status = CA_VariantSetDispatch (&MyVariant, &MyDispatch);
status = CA_CreateObjHandleFromIDispatch (MyDispatch, 0, &ExcelSingleCellRangeHandle);
status = Excel_SetProperty (ExcelSingleCellRangeHandle, NULL, Excel_RangeValue2, CAVT_VARIANT, &MyVariant);
status= CA_VariantSetCString(&MyVariant,writedata);
i know i am doing some mistake in the above code.