打印报表,显示不出内容,请高手指点
void __fastcall TForm1::btn1Click(TObject *Sender)
{
VARIANT vNA = Variant(0L);
Statist1-> StartDocA();
Statist1-> PageBorder = 7;
Statist1-> TableBorder = 7;
Statist1-> TablePenLR = 40;
Statist1-> TablePenTB = 40;
Statist1-> StartTable();
Statist1-> AddTable(AnsiToOLESTR( "2300|2300|2300 "),AnsiToOLESTR( "Column 1|Column 2|Column 3 "),AnsiToOLESTR( " "), VARIANT(Variant((long)RGB(200, 200, 250))), vNA, vNA);
Statist1-> set_TableCell(tcRows, vNA, vNA, vNA, vNA,VARIANT( Variant(10L)));
Statist1-> set_TableCell(tcAlign, vNA, vNA, vNA, vNA,VARIANT( Variant((long)taCenterMiddle)));
for (long row = 1; row <= 7; row++)
{
for (long col = 1; col <= 3; col++)
{
if ((row + col) % 7 != 0)
{
String cell = "this is a test ";
VARIANT aa = TVariantInParam (cell);
Statist1-> set_TableCell(tcText, VARIANT( Variant(row)), VARIANT( Variant(col)), vNA, vNA, VARIANT(aa));
} else
{
Statist1-> set_TableCell(tcText, VARIANT( Variant(row)), VARIANT( Variant(col)), vNA, vNA, VARIANT(TVariantInParam( "ls test ")));
Statist1-> set_TableCell(tcBackColor, VARIANT( Variant(row)), VARIANT( Variant(col)), vNA, vNA, VARIANT( Variant((long)RGB(100, 250, 100))));
Statist1-> set_TableCell(tcFontBold, VARIANT( Variant(row)), VARIANT( Variant(col)), vNA, vNA, VARIANT( Variant((long)TRUE)));
}
}
}
Statist1-> EndTable();
Statist1-> EndDoc();
}
能显示标题,但是不容“this is a test”就是显示不出来,不知道为什么?我用到控件是
#pragma link "VSPrinter8Lib_OCX "
#pragma link "VSReport8Lib_OCX "
[解决办法]
哈哈,这东东我见过,很简单的,看看
TVSprint-> StartDocA();
TVSprint-> FontBold = true;
TVSprint-> PageBorder = 0;
TVSprint-> StartTable();
TVSprint-> TableBorder = 7;
TVSprint-> TablePenLR = 0;
TVSprint-> TablePenTB = 0;
TVSprint-> FontSize = 12;
TVSprint-> AddTable(AnsiToOLESTR( "2000|2000|2000 "),AnsiToOLESTR( "姓名 ", "年龄 ", "班级 "),AnsiToOLESTR( " "), VARIANT(Variant((long)RGB(0, 0, 0))), vNA, vNA);
TVSprint-> EndTable();
TVSprint-> EndDoc();