Home » , » Excel / Office Automation issues in .net Globalization application with Fix

Excel / Office Automation issues in .net Globalization application with Fix

Written By M.L on வியாழன், 17 நவம்பர், 2011 | நவம்பர் 17, 2011

In one of our .net Globalization web applications catering to many geographies, uses the excel automation (using Microsoft.office.Interop). when some users in Nordic countries click on view spread sheet from .net web application, it was throwing up the below issue, which is very generic. And it is working well for other country instances.

System.NullReferenceException: Object reference not set to an instance of an object.
  at S6.DAL.DOCMGT.Cache.CACHE_ITEMSProcess.SetHiddenFieldsInExcelFile(String fileName, Int32 version) in W:\vs\S6.DOCMGT\DAL.DOCMGT\Cache\CACHE_ITEMSProcess.cs:line 774
 at S6.Web.UI.CMS.ViewExcel.ViewExcelFile(String _splitid) in C:\Inetpub\wwwroot\CMS_4\ViewExcel.aspx.cs:line 111
 at S6.DAL.DOCMGT.Cache.CACHE_ITEMSProcess.SetHiddenFieldsInExcelFile(String fileName, Int32 version) in W:\vs\S6.DOCMGT\DAL.DOCMGT\Cache\CACHE_ITEMSProcess.cs:line 774
  at S6.Web.UI.CMS.ViewExcel.ViewExcelFile(String _splitid) in C:\Inetpub\wwwroot\CMS_4\ViewExcel.aspx.cs:line 111

After having a trace in the respective excel method for each and every line, the following is the issue which is being traced for the excel object crash when the troubled users from Nordic countries are accessing the spread sheet from their machines. The reasons and actual issue which is causing the excel object crash is provided below along with its fix.

Issue:
            "Old format or invalid type library" error when automating Excel

Symptoms:
           Automating Microsoft Excel with Microsoft Visual Basic .NET, Microsoft Visual C# .NET, or Microsoft Visual C++, we may receive the above error when calling certain excel methods.

Root Cause:
            This error is received calling an Excel method under the following conditions:

          The method requires an LCID (locale identifier). We run an English version of Excel. However, the regional settings for the computer are configured for a non-English language.
          If the server computer runs the English version of Excel and the locale for the current user is configured for a language other than English, Excel will try to locate the language pack for the configured language. If the language pack is not found, the error is reported.

Solution / Fix:
            To fix this problem, you can use one of the following methods:

          Install the Multilingual User Interface Pack for your version of Office.
          Execute the Excel method or property by using InvokeMember so that you can specify the CultureInfo for the call. For example, the following code illustrates how you can invoke the Workbooks object Add method with "en-US" as the Culture Info

Hope, this information is useful and helps you in resolving any such excel / office automation issues in your .net applications.



Note :- Provide your coments by clicking below options :)

0 comments:

கருத்துரையிடுக

Popular Posts

General Category