기본 콘텐츠로 건너뛰기

2월, 2011의 게시물 표시

Late Binding을 통한 Excel Automation class

Late Binding을 하게 되면 사용자 머신에 설치된 Excel의 버젼에 상관없이 사용할 수 있게 되어 유용합니다. 참조 사이트 : http://www.codeproject.com/KB/cs/How2LateBinding.aspx 사용 법: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 /// <summary>   /// export data to excel file   /// </summary>   /// <param name="sender"></param>   /// <param name="e"></param>   private   void  btnExport_Click( object  sender, EventArgs e)   {        int  iExlStartRow  =   2  , iNextColumn  =   10 ;        try       {          CExcelAutomation xlApp  =   new  CExcelAutomation( true );           if  ( true   = =  xlApp.Open( "d:\\MicroStation Analysis.xlsx" ))          {               object [] parameter  =   new   object [ 1 ];              parameter[ 0 ]  =   1 ;               object  objWorksheet  =  xlA

Python.NET

이번에 예정인 프로젝트가 C#을 사용할 것이기 때문에 C#과 python을 어떻게 연동할지 찾아 보았습니다. 가장 눈에 띄는게 IronPython이었는데요,  인터넷상의 대부분의 문서들이 .NET 4.0에서 환경에서 연동하는 것을 설명하였습니다. 이렇게 할려면 VS2010이 있어야 하는것 같았구요. 저의 환경은 VS2008이고 시스템에 설치되어 있는 것도 .NET2.X 였습니다. 그래서 IronPython을 포기하고 Python.NET을 검토해 보았는데 의외로 쉽게 연동할수가 있었습니다. 일단은 Python.NET을 다운 받구요. C# 프로젝트에서 다운 받은 DLL을 레퍼런스 시키면 바로 시작할 수 있습니다. 아래는 동료 연진이가 테스트한 코드입니다.   1 using System;   2 using System.Collections.Generic;   3 using System.Linq;   4 using System.Text;   5 using Python.Runtime;   6 using System.Windows.Forms;   7 namespace Python_Test   8 {   9      class Program 10      { 11          static void Main( string [] args) 12          { 13 14              int index = Application.ExecutablePath.LastIndexOf( " \\ " ); 15              string AppPath = Application.ExecutablePath.Substring( 0 , index); 16 17              PythonEngine.Initialize(); 18 19              //! 파이썬 파일이 들어 있는 폴더를 path 에 추가 20              PyObject sys = PythonEngine.

jsm 파일 만들기의 문제점 V8 / MSTN/MDL/VBA

Interference Manager를 통해서 jsm 파일을 만들때, dgn item에 들어 있는 내용은 jsm 파일의 property에 넣어 줄수 있습니다. 하지만 dgn item에 없는 사용자 property를 넣어주기 위해서 간략한 MDL App.를 만들었는데 이것의 문제점은 실제로 interference가 발생하지 않으면 MDL App의 함수가 호출되지 않는다는 것입니다.(이 함수에서 사용자 property의 값을 넣어주게 됩니다.) 그래서 테스트를 위해 임의로 CELL을 Support Model과 interference가 발생하게 넣어주고 interference mananger를 통해서 MDL App.를 호출하였는데, 여기서 또한 문제가 발생했습니다. 넣어준 CELL의 property에는 값을 넣어줄 수가 있었는데 정작 필요한 support model의 property에는 값을 넣어 줄수가 없는 것이었습니다. 이 부분을 어떻게 다루어야 하는지 모르겠습니다.(Support Model의 property 값을 넣도록 하는 것) 2011.02.23 Application Setting에서 Design Series 체크 버튼을 끄고 하면 Support Model의 Property에 값을 넣을수는 있는데, 가장 상위의 Cell에만 들어가는 문제가 또 있습니다. Assembly로 만든 Support는 각 Component가 Nested Cell 형식으로 존재하게 되는데, 결과적으로 Nested Cell의 Property에 값을 넣어 줄수가 없는 것입니다. 2011.02.24 Navigator COM API로 jsm 파일 안에 있는 propery를 찾고 , 값을 변경 그리고 저장할수 있다고 합니다. 하지만 누가 프로그램을 짜서 이렇게 할려고 할까요? Navigator가 시장에서 많이 사용하고 있는 것도 아니고 또한 공짜로 배포하고 있는데 말이죠...

CFileDialog를 사용하기

// 파일 Save CString strExtFile, strFilePath; CString strFilter = _T("텍스트 문서(*.txt)|*.txt||"); strExtFile = _T("*.txt"); CFileDialog dlg(FALSE,strExtFile,strExtFile,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, strFilter); if(IDOK == dlg.DoModal()) { strFilePath = dlg.GetPathName(); } // 파일 Open CFileDialog dlg(TRUE,_T("txt,*.*"),_T(""),OFN_HIDEREADONLY|OFN_FILEMUSTEXIST, _T("텍스트 문서(*.txt,*.dat)|*.txt;*.dat|모든 문서(*.*)|*.*||")); if(IDOK == dlg.DoModal()) { dlg.GetPathName(); } // 기본 경로 설정하기 dlg.m_ofn.lpstrInitialDir = _T("_PATH_");

HOWTO: Use regsvr32.exe with WIX

WIX 관련 첫번째 포스트입니다. WIX의 철학(?)은 아직 저에게 익숙하지가 않네요. 어떻게 그 많은 아이템들을 입력해야 하는지(물론 WIX 편집기도 있지만 불편한 점은 어쩔수가 없습니다.) 원문 : http://blogs.microsoft.co.il/blogs/yanush/archive/2008/09/22/howto-use-regsvr32-exe-with-wix.aspx Last night I had to deal with this issue, in one of the projects I’m involved in. So, after sifting through some forums, msdn and wix schema reference here is the end result. Its a fairly simple thing… in retrospect! :) Adding the custom actions: 1 2 3 4 5 6 7 8 9 < CustomAction   Id = "RegisterAdx"      Directory = "INSTALLDIR"         ExeCommand = 'regsvr32.exe /s "[INSTALLDIR]adxloader.dll"'         Return = "check" > < / CustomAction > < CustomAction   Id = "UnregisterAdx"         Directory = "INSTALLDIR"         ExeCommand = 'regsvr32.exe /s /u "[INSTALLDIR]adxloader.dll"' > < / CustomAction > Colored by Color Scripter cs For those of you who don’t reco