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
[44037] 엑셀파일 저장시 문제
우리 [palindrome] 1253 읽음    2006-03-10 11:50
엑셀파일을 열어서 읽고 셀 하나에 값을 넣고

저장하고 나오는 간단한 소스입니다.

그런데 실행하면 팝업창이 뜨면서 "이미 기존파알이 있으니 교체하겠냐" 는 메시지가 뜹니다.

이거 안뜨게 하고 바로 저장하게 할수는 없나요?

고수님들 알려주세요 ~ ^^;;

//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop

#include "utilcls.h"
#include <graphics.hpp>
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  Variant ex=Variant::CreateObject("Excel.Application");
  ex.OlePropertyGet("WorkBooks").OleProcedure("Open","c:\\test.xls");
  Variant awb=ex.OlePropertyGet("ActiveWorkBook");
  Variant sh=awb.OlePropertyGet("ActiveSheet");//엑티브sheet
//  Variant sh=awb.OlePropertyGet("Sheets").OlePropertyGet("item",1);//sheet1
//  Variant sh=awb.OlePropertyGet("Sheets").OlePropertyGet("item",2);//sheet2

  int row=sh.OlePropertyGet("UsedRange").OlePropertyGet("Rows").OlePropertyGet("Count"); //row갯수
  int col=sh.OlePropertyGet("UsedRange").OlePropertyGet("Columns").OlePropertyGet("Count");//col갯수

  StringGrid1->RowCount=row+1;
  StringGrid1->ColCount=col+1;

  for(int j=0;j<row;j++){
    for(int i=0;i<col;i++){
      StringGrid1->Cells[i+1][j+1]=sh.OlePropertyGet("Cells",j+1,i+1).OlePropertyGet("Value");
    }
  }

  sh.OlePropertyGet("Cells").OlePropertySet("_Default", 1, 1, "test");

  awb.OleProcedure("Save");
  awb.OleProcedure("Close");
  ex.OleProcedure("Quit");

  awb=Unassigned;
  ex=Unassigned;

}

+ -

관련 글 리스트
44037 엑셀파일 저장시 문제 우리 1253 2006/03/10
44039     Re:엑셀파일 저장시 문제 alex 1382 2006/03/10
44040         Re:Re:엑셀파일 저장시 문제 우리 1704 2006/03/10
44043             Re:Re:Re:엑셀파일 저장시 문제 smleelms 1670 2006/03/10
70752                 Re:Re:Re:Re:엑셀파일 저장시 문제 966 2014/01/21
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.