Click here to Skip to main content
15,894,343 members

Comments by Member 13818561 (Top 10 by date)

Member 13818561 8-Jun-18 4:22am View    
I am getting this error.
System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)). at System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(RuntimeType objectType) at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(RuntimeType serverType) at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, Boolean bNewObj) at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at Project1.WebForm1.READExcel(String path)
Member 13818561 8-Jun-18 3:09am View    
Actually the problem is references are not published while publishing the asp.net project. So what should I do?
Member 13818561 8-Jun-18 2:29am View    
I used this code.
Microsoft.Office.Interop.Excel.Application objXL = null;

//Workbook refrence

Microsoft.Office.Interop.Excel.Workbook objWB = null;

//DataSet ds = new DataSet();

//try
//{

//Instancing Excel using COM services

objXL = new Microsoft.Office.Interop.Excel.Application();

//Adding WorkBook
objWB = objXL.Workbooks.Open(path);

foreach (Microsoft.Office.Interop.Excel.Worksheet objSHT in objWB.Worksheets)

int rows = objSHT.UsedRange.Rows.Count;
int cols = objSHT.UsedRange.Columns.Count;
DataTable dt = new DataTable();
int noofrow = 1;
//If 1st Row Contains unique Headers for datatable include this part else remove it

//Start
for (int c = 1; c <= cols; c++)
{
string colname = objSHT.Cells[1, c].Text;
dt.Columns.Add(colname);
noofrow = 2;
}
//END
for (int r = noofrow; r <= rows; r++)
{
DataRow dr = dt.NewRow();

for (int c = 1; c <= cols; c++)
{

dr[c - 1] = objSHT.Cells[r, c].Text;
}

dt.Rows.Add(dr);
}

ds.Tables.Add(dt);}
Member 13818561 8-Jun-18 2:26am View    
Sir I have a doubt,
I wanted to convert from excel to dataTable. It works fine. But after publishing my project rest of all page works fine. But only this page code is not working. please give me suggestions.
Member 13818561 28-May-18 3:20am View    
Thank You so much sir. It works for me.