|
Chane to this..
awb.OleProcedure("Close",(Variant)false );
우리 님이 쓰신 글 :
: 엑셀파일을 열어서 읽고 셀 하나에 값을 넣고
:
: 저장하고 나오는 간단한 소스입니다.
:
: 그런데 실행하면 팝업창이 뜨면서 "이미 기존파알이 있으니 교체하겠냐" 는 메시지가 뜹니다.
:
: 이거 안뜨게 하고 바로 저장하게 할수는 없나요?
:
: 고수님들 알려주세요 ~ ^^;;
:
: //---------------------------------------------------------------------------
: #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;
:
: }
|