|
FastReport 의 샘플코드에 보면 PrintStringGrid 이란 예제가 있는데
아래와 같이 세가지 방법으로 직접 String 을 대입 했는데 잘 되지 않아서 도움을 청합니다.
String str = "testval";
wchar_t *str2 = L"testval2";
void __fastcall TForm1::frxReport1BeforePrint(TfrxReportComponent *Sender)
{
TfrxCrossView * Cross = NULL;
int idx1,idx2;
Variant Row,Col,Text;
if(strcmp(Sender->Name.t_str(),"Cross1\0") == 0)
{
if(Cross = dynamic_cast < TfrxCrossView *> (Sender))
{
for(idx1 = 0; idx1 < StringGrid1->RowCount; idx1++)
for(idx2 = 0; idx2 < StringGrid1->ColCount; idx2++)
{
Row = idx1;
Col = idx2;
//아래 세가지 방법 모두 에러 발생 (1, 2, 3)
Text = SysAllocString(L"HELLO!"); <------ 1 (API 사용해서 문자열 할당: 에러발생)
Text = str; <------ 2 (String 형 대입: 에러발생)
Text.bstrVal = str2; <------ 3 (wchar_t * 형 대입: 에러는 발생하지 않지만 그림2처럼 레포트에 출력데이타가 없음)
//Text = StringGrid1->Cells[idx1][idx2]; <--- 잘되는 오리지널 코드
Cross->AddValue( &Row,1,&Col,1,&Text,1);
}
}
}
}
에러 메시지는 다음과 같습니다.
... Exception class EVariantTypeCastError with message 'Could not convert variant of type (UnicodeString) into type (Double)'
에러화면 캡춰는 err.jpg 이고
출력레포트에 출력데이터가 없는거는 2.jpg 입니다.
감사합니다.
|