C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[20889] 엑셀 문의
김용수 [y016skim] 1002 읽음    2002-08-19 21:59
잘은모르지만 데이터를 엑셀파일로 저장하기서 본 홈페이지에 있는 소스들을
이용해서 저장하는 것은 했는데, 파일명을 제가 지정하여 저장시키고 엑셀을 종료시키게
하고 싶은데 아래 소스는 엑셀이 실행되고 데이터가 셀에 삽입된채로 가만이 있습니다.
즉, 엑셀이 실행되지 않는상태에서 변수에 있는데이터를 엑셀파일에 파일명을 제가
임의로 프로그램에서 지정하면서 저장하게 할수 있을것 같은데 방법을 모르겠습니다.
고수님들의 도움바랍니다.

또한 새로운 시트의 추가나 시트의 이름변경, 차트그리기등도 하고 싶은데
어떤자료를 보아야 되나여?


  if(xlApp.IsEmpty())
     {
           xlApp = Variant::CreateObject("Excel.Application");
     }
     xlApp.OlePropertySet("Visible", true);

     Variant xlBooks;
     xlBooks = xlApp.OlePropertyGet("Workbooks");
     xlBooks.OleProcedure("Add");                   //파일을 새로 만들때

     Variant xlBook = xlBooks.OlePropertyGet("Item", 1);
     Variant xlSheets = xlBook.OlePropertyGet("Worksheets");
     Variant xlSheet = xlSheets.OlePropertyGet("Item", 1);

     Variant VRange;
     VRange = xlSheet.OlePropertyGet("Range", "A1");
     VRange.OlePropertySet("Value", "Count");
     VRange = xlSheet.OlePropertyGet("Range", "B1");
     VRange.OlePropertySet("Value", "T1[min]");
     VRange = xlSheet.OlePropertyGet("Range", "C1");
     VRange.OlePropertySet("Value", "Temp[K]");
     VRange = xlSheet.OlePropertyGet("Range", "D1");
     VRange.OlePropertySet("Value", "T2[min]");
     VRange = xlSheet.OlePropertyGet("Range", "E1");
     VRange.OlePropertySet("Value", "Tref[K]");
     VRange = xlSheet.OlePropertyGet("Range", "F1");
     VRange.OlePropertySet("Value", "T3[min]");
     VRange = xlSheet.OlePropertyGet("Range", "G1");
     VRange.OlePropertySet("Value", "P[W]");
     VRange = xlSheet.OlePropertyGet("Range", "H1");
     VRange.OlePropertySet("Value", "T4[min]");
     VRange = xlSheet.OlePropertyGet("Range", "I1");
     VRange.OlePropertySet("Value", "I[Arms]");
     VRange = xlSheet.OlePropertyGet("Range", "J1");
     VRange.OlePropertySet("Value", "T5[min]");
     VRange = xlSheet.OlePropertyGet("Range", "K1");
     VRange.OlePropertySet("Value", "S[mm]");
     VRange = xlSheet.OlePropertyGet("Range", "L1");
     VRange.OlePropertySet("Value", "T6[min]");
     VRange = xlSheet.OlePropertyGet("Range", "M1");
     VRange.OlePropertySet("Value", "Error");

     xlSheet = xlApp.OlePropertyGet("ActiveSheet");
     for(int Row=0; Row<DataLengthOfMotor; Row++)
     {
       //Worksheets("Sheet1").Cells(6, 1).Value = 10
       xlSheet.OlePropertySet("Cells", Row+2, 1,Row+1);
       xlSheet.OlePropertySet("Cells", Row+2, 2,TimeColdTemp[Row]);
       xlSheet.OlePropertySet("Cells", Row+2, 3,ColdTemp[Row]);
       xlSheet.OlePropertySet("Cells", Row+2, 4,TimeColdTempref[Row]);
       xlSheet.OlePropertySet("Cells", Row+2, 5,ColdTempref[Row]);
       xlSheet.OlePropertySet("Cells", Row+2, 6,TimeMotorPower[Row]);
       xlSheet.OlePropertySet("Cells", Row+2, 7,MotorPower[Row]);
       xlSheet.OlePropertySet("Cells", Row+2, 8,TimeMotorCurrent[Row]);
       xlSheet.OlePropertySet("Cells", Row+2, 9,MotorCurrent[Row]);
       xlSheet.OlePropertySet("Cells", Row+2,10,TimeMotorStroke[Row]);
       xlSheet.OlePropertySet("Cells", Row+2,11,MotorStroke[Row]);
       xlSheet.OlePropertySet("Cells", Row+2,12,TimeErrorCode[Row]);
       xlSheet.OlePropertySet("Cells", Row+2,13,ErrorCode[Row]);
    }

+ -

관련 글 리스트
20889 엑셀 문의 김용수 1002 2002/08/19
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.