Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Member
97 Points
156 Posts
Jul 29, 2011 10:01 AM|LINK
Dear All,
I am using following code line for reading cell value from excel file, but when if the cell value is blank then its giving error, can anybody tell me how to resolve this issue ?
string strGetPhysicalCellValue = ((Microsoft.Office.Interop.Excel.Range)oWorkSheet.Cells[Row, intAnsValue]).Value2.ToString();
Error:
"'oWorkSheet.Cells' threw an exception of type 'System.Runtime.InteropServices.COMException' string "
For check the null value i tried if condition therefore also it's giving error,
if(((Microsoft.Office.Interop.Excel.Range)oWorkSheet.Cells[Row, intAnsValue]).Value2.ToString() != null )
{
strGetPhysicalCellValue = ((Microsoft.Office.Interop.Excel.Range)oWorkSheet.Cells[Row, intAnsValue]).Value2.ToString();
}
Thanks and Regard's
Harish Patil
hspatil
Member
97 Points
156 Posts
Error While read cell value from excel file.
Jul 29, 2011 10:01 AM|LINK
Dear All,
I am using following code line for reading cell value from excel file, but when if the cell value is blank then its giving error, can anybody tell me how to resolve this issue ?
string strGetPhysicalCellValue = ((Microsoft.Office.Interop.Excel.Range)oWorkSheet.Cells[Row, intAnsValue]).Value2.ToString();
Error:
"'oWorkSheet.Cells' threw an exception of type 'System.Runtime.InteropServices.COMException' string
"
For check the null value i tried if condition therefore also it's giving error,
if(((Microsoft.Office.Interop.Excel.Range)oWorkSheet.Cells[Row, intAnsValue]).Value2.ToString() != null )
{
strGetPhysicalCellValue = ((Microsoft.Office.Interop.Excel.Range)oWorkSheet.Cells[Row, intAnsValue]).Value2.ToString();
}
Thanks and Regard's
Harish Patil