Reading Values from Excel

Posted by .Netlearner under C# on 11/23/2012 | Points: 10 | Views : 1178 | Status : [Member] | Replies : 7
Hello All,

Am Currently Converting a project from vb to C# in .NET.

I Got Struck With the Following Code while trying to read values of cell from the excel file.Can Anyone please shed some light on this issue .

sheet.Cells[i, 1].ToString()

where i has incremented value .

But Its not working.It returns just the Sys_Object value.




Responses

Posted by: Nkkppp on: 11/23/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

I am not aware of Vb though, below is a code translator.

Try below link

http://www.carlosag.net/Tools/CodeTranslator/


---Prathap

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Krv on: 11/23/2012 [Member] Starter | Points: 25

Up
0
Down
You can try the below one

sheet.Cells[i, 1].Value2

http://www.dotnetfunda.com/forums/thread5897-how-to-get-single-value-from-excel-sheet-using-csharp.aspx

Thanks,
R.Vasanth
MCTS(SQL Server & BI)
http://bigdatatech.blogspot.com

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: .Netlearner on: 11/24/2012 [Member] Starter | Points: 25

Up
0
Down

do
{
string value = "";
Range r = (Range)sheet.Cells[vExlTRow, 1];
value = r.Value2.ToString();
Range r1 = (Range)sheet.Cells[vExlTRow, 2];
string value1 = r1.Value.ToString();
if ((value != "") || (value1 != ""))
{

vExlTRow = vExlTRow + 1;
}
else
{
break;
}
} while (true);


I Want to Count the Total Number of rows in my excel file. I Have writtern the above code. If i have 5 rows in my excel its executing properly for the 5 times and when its becomes 6 Instead of return null value Its returning Sys_Object There by causes the error object reference.Kindly Guide me through this

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: .Netlearner on: 11/24/2012 [Member] Starter | Points: 25

Up
0
Down
Range rvCou = (Range)sheet.Cells[vExlRow, vCou];


Its not reading the NULL value.It causes the error can anyone please guide me.How to include null values while reading the excel file

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bageshkumarbagi on: 11/24/2012 [Member] Starter | Points: 25

Up
0
Down
hi
Try this
http://www.dotnetfunda.com/codes/code3340-reading-the-data-from-excel-sheet-in-aspnet.aspx

Thanks,
Bagesh Kumar Singh
Mark as answer if you have been satisfied

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 11/30/2012 [Member] Starter | Points: 25

Up
0
Down
http://sandeep-chourasia.blogspot.in/2012/04/read-excel.html

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bageshkumarbagi on: 12/3/2012 [Member] Starter | Points: 25

Up
0
Down
if you got your answer plz mark as answer.

Thanks,
Bagesh Kumar Singh
Mark as answer if you have been satisfied

.Netlearner, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response