Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am testing api on UFT api and have done data driven using gui layer on top of api layer that means I have external datasheet sending the values. I have used custom code to get the xml node values. however i need to write this values in excel. I have the script but i dont know how to write this values in the column "Name" on the 10th row where Flag will be set to "Y". First column header is "Flag" and 10th row has "Y" so I want to write value in cell which is in 10th row under the column header "Name"

Flag col1 col2 .... Name . . . . Y ???


What I have tried:

C#
<pre>
    Microsoft.Office.Interop.Excel.Application oXL = null;
    Microsoft.Office.Interop.Excel._Workbook oWB = null;
    Microsoft.Office.Interop.Excel._Worksheet oSheet = null;


    oXL = new Microsoft.Office.Interop.Excel.Application();
    oWB = oXL.Workbooks.Open("path of excelsheet.xlsx");
    oSheet = (Microsoft.Office.Interop.Excel._Worksheet)oWB.ActiveSheet;


//some code to get xml node values
disGPre = dpNode["ns2:node1"].InnerText;
var disGPre1 = Convert.ToDecimal(disGPre);


// here I am trying to write the value using row index and column index but     this isnt the correct snippet. I need to get the correct one. Pls assist.  With this snippet, data is written in the correct column but in the first row of the sheet.

oSheet.Cells[this.Loop2.CurrentIterationNumber,39] = disGPre1;
Posted
Comments
Richard MacCutchan 26-Apr-17 3:58am    
You need to get a Range object that refers to the actual cell where you want to store the data. See the documentation for a description of the Range type.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900