To insert data into Excel file from datatable using C# .Net

Posted on 2005-04-06
Last Modified: 2010-07-27
LAYER: Domain
CLASS: ViewStatisticsManager            
MESSAGE: An unknown exception occured in Domain. jp Access is denied.
at System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(RuntimeType objectType)
   at System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(Type objectType)
   at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(Type serverType)

This is the error and it is coming at line which looks like this:
 " objExcel = new Excel.ApplicationClass(); "

I hv MS Excel 11.0 Object Library(MS Office 2003) & OS : MS 2000 Prof.

My task is : To insert data into Excel file from datatable.

This is very urgent need....plzzzzzz reply to this as early as possible
waiting for reply....

Thanking u in anticipation......

Question by:ketanghole
    LVL 14

    Expert Comment

    by:Thandava Vallepalli

    Alternate is create new excel file using C# code....

    send that file path to  below query... the query will insert the data into the excel automatically without creating excel object...

    INSERT INTO OPENROWSET ('Microsoft.Jet.OleDB.4.0', 'EXCEL 8.0;Database=f:\Book1.xls', Sheet1$ ) (C1, C2)

    run this query using   command.NonQueryExceute( ) metbod.....

    LVL 14

    Accepted Solution

    Running office applications from is not supported by MS, and this KB
    article tries to explain why:;EN-US;q257757



    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
    Article by: Najam
    Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now