Solved

Opening the Excel Workbook in share-point without installing the Excel libraries in the Server

Posted on 2013-10-24
5
48 Views
Last Modified: 2015-09-07
The logic goes here:-

There is a excel template file on the server. I read this file using code i.e C#, Excel is installed on my machine and all the things works fine. When using on the Production the same scenario, as excel is not installed the following error occurs which is attached. Kindly suggest me, to overcome this solution. How to overcome this solution without installing the EXCEL on server ?
Error.JPG
0
Comment
Question by:mu3tasem
  • 3
  • 2
5 Comments
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 39596708
0
 

Author Comment

by:mu3tasem
ID: 39596840
sqlcon.ConnectionString = ConfigurationManager.ConnectionStrings["IBTSMainString"].ConnectionString;
            this.sqlcmd = new SqlCommand("", this.sqlcon);
            this.sqlad = new SqlDataAdapter(this.sqlcmd);
            if (this.ds.Tables.Contains("Project.Master"))
            {
                this.ds.Tables["Project.Master"].Clear();
            }
            UserLoggedIn = strUserId;
            this.sqlcmd.CommandText = "Project.dbspRptMaster '" + this.UserLoggedIn + "'";
            this.sqlad.Fill(this.ds, "Project.Master");
            string filename = HttpRuntime.AppDomainAppPath + @"Reports\Contract Review.xls";
            Application application = new ApplicationClass()
            {
                AutomationSecurity = MsoAutomationSecurity.msoAutomationSecurityForceDisable
            };
             
            Workbook workbook = application.Workbooks.Open(filename, 2, false, Missing.Value, Missing.Value, Missing.Value, true, Missing.Value, Missing.Value, Missing.Value, true, Missing.Value, false, Missing.Value, Missing.Value);
            Worksheet worksheet = (Worksheet)workbook.Worksheets["Header"];
            Worksheet worksheet2 = (Worksheet)workbook.Worksheets["Items"];
            Worksheet worksheet3 = (Worksheet)workbook.Worksheets["Report"];
            Worksheet worksheet4 = (Worksheet)workbook.Worksheets["Mother Pipes Required"];
            int num = Convert.ToInt32(ProjId);


Error at Application Class
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 39596998
this code requires Excel to be installed. You cannot use it if you don't install it (which is not recommended on a server). This is why you should use something else like the 2 links I have provided.
0
 

Author Comment

by:mu3tasem
ID: 39603458
Mr. emoreau thanks for your comments. Is there any alternative other than that you refer above.
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 39603725
what kind of alternatives are you looking for? I provided a free one and a commercial one?
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

708 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

12 Experts available now in Live!

Get 1:1 Help Now