LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there anything wrong with ExcelRpt_SetCellRangeAttribute function?

Why cell A1 is the only cell being set to FONT BOLD with the following line (note that my active range is "A1:K500")?

error = ExcelRpt_SetCellRangeAttribute ExcelWorksheetHandle, "A1:C12", ER_CR_ATTR_FONT_BOLD, ExRConst_True);

I have tried many ways to be sure to get the range active and so, but the function does not seem to work properly.
0 Kudos
Message 1 of 4
(3,165 Views)
Dhemaius,

I ran a simple test program and I also had some trouble getting the SetCellRangeAttribute to change the attributes for any range of cells. I will make sure to pass this on for review and see if something could be done to fix it.

In the meantime, you might try calling the ExcelRpt_SetCellRangeAttribute function for every cell. It would be a little cumbersome, but it would get the job done right now.

If I find out anything more that would help change a range of cells, I will let you know.

Thanks for making us aware of this issue.

Shannon R.
Applications Engineer
National Instruments
Message 2 of 4
(3,165 Views)
Well, I have worked out some code into "ExcelRpt_SetCellRangeAttribute" function and it's working just fine with my application. The function with my code is in attachment
0 Kudos
Message 3 of 4
(3,165 Views)
This is a bug in the Excel Report instrument driver that will be fixed in the next CVI release. In the meantime, you can perform the fix yourself as follows:

Edit the excelreport.c source file to fix the problem. Change "cellHandle" to "rangeHandle" in the call that gets the font handle near the top of the function. Make the change as shown below:

__caErrChk (Excel_GetProperty (cellHandle, NULL, Excel_RangeFont, CAVT_OBJHANDLE, &FontHandle));

changes to this:

__caErrChk (Excel_GetProperty (rangeHandle, NULL, Excel_RangeFont, CAVT_OBJHANDLE, &FontHandle));

The code posted earlier will work fine, but the change as I've shown here has several benefits:

-It will work for all of the font attributes.
-It is more efficient in that it
only makes one ActiveX call to Excel for the entire range rather than one call per cell.
-It works for more complex ranges. ("A1:A5,B7:B10")
0 Kudos
Message 4 of 4
(3,165 Views)