|
//그런데 이부분은 에러가 나네요
AnsiString a, b, date, name;
date = "2005-01-01";
name = "홍길동";
a = "A" + 2; // <<-------- 이 부분 문제 ****
a=""+a+"";
("A" + 2 ) 가되면, (char *) 형의 연산이 됩니다.
("A"의 주소(pointer)에 2를 더하는 결과가 됩니다.)
원하는 AnsiString의 '+' 연산을 하시려면,
a = "A" + IntToStr(2);
또는
a = AnsiString("A") + 2
이런식으로 고쳐야 할 것 같습니다.
아름이 님이 쓰신 글 :
: Variant xlApp, xlBooks, xlBook, xlSheet, xlSheets, VRange;
:
: if (xlApp.IsEmpty()){
: xlApp=Variant::CreateObject("Excel.Application.9");
: }
:
: xlApp.OlePropertySet("Visible", true);
:
: xlBooks=xlApp.OlePropertyGet("Workbooks");
: xlBooks.OleProcedure("add");
: xlBook=xlBooks.OlePropertyGet("Item",1);
: xlSheets=xlBook.OlePropertyGet("Worksheets");
: xlSheet=xlSheets.OlePropertyGet("Item",1);
:
: //아래의 내용은 엑셀로 잘 옮겨집니다. 문제가 전혀없이요..
:
: VRange=xlSheet.OlePropertyGet("Range","A1");
: VRange.OlePropertySet("Value", "날짜");
: VRange=xlSheet.OlePropertyGet("Range","B1");
: VRange.OlePropertySet("Value", "성명");
:
:
: //그런데 이부분은 에러가 나네요
: AnsiString a, b, date, name;
: date = "2005-01-01";
: name = "홍길동";
:
: a = "A" + 2;
: a=""+a+"";
:
: VRange=xlSheet.OlePropertyGet("Range",a);
: VRange.OlePropertySet("Value",date);
:
:
: b = "B" + 2;
: b=""+b+"";
:
: VRange=xlSheet.OlePropertyGet("Range",b);
: VRange.OlePropertySet("Value",name);
:
: 컴파일시는 문제가 전혀 없구요
: 실행해서 엑셀로 변환할때 "잘못된 변수 유형입니다" 라고 에러가 나면서
:
: 그 포인터가 sysvari.h 의
:
: template <class P1>
: Variant Variant::OlePropertyGet(const String& name, P1 p1)
: {
: TAutoArgs<1> args;
: args[1] = p1;
: return OlePropertyGet(name, static_cast<TAutoArgsBase*>(&args)); <--- 이부분에서 잡힙니다.
: }
:
:
: 무슨 에러며 왜 나는것일까요?
:
: 고수닙들의 한수 가르침을 간절히 기다립니다. 꾸벅
|