01-21-2011 03:10 AM
01-24-2011 08:08 PM
Kumar,
I modified part of the example "excel2000demo.c" shipped with CVI to realize what you wanted.
Assuming you've done this part already in your code
static ExcelObj_Workbooks ExcelWorkbooksHandle = 0;
static VARIANT MyCellRangeV;
....
.... (open Excel and activate an Excel worksheet ...)
CA_VariantSetCString (&MyCellRangeV, "A2:H11");
1) To set the text alignment in a range of cells:
Excel_WorksheetRange (ExcelWorksheetHandle, NULL, MyCellRangeV, CA_DEFAULT_VAL, &ExcelRangeHandle);
Excel_RangeActivate (ExcelRangeHandle, &ErrorInfo, NULL);
Excel_SetProperty (ExcelRangeHandle, &ErrorInfo, Excel_RangeHorizontalAlignment, CAVT_INT, ExcelConst_xlHAlignRight);
Excel_SetProperty (ExcelRangeHandle, &ErrorInfo, Excel_RangeVerticalAlignment, CAVT_INT, ExcelConst_xlVAlignCenter);
2) To set the background color of a range of cells:
CAObjHandle rangeInteriorHandle = 0 ;
Excel_GetProperty (ExcelRangeHandle, &ErrorInfo, Excel_RangeInterior, CAVT_OBJHANDLE, &rangeInteriorHandle);
Excel_SetProperty (rangeInteriorHandle, &ErrorInfo, Excel_InteriorColor, CAVT_INT, 0x00FFFF); // yellow background
// Note: 0xFF0000=Blue, 0x00FF00=Green, 0x0000FF=Red
These function calls work perfectly in my Excel 2003 version.
01-27-2011 11:01 PM
Hi dcl,
I am using functions exposed by CVI i.e.
ExcelRpt_SetCellRangeAttribute(gl_ExcelWorksheetHandle,s_RangeValue,ER_CR_ATTR_BGCOLOR,ptr_l_ColVal)
if I will use Excel_SetProperty,there is no help provided for these functions , so its very difficult to identify some parameters in this function
01-31-2011 05:09 PM
You're right. There's not much help one could find from NI except those example programs.
You need to go to Microsoft's web sites and search for the programming help on Excel using Visual Basic.
And, of course, trial and error.
03-14-2011 12:33 AM
Thanks every one I got the solution....
03-15-2011 08:24 AM
A Kumar:
If you found a solution different than what DCL9000 suggested, please post it. If DCL9000 answered your question, mark that answer as the solution.
Thanks!