نمایش نتایج 1 تا 3 از 3

نام تاپیک: خطای HRESULT در هنگام انتقال اطلاعات دیتا گرید به اکسل

  1. #1

    Question خطای HRESULT در هنگام انتقال اطلاعات دیتا گرید به اکسل

    با سلام
    من با استفاده از کتابخانه Microsoft.Office.Interop.Excel در C#‎ می خوام اطلاعات دیتا گرید ویو رو به اکسل انتقال بدم . وقتی تعداد ستون های اطلاعات (فیلدها) کمه مشکلی پیش نمیاد ولی وقتی تعداد ستون ها اضافه می شه با این خطا مواجه می شم :

    System.Runtime.InteropServices.COMException was unhandled by user code
    HResult=-2146827284
    Message=Exception from HRESULT: 0x800A03EC
    Source=""
    ErrorCode=-2146827284
    StackTrace:
    at System.RuntimeType.ForwardCallToInvokeMember(Strin g memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
    at Microsoft.Office.Interop.Excel.Range.set_Value(Obj ect RangeValueDataType, Object value)
    at ImportValidation.ThisAddIn.removeAnySpaces(Int32 x, Int32 y) in c:\Users\dshevelev\Documents\Visual Studio 2012\Projects\ImportValidation\ImportValidation\Th isAddIn.cs:line 354
    at ImportValidation.ThisAddIn.ReadHeaders(Hashtable columnAddress) in c:\Users\dshevelev\Documents\Visual Studio 2012\Projects\ImportValidation\ImportValidation\Th isAddIn.cs:line 123
    at ImportValidation.ThisAddIn.mapColumns() in c:\Users\dshevelev\Documents\Visual Studio 2012\Projects\ImportValidation\ImportValidation\Th isAddIn.cs:line 493
    at ImportValidation.Ribbon1.button6_Click(Object sender, RibbonControlEventArgs e) in c:\Users\dshevelev\Documents\Visual Studio 2012\Projects\ImportValidation\ImportValidation\Ri bbon1.cs:line 55
    at Microsoft.Office.Tools.Ribbon.RibbonPropertyStorag e.ControlActionRaise(IRibbonControl control)
    at Microsoft.Office.Tools.Ribbon.RibbonPropertyStorag e.ButtonClickCallback(RibbonComponentImpl component, Object[] args)
    at Microsoft.Office.Tools.Ribbon.RibbonManagerImpl.In voke(RibbonComponentCallback callback, Object[] args)
    at Microsoft.Office.Tools.Ribbon.RibbonMethodInfo.Inv oke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    at Microsoft.Office.Tools.Ribbon.RibbonManagerImpl.Sy stem.Reflection.IReflect.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters)
    InnerException:


    لطفا کمکم کنید . خیلی مهمه برام

  2. #2
    مدیر بخش آواتار مهرداد صفا
    تاریخ عضویت
    تیر 1391
    محل زندگی
    select Country,City From World where Country.Name=IRAN and City.Contains(حضرت معصومه(ع))
    پست
    1,499

    نقل قول: خطای HRESULT در هنگام انتقال اطلاعات دیتا گرید به اکسل

    سلام.
    If you automate Microsoft Excel with Microsoft Visual Basic .NET, Microsoft Visual C#‎ .NET, or Microsoft Visual C++‎, you may receive the following errors when calling certain methods because the machine has the locale set to something other than US English (locale ID or LCID 1033):
    Exception from HRESULT: 0x800A03EC
    and/or
    Old format or invalid type library
    SOLUTION 1:

    To get around this error you can set CurrentCulture to en-US when executing code related to Excel and reset back to your originale by using these 2 functions.
    //declare a variable to hold the CurrentCulture
    System.Globalization.CultureInfo oldCI;
    //get the old CurrenCulture and set the new, en-US
    void SetNewCurrentCulture()
    {
    oldCI = System.Threading.Thread.CurrentThread.CurrentCultu re;
    System.Threading.Thread.CurrentThread.CurrentCultu re = new System.Globalization.CultureInfo("en-US");
    }
    //reset Current Culture back to the originale
    void ResetCurrentCulture()
    {
    System.Threading.Thread.CurrentThread.CurrentCultu re = oldCI;
    }
    SOLUTION 2:

    Another solution that could work, create a 1033 directory under Microsoft Office\Office11 (or your corresponding office-version), copy excel.exe to the 1033 directory, and rename it to xllex.dll.
    Although you might solve the problem using one off these solutions, when you call the Excel object model in locales other than US English, the Excel object model can act differently and your code can fail in ways you may not have thought of. For example, you might have code that sets the value of a range to a date:
    yourRange.Value2 = "10/10/09"
    Depending on the locale this code can act differently resulting in Excel putting into the range any of the following values:
    October 10, 2009 September 10, 2009 October 9, 201
    http://www.made4dotnet.com/Default.a...bid=141&aid=15
    چشم ظاهر گر نبیند عیب نیست چشم دل گر ننگرد باید گریست
    **********
    اَلسَّلامُ عَلَى الْحُسَيْنِ وَ عَلى عَلِىِّ بْنِ الْحُسَيْنِ وَ عَلى اَوْلادِ الْحُسَيْنِ وَ عَلى اَصْحابِ الْحُسَيْنِ

  3. #3

    نقل قول: خطای HRESULT در هنگام انتقال اطلاعات دیتا گرید به اکسل

    با سلام و خسته نباشید من موقع انتقال اطلاعات از data grid به اکسل Untitled.jpg این خطا می ده لطفا کمکم کنید ممنون میشم

تاپیک های مشابه

  1. سوال: نحوه ی انتقال اطلاعات دیتا گرید ویو به فایل PDF
    نوشته شده توسط 09178525592 در بخش C#‎‎
    پاسخ: 3
    آخرین پست: چهارشنبه 25 اردیبهشت 1392, 16:42 عصر
  2. نحوه انتقال اطلاعات datagridview به TextBox
    نوشته شده توسط Behnam6670 در بخش C#‎‎
    پاسخ: 3
    آخرین پست: دوشنبه 14 اسفند 1391, 09:22 صبح
  3. ذخیره اطلاعات دیتا گرید در اکسل
    نوشته شده توسط helpsos در بخش WPF
    پاسخ: 3
    آخرین پست: دوشنبه 16 بهمن 1391, 14:16 عصر
  4. تبدیل اطلاعات دیتا گرید به اکسل
    نوشته شده توسط hr_3303 در بخش برنامه نویسی در 6 VB
    پاسخ: 3
    آخرین پست: یک شنبه 08 بهمن 1391, 09:27 صبح
  5. سوال: خطای عجیب در هنگام انتقال اطلاعات به sql
    نوشته شده توسط mr.siahatgar در بخش C#‎‎
    پاسخ: 3
    آخرین پست: یک شنبه 01 بهمن 1391, 01:49 صبح

برچسب های این تاپیک

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •