Member 13134207 Ответов: 0

Запись значений в конкретную ячейку excel, где установлен флаг при перемещении данных с внешнего листа ...C#


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 ???


Что я уже пробовал:

<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;

Richard MacCutchan

Вам нужно получить объект диапазона, который ссылается на фактическую ячейку, в которой вы хотите хранить данные. Описание типа диапазона см. В документации.

0 Ответов