Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use CNiexcel classes for contious logging using VC++

Currently i am using an array and store all the values to this array after that i write the array in to excel file. Any other way for continious logging?. I need to update the same excel file with continious rows. How can i get the last used Cell range?. So that i will continue writing on the same sheet.
 
Also while writing the excel file, Is it possible to open/copy the same file?  Is there any property for this ?
 
Please give a suggestion.
0 Kudos
Message 1 of 3
(6,917 Views)

Hi vels02,

You can get a hold of the used cells by using the CNiExcelWorksheet.UsedRange() function. This function will return a block of the used cells in the format of A1:B9. Hence, it's possible to know the first row and last row used in a block of data.

I was also able to continuously  append to an Excel worksheet simply by calling the CNiExcelWorksheet.GetRange() function with dynamic parameters. It seems that the Excel Automation does not give us the functionality to append to a file simply by using an "append" function. You must always have a specified range before sending the data to the Excel worksheet.

Also note that it's not necessary to send a matrix of data. You may use CNiExcelCellRange.SetCellValue() to send one value to a specific cell.

Attached is an example that demonstrates how to continuously append to a worksheet. I simply modified the example shipped with Measurement Studio. You are particularly interested in the function definition for CExcelReportDlg:: OnBnClickedButton3() under the ExelReportDlg.cpp file.

Nestor
0 Kudos
Message 2 of 3
(6,889 Views)
Hi Nester,
 
 
  Thank you so much. I am using these two funtions ( UsedRange()  and GetRange() ) to get and set the cell range if the same file is selected for logging again. Thanks much for your example.
 
 
Regards,
velu.
 
 
0 Kudos
Message 3 of 3
(6,866 Views)