LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

ExcelRpt_SetCellValue function to write to multiple cells

I'm not sure how to use the ExcelRpt_SetCellValue function to write to more than 1 cell at a time. The function panel specifies that a cell range can be selected so I presume that data can be written to more than 1 cell.
Hope you can help.
Cheers, Sandro
0 Kudos
Message 1 of 6
(4,198 Views)
Hi,
the function call only writes to one cell. Even though it takes a range, the help for the range says the following :
The range of an individual cell. This value should be a string containing the cell range, such as "A1". If the range contains multiple cells, this function will examine the uppper leftmost cell in the range.
Instead, try the
ExcelRpt_WriteData (, "", ExRConst_dataDouble, , , );
function, which will take an array of 2D data (right click on items in the function panel for more information on what each parameter needs to take in.
(Function can be found under Excel Report->Cell Range->Write Data)

Hope that helps
Sacha Emery
National Instruments (UK)
// it takes almost no time to rate an answer Smiley Wink
Message 2 of 6
(4,134 Views)
Thanks!
0 Kudos
Message 3 of 6
(4,128 Views)
Hi, was trying the ExcelRpt_writeData function but can't seem to get it working.
After starting an excel application, workbook,.. etc
I write: EXcelRpt_WriteData(worksheetHandle, "A1:A2", ExRConst_dataDouble, 1, 2, data)
where data = {100,101}
I keep getting runtime errors Could you show me an example please.
Thanks, sandro
0 Kudos
Message 4 of 6
(4,130 Views)
Hi,
what are the runtime errors???
I have Windows XP, CVI 7.1 and according to the help->about Excel 2002 sp-1.
I've pasted in below an example which works for me (note the order of the rows versus columns - Dealing in one column, so that's 2,1 for the dimension sizes:

#include
#include "excelreport.h"

int main (int argc, char *argv[])
{
CAObjHandle HdlWorkbook;
CAObjHandle HdlXLApp;
CAObjHandle HdlWorksheet;
double data[2] = {200,2354.25898};

if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */

// Open Excel and make it visible
ExcelRpt_ApplicationNew (VTRUE, &HdlXLApp);
// Get a New workbook
ExcelRpt_WorkbookNew (HdlXLApp, &HdlWorkbook);
// Get the first worksheet (could get by name here if necessary
ExcelRpt_GetWorksheetFromIndex (HdlWorkbook, 1, &HdlWorksheet);

// put a breakpoint in here
ExcelRpt_WriteData (HdlWorksheet, "A1:A2", ExRConst_dataDouble, 2, 1,
data);
// close workbook
ExcelRpt_WorkbookClose (HdlWorkbook, 0);
// Quit Application
ExcelRpt_ApplicationQuit (HdlXLApp);

// tidy up memory space

CA_DiscardObjHandle(HdlWorksheet);
CA_DiscardObjHandle(HdlWorkbook);
CA_DiscardObjHandle(HdlXLApp);
return 0;
}


Hope that helps
Thanks
Sacha.
// it takes almost no time to rate an answer Smiley Wink
Message 5 of 6
(4,116 Views)
Used your method and all was good! Think I was going wrong with the datatype.
Thank you very much for your help,
Sandro
0 Kudos
Message 6 of 6
(4,112 Views)