Main Topics
Browse All TopicsException Details: System.Runtime.InteropServ
Source Error:
Line 32: xlApp.Visible = true;
Line 33: string strFileName = sFileName;
Line 34: Excel.Workbook xlWB = xlApp.Workbooks.Open("Exce
Line 35: null,
Line 36: null,
Source File: c:\inetpub\wwwroot\webappl
Code:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls
using System.Diagnostics;
using System.Reflection;
using Excel= Microsoft.Office.Interop.E
using System.Data.OleDb;
using System.IO;
using System.Text;
using System.Runtime.InteropServ
namespace WebApplication1
{
/// <summary>
/// Summary description for WebForm2.
/// </summary>
public class WebForm2 : System.Web.UI.Page
{
protected Excel.Application xlApp;
protected Excel.Workbook xlWB1;
private void searchExcelSpreadSheet(str
{
Excel.Application xlApp = new Excel.Application();
xlApp.Visible = true;
string strFileName = sFileName;
Excel.Workbook xlWB = xlApp.Workbooks.Open("Exce
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null);
Excel.Worksheet xls = (Excel.Worksheet)xlWB.Shee
int intRows, intCols, r, c;
intRows = xls.UsedRange.Rows.Count;
intCols = xls.UsedRange.Columns.Coun
for(r = 1; r < intRows; r++)
{
for(c=1; c < intCols; c++)
{
string text = (string)((Excel.Range)xls.
Response.Write (text+"<br>");
}
}
xlWB.Close(false, null, null);
xlApp.Quit();
xls = null;
xlWB = null;
xlApp = null;
}
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
searchExcelSpreadSheet ("\\Excel\\ExcelData.xls")
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.P
}
#endregion
}
}
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: prakash_prkPosted on 2005-01-10 at 02:06:42ID: 13001375
Instead of null pass System.Reflection.Missing. Value to the workbooks.open function..
regards
prakash