Click here to Skip to main content
15,879,184 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi guys, I have below code to generate excel sheet, its working fine in my local system and when im hosted in server its saying Object reference error, Can ny helpme out




C#
if (ds.Tables[0].Rows.Count > 0)
            {
                CreateExcelDoc exceldoc = new CreateExcelDoc();
                #region creates the main header

                exceldoc.createHeaders(2, 6, "NAME OF THE INST", "F1", "I1", 0, "", true, 15, "");
                exceldoc.createHeaders(3, 6, "LOCATION, LOCATION-521165,LOCATION District", "F2", "I2", 0, "", true, 10, "");

                
                   
                    exceldoc.addData(6, 6, ds.Tables[0].Rows[0]["1"].ToString(), "A" + 6 + "", "A" + 6 + "", "");
                    exceldoc.addData(6, 7, ds.Tables[0].Rows[0]["2"].ToString(), "A" + 6 + "", "A" + 6 + "", "");
                    exceldoc.addData(6, 8, ds.Tables[0].Rows[0]["3"].ToString(), "A" + 6 + "", "A" + 6 + "", "");
                    exceldoc.addData(6, 9, ds.Tables[0].Rows[0]["4"].ToString(), "A" + 6 + "", "A" + 6 + "", "");

                    exceldoc.addData(10, 6, "Name", "A" + 6 + "", "A" + 6 + "", "");
                    exceldoc.addData(10, 7, "Marks", "A" + 6 + "", "A" + 6 + "", "");
                    
                    if (ds.Tables[0].Rows.Count > 0)
                               {
                                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                                   {
                                       exceldoc.addData(i + 11, 6, ds.Tables[0].Rows[i]["5"].ToString(), "A" + (i + 11), "A" + (i + 11), "");
                                       exceldoc.addData(i + 11, 7, ds.Tables[0].Rows[i]["6"].ToString(), "A" + (i + 11), "A" + (i + 11), "");
                                       

                                   }
                               }
              
                exceldoc.app.Visible = true;

                #endregion
            }
Posted
Updated 22-Apr-13 22:24pm
v2
Comments
Sergey Alexandrovich Kryukov 23-Apr-13 1:17am    
Sorry, this is not a question.
—SA
arindamrudra 23-Apr-13 2:49am    
Can you please check in your server there is proper link for CreateExcelDoc is available or not?
Shashi226 23-Apr-13 3:00am    
where to check
AmitGajjar 23-Apr-13 4:35am    
on which line you got object reference exception ?
Shashi226 23-Apr-13 4:37am    
hey itz cmg on local
i think on client system with the below line im getting error

exceldoc.app.Visible = true;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900