?
Solved

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

Posted on 2013-10-24
5
Medium Priority
?
72 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 70

Accepted Solution

by:
Éric Moreau earned 1500 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 70

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 70

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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses
Course of the Month15 days, 2 hours left to enroll

840 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