一个stringgrid,有滚动条,窗口上只能显示一部分数据
想把整个表的数据打印出来,该怎么处理?
能否整个表格作为一个整体打印?(stringgrid类好像没有print方法)

解决方案 »

  1.   

    要么自己写,要么用QuickRep控件,要么第三方
      

  2.   

    数据库里有和stringgrid中数据结构相同下表吗,有直接用表相连在quickrep中实现;
    没有就用临时表把stringgrid中的数据存进去,再在stringgrid中实现。
      

  3.   

    当年用BCB写的,看看
    void TFQuickRep::ShowForm(TStringGrid* StringGrid)
    {
       TList *ShapeList ;
       TList *ShapeList2 ;
       TList *LabelList ;
       TList *QRTextList ;
       TQRShape *NewShape ;
       TQRShape *OneShape ;
       TQRLabel *NewLabel ;
       TQRDBText *NewQRText;
       int iTemp1,iTemp2 ;
       AnsiString sSQL;   ShapeList = new TList ;
       ShapeList2 = new TList;
       LabelList = new TList ;
       QRTextList = new TList;   QRTitleShape->Width = StringGrid->ColWidths[0] ;
       QRDetailShape->Width = StringGrid->ColWidths[0];
       QRTitleLabel->Caption = StringGrid->Cells[0][0];   for(int m=0;m<StringGrid->FixedRows;m++)
       {
           ShapeList->Clear();
           LabelList->Clear();
           LabelList->Add(QRTitleLabel) ;
           ShapeList->Add(QRTitleShape) ;
           if(m>0)
           {
              QRBand1->Height = QRBand1->Height+QRTitleShape->Height;
              NewShape = new TQRShape(this);
              NewShape->Parent = QRBand1;
              NewShape->Height = QRTitleShape->Height;
              NewShape->Width = StringGrid->ColWidths[0];          NewShape->Left = QRTitleShape->Left;
              NewShape->Top=QRTitleShape->Top+m*(NewShape->Height);
              NewLabel = new TQRLabel(this);
              NewLabel->Parent = QRBand1;
              NewLabel->Caption = StringGrid->Cells[0][m];
              NewLabel->Left = iTemp1+5;
              NewLabel->Top=NewShape->Top + 3;
              NewLabel->AutoSize = true;
              NewLabel->BringToFront();
           }
           for(int i=1;i<StringGrid->ColCount;i++)
           {          iTemp1 = QRTitleShape->Left;
              NewShape = new TQRShape(this);
              NewShape->Parent = QRBand1;
              NewShape->Height = QRTitleShape->Height;
              NewShape->Width = StringGrid->ColWidths[i];
              for(int j=0;j<ShapeList->Count;j++)
              {
                iTemp1 = iTemp1+((TQRShape *)(ShapeList->Items[j]))->Width-1;
              }
              NewShape->Left = iTemp1;
              NewShape->Top=QRTitleShape->Top+m*(NewShape->Height);
              ShapeList->Add(NewShape);          NewLabel = new TQRLabel(this);
              NewLabel->Parent = QRBand1;
              NewLabel->Caption = StringGrid->Cells[i][m];
              NewLabel->Left = iTemp1+5;
              NewLabel->Top=NewShape->Top + 3;
              NewLabel->AutoSize = true;
              NewLabel->BringToFront();
          }
       }   ShapeList2->Add(QRDetailShape);
       QRTextList->Add(QRDBDetailText);
       for(int i=1;i<StringGrid->ColCount;i++)
       {
          iTemp1 = QRDetailShape->Left;
          OneShape = new TQRShape(this);
          OneShape->Parent = QRBand2;
          OneShape->Height = QRDetailShape->Height;
          OneShape->Width = StringGrid->ColWidths[i];
          for(int j=0;j<ShapeList2->Count;j++)
          {
            iTemp1 = iTemp1+((TQRShape *)(ShapeList2->Items[j]))->Width-1;
          }
          OneShape->Left = iTemp1;
          OneShape->Top=QRDetailShape->Top;
          ShapeList2->Add(OneShape);      NewQRText = new TQRDBText(this);
          NewQRText->Parent = QRBand2;
          NewQRText->Left = iTemp1+5;
          NewQRText->Top=QRDBDetailText->Top;
          NewQRText->AutoSize = true;
          NewQRText->BringToFront();
          QRTextList->Add(NewQRText);
       }
       sSQL = "select * from tReport_tmp";
       if(OpenSQL(DMMain->qryCall,sSQL))
       {
          for(int i=0;i<QRTextList->Count;i++)
          {
             ((TQRDBText *)(QRTextList->Items[i]))->DataSet=DMMain->qryCall;
             ((TQRDBText *)(QRTextList->Items[i]))->DataField="F"+IntToStr(i);
          }
       }
       QuickRep1->Preview();
    }
      

  4.   

    跟数据库没有关系,就是一个stringgrid控件显示一些数据
    不是数据库的表