system._comobject,while reading excel file
Posted: Tue Jul 15, 2014 9:32 am
Hi friends,when I am executing following script,the content read from the excel showing as system._comObject.
can anyonce help in this.....
xlRange.Cells[i,j].ToString());
when I googled it I got the solution as xlRange.Cells[i,j].value2.ToString());
but
value2 fun/method/command not showing in the popup that comes on putting dot after xlRange.Cells[i,j].
using System;
using System.Threading;
using System.Drawing;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using WinForms = System.Windows.Forms;
using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Reporting;
using Ranorex.Core.Testing;
using System.Windows.Forms;
using Office;
using Microsoft.Office.Interop.Excel;
namespace excelReadNDwrite
{
class Program
{
[STAThread]
public static void Main(string[] args)
{
Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;
Excel.Application xlApp = new Excel.Application();
Excel.Workbook xlWorkbook =xlApp.Workbooks.Open(@"E:\MyExcelTest\keywordDriven.xls");
Excel.Worksheet xlWorkSheet = (Excel.Worksheet)(xlWorkbook.Worksheets.get_Item(3));
Excel.Range xlRange = xlWorkSheet.UsedRange;
int rowCount = xlRange.Rows.Count;
int colCount = xlRange.Columns.Count;
MessageBox.Show(rowCount.ToString());
MessageBox.Show(colCount.ToString());
for (int i = 1; i <=3; i++)
{
for (int j = 1; j <= 3; j++)
{
MessageBox.Show(xlRange.Cells[i,j].ToString());
}
}
}
}
}
can anyonce help in this.....
xlRange.Cells[i,j].ToString());
when I googled it I got the solution as xlRange.Cells[i,j].value2.ToString());
but
value2 fun/method/command not showing in the popup that comes on putting dot after xlRange.Cells[i,j].
using System;
using System.Threading;
using System.Drawing;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using WinForms = System.Windows.Forms;
using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Reporting;
using Ranorex.Core.Testing;
using System.Windows.Forms;
using Office;
using Microsoft.Office.Interop.Excel;
namespace excelReadNDwrite
{
class Program
{
[STAThread]
public static void Main(string[] args)
{
Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;
Excel.Application xlApp = new Excel.Application();
Excel.Workbook xlWorkbook =xlApp.Workbooks.Open(@"E:\MyExcelTest\keywordDriven.xls");
Excel.Worksheet xlWorkSheet = (Excel.Worksheet)(xlWorkbook.Worksheets.get_Item(3));
Excel.Range xlRange = xlWorkSheet.UsedRange;
int rowCount = xlRange.Rows.Count;
int colCount = xlRange.Columns.Count;
MessageBox.Show(rowCount.ToString());
MessageBox.Show(colCount.ToString());
for (int i = 1; i <=3; i++)
{
for (int j = 1; j <= 3; j++)
{
MessageBox.Show(xlRange.Cells[i,j].ToString());
}
}
}
}
}