Excel otomasyonunda problem !

by eMRe 2. Mart 2011 20:24

excel icon excel exel egzel

C# ile excel otomasyonu yapıyorsanız, karşılacabileceğiniz bir takım iyi bilinen problemler olacaktır elbet. Zaten bu yüzden Microsoft firması da kendi makalelerinde kod yoluyla otomatik bir şekilde excel dosyaları üretmeyi önermiyor. tavsiye etmiyor. Ve bu konuda da destek vermiyor. Herhangi bir sorun yaşadığında bunu iletemiyorsun resmi makamlara.. "kardeşim sana kim bunu yapabilirsin dedi ?"  diyorlar haliyle.

 

Şimdi en sık karşılaşılan problemlerden birisi, excel'i örneklerken ki satırda "invalid type or old method" gibi bir hata almanızdır. bunun çözümü gayet basittir. Bunun sebebi office in kültür ayarlarından kaynaklanıyor. Bu sekilde bu nesneyi örneklerken sadece en-US  kültür ayarında çağırma yapmanız gerekiyor malesef. Bu bilinen bir sorundur..

 

dolayısı ile

Microsoft.Office.Interop.Excel._Application xlApp = new Microsoft.Office.Interop.Excel.ApplicationClass(); 

 Microsoft.Office.Interop.Excel.Workbook xlWorkBook;

        Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;

 System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");

      xlWorkBook = xlApp.Workbooks.Add(true);

 

işte tam burda workbooks.add methodu çağırılırken o anki thread in kültür ayarını en-US  a çevirmemiz gerekiyor. .Add satırından sonra tekrar eski haline cevirebilirsiniz sıkıntı olmaz.

 

Ancak 2 gündür boğuştuğum başka bir problem vardı benim. Bütün bu sorunları gidermeme rağmen. Kodum çalışırken tam Workbooks.Add kısmına geliyor ve orda kalıyor. ilerlemiyor. hata da vermiyordu. Sunucuya giriyorum bakıyorum kod çalışırken EXCEL.EXE çalışmaya baslıyor. Bunu task manager 'dan görebiliyorum. ama işlem yapmıyor öylece kalıyor. Daha sonra bayağı bi bekledikten sonra EXCEL.EXE'yi manuel bir şekilde görevi sonlandır dedikten sonra kodum hata veriyor. Hata verdiği satır da tam Workbooks.Add'in olduğu satır. 

 

Bu arada bu tip otomasyonlar yapılabilmesi için kodun çalıştığı makinada excel yüklü olması lazım. Benim sunucumda Office 2007 Enterprise yüklüydü. Günlerce uğraştım. Google da belki 2000 tane site gezmişimdir. Ancak sorunu bulamadım bir türlü. Excel exe çalışıyor ama kod ilerlemiyor. Çözümünü bulabilen olmamış. 1 tane aynı sorunla karşılan yabancı bi eleman gördüm. Onun da sorusuna kimse cevap yazmamış zaten.

Aklıma gelen herşeyi denedikten sonra, azmettim ve bütün office versionlarını makinaya kurup denemeye karar verdim.. Ve en sonunda Office 2007 Professional'ı kurdum ve sorun düzeldi. Hepimiz derin bir nefes aldık.

Halbuki Enterprise la gelen ve Professional ile gelen excel.exe lerin Built number ları bile aynı. Dosyalar tamamen aynı. Boyutlarına kadar versionlarına kadar hepsi aynı. Demek olay excel de bitmiyor, arka planda bazı dll lerde farklılıklar var..

Mesela en çok ilgimi çeken Office 2007 Enterprise da MSO.DLL diye birşey YOK. ama Professional da var. Belki de olay ondan kaynaklanıyordur. 

Nihayet bütün kodum tekrar çalışıyor. Umarım aynı problemi yaşan kişilere bir kaynak teşkil eder bu yazım.

Kodunuz hiç bir hata vermeden "çalışmamazlık" ediyorsa, office in farklı versionlarını yukleyip test edin derim öncelikle !

 

FacebookDigg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Etiketler: , , , , ,

Programlama

Yorumlar

12.05.2011 04:56:31 #

Spielautomaten Trick

With havin so much written content do you ever run into any problems of plagorism or copyright infringement? My site has a lot of unique content I've either written myself or outsourced but it seems a lot of it is popping it up all over the internet without my authorization. Do you know any ways to help prevent content from being ripped off? I'd genuinely appreciate it.

Spielautomaten Trick United States | Reply

12.05.2011 05:11:46 #

Roulette Strategie

I do enjoy the manner in which you have framed this particular issue and it does offer me personally a lot of fodder for thought. Nevertheless, because of just what I have observed, I only hope when the comments pile on that people remain on issue and not start on a soap box of some other news of the day. Yet, thank you for this outstanding point and while I do not concur with the idea in totality, I respect your perspective.

Roulette Strategie United States | Reply

12.05.2011 05:35:18 #

roulett

Almost all of what you mention happens to be astonishingly accurate and it makes me wonder the reason why I hadn't looked at this in this light previously. This article truly did turn the light on for me as far as this particular subject goes. However there is 1 factor I am not really too comfortable with so while I try to reconcile that with the core theme of your position, allow me see what all the rest of the readers have to point out.Very well done.

roulett United States | Reply

12.05.2011 12:52:58 #

Roulette Strategie

Have you ever considered writing an ebook or guest authoring on other sites? I have a blog based upon on the same subjects you discuss and would love to have you share some stories/information. I know my readers would value your work. If you are even remotely interested, feel free to send me an e mail.

Roulette Strategie United States | Reply

12.05.2011 20:00:58 #

Roulette Strategie

A lot of whatever you articulate happens to be supprisingly precise and that makes me wonder the reason why I hadn't looked at this in this light previously. This article really did turn the light on for me personally as far as this subject goes. Nonetheless at this time there is one particular point I am not necessarily too comfortable with and whilst I make an effort to reconcile that with the central idea of the issue, permit me see exactly what all the rest of your visitors have to point out.Nicely done.

Roulette Strategie United States | Reply

18.05.2011 22:18:59 #

Roulette Cheat

Throughout this awesome scheme of things you'll get  an A+ just for effort. Where you lost me was in your facts. You know,  it is said, details make or break the argument.. And that couldn't be much more true right here. Having said that, allow me say to you precisely what did deliver the results. Your authoring is definitely very persuasive which is most likely the reason why I am taking an effort to comment. I do not make it a regular habit of doing that. Next, whilst I can certainly see a jumps in reasoning you come up with, I am definitely not convinced of just how you appear to unite the points that make the actual conclusion. For right now I will, no doubt yield to your issue but wish in the near future you connect your dots better.

Roulette Cheat United States | Reply

19.05.2011 16:36:29 #

Roulette Strategy

The core of your writing whilst sounding agreeable initially, did not really settle properly with me personally after some time. Someplace within the sentences you were able to make me a believer but just for a short while. I however have got a problem with your jumps in assumptions and one might do nicely to help fill in those breaks. In the event that you can accomplish that, I could definitely be fascinated.

Roulette Strategy United States | Reply

20.05.2011 04:55:24 #

Boof of Ra

I do like the manner in which you have framed this specific issue and it does supply us a lot of fodder for consideration. On the other hand, because of what I have personally seen, I basically hope as the reviews stack on that men and women continue to be on issue and in no way get started on a tirade of some other news of the day. Anyway, thank you for this exceptional piece and even though I do not go along with it in totality, I respect your perspective.

Boof of Ra United States | Reply

20.05.2011 05:58:48 #

spielautomaten tricks

Hello just wanted to give you a brief heads up and let you know a few of the pictures aren't loading correctly. I'm not sure why but I think its a linking issue. I've tried it in two different browsers and both show the same outcome.

spielautomaten tricks United States | Reply

22.05.2011 03:58:02 #

Boof of Ra Download

Hello! I know this is somewhat off topic but I was wondering if you knew where I could find a captcha plugin for my comment form? I'm using the same blog platform as yours and I'm having problems finding one? Thanks a lot!

Boof of Ra Download United States | Reply

22.05.2011 06:09:14 #

Geld Gewinnen

The very core of your writing while appearing agreeable originally, did not really settle very well with me personally after some time. Someplace throughout the sentences you managed to make me a believer unfortunately just for a short while. I still have a problem with your jumps in logic and one might do nicely to fill in all those breaks. When you can accomplish that, I could surely be amazed.

Geld Gewinnen United States | Reply

22.05.2011 06:26:51 #

Roulette Systeme

In this awesome design of things you receive  an A just for effort. Where you misplaced us was on the details. You know,  they say, details make or break the argument.. And that could not be more accurate at this point. Having said that, allow me inform you what did deliver the results. Your article (parts of it) is certainly highly convincing and this is most likely why I am making the effort in order to comment. I do not make it a regular habit of doing that. Second, even though I can certainly see the jumps in logic you make, I am not really certain of how you appear to connect your details that make the final result. For now I will, no doubt subscribe to your issue however trust in the near future you actually link the dots better.

Roulette Systeme United States | Reply

24.05.2011 15:47:18 #

Roulette Strategy

Almost all of whatever you point out is astonishingly appropriate and it makes me wonder the reason why I had not looked at this with this light before. Your article truly did switch the light on for me personally as far as this issue goes. Nonetheless there is actually one position I am not too cozy with so while I attempt to reconcile that with the actual core idea of the point, let me see exactly what the rest of your subscribers have to say.Nicely done.

Roulette Strategy United States | Reply

25.05.2011 00:27:40 #

American Poker

I do enjoy the manner in which you have framed this specific difficulty plus it does supply me a lot of fodder for consideration. However, because of what precisely I have seen, I just simply trust as the actual remarks pile on that individuals continue to be on point and not embark upon a tirade regarding the news of the day. Anyway, thank you for this superb piece and even though I can not concur with this in totality, I value the standpoint.

American Poker United States | Reply

30.05.2011 02:37:34 #

Casino Club

Hi there! I know this is kinda off topic nevertheless I'd figured I'd ask. Would you be interested in exchanging links or maybe guest writing a blog article or vice-versa? My blog covers a lot of the same subjects as yours and I believe we could greatly benefit from each other. If you're interested feel free to send me an e-mail. I look forward to hearing from you! Fantastic blog by the way!

Casino Club United States | Reply

08.06.2011 01:04:11 #

Roulette Tricks

Nearly all of whatever you mention happens to be astonishingly legitimate and it makes me wonder the reason why I hadn't looked at this with this light previously. Your piece truly did turn the light on for me as far as this particular subject matter goes. Nonetheless at this time there is just one issue I am not necessarily too cozy with and while I make an effort to reconcile that with the main theme of the issue, allow me see what the rest of your visitors have to say.Well done.

Roulette Tricks United States | Reply

12.06.2011 16:27:33 #

Roulette Spiel

The core of your writing whilst appearing agreeable originally, did not sit very well with me after some time. Someplace throughout the sentences you actually managed to make me a believer but just for a while. I nevertheless have a problem with your leaps in logic and one might do nicely to fill in all those breaks. In the event you actually can accomplish that, I will certainly end up being impressed.

Roulette Spiel United States | Reply

15.06.2011 03:07:54 #

Roulette Spiel

Does your blog have a contact page? I'm having a tough time locating it but, I'd like to send you an email. I've got some ideas for your blog you might be interested in hearing. Either way, great blog and I look forward to seeing it expand over time.

Roulette Spiel United States | Reply

17.06.2011 06:05:03 #

roulette system

I really like your blog.. very nice colors & theme. Did you design this website yourself or did you hire someone to do it for you? Plz answer back as I'm looking to design my own blog and would like to find out where u got this from. kudos

roulette system United States | Reply

Yorum ekle


(Gravatar simgesini gösterecek)

  Country flag

biuquote
  • Yorum
  • Canlı önizleme
Loading



Son Yorumlar

Comment RSS