A small example of a crystal report

xiaoxiao2021-03-06  41

This time we made a program. Access the database: Use the database access middleware, just write an XML file, access to the real database via Hibrate, it will return an XML document to us as a record set. Make reports : Generate a static report. Write a TTX file. Based on this to make a static report. Some content you need to display. There are also some formulas to do well. After that, the data source is like this. Read out The record set in the XML document opens a recordset that is not connected to an ADO on the database. Then one piece adds a record set. Then use the crystal report object to set the table structure in a report with one of my ADO records Set, this can be easily displayed. Example of code I have some post here. Maybe it will be used in the future. _RecordSetptr m_precordset; m_precordset.createInstance (__ uuidof (recordset); m_precordset-> CursorLocation = aduseclient;

Try {// Add column m_precordset-> fields-> append (_BSTR_T ("ID"), Advarchar, 40, Adfldisnullable;

// open the record set, (com, there are some default values ​​can be used to fill in vtMissing) m_pRecordset-> Open (vtMissing, vtMissing, adOpenStatic, adLockBatchOptimistic, adCmdUnknown); // create a DOM, load an XML document MSXML :: IXMLDOMDocumentPtr pCommandDoc ; pCommandDoc.CreateInstance (__ uuidof (MSXML :: DOMDocument)); pCommandDoc-> put_async (VARIANT_FALSE); pCommandDoc-> put_validateOnParse (VARIANT_FALSE); pCommandDoc-> put_resolveExternals (VARIANT_FALSE); pCommandDoc-> put_preserveWhiteSpace (VARIANT_TRUE); pCommandDoc-> load (. Dlg.GetPathName () GetBuffer (0)); MSXML :: IXMLDOMNodePtr pRootNode = pCommandDoc-> selectSingleNode ( "rowdata"); if (pRootNode == NULL) {return;} // read record set MSXML :: IXMLDOMNodeListPtr pListNode = pRootNode-> selectNodes ( "row"); for (int i = 0; i length; i ) {MSXML :: IXMLDOMNodePtr pNode = pListNode-> Getitem (i); MSXML :: IXMLDOMNodeListPtr pListNode2 = pNode -> Selectnodes ("*"); for (int J = 0; j length; j ) {msxml :: ixmldomnodeptr pnode2 = pListNode2-> GetItem (j); _BSTR_T INFO = PNODE2-> getText (); // Insert a row m_p Recordset-> addnew (); // / Add new record m_precordset-> Putcollect ("ID", _ variant_t (info)); m_precordset-> update (); // saved to the library}} // Data source m_report-> m_Report-> Database-> Tables-> Item [1] -> SetDataSource (_variant_t ((IDispatch *) m_pRecordset)); m_report-> m_CRViewer1.SetReportSource (m_report-> m_Report); // refresh m_report-> M_crViewer1.viewRewReport (); m_report-> m_crviewer1.refresh (); m_precordset-> close ();

转载请注明原文地址:https://www.9cbs.com/read-71658.html

New Post(0)