+ All Categories
Home > Documents > ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object,...

ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object,...

Date post: 05-Apr-2018
Category:
Upload: phamdiep
View: 223 times
Download: 4 times
Share this document with a friend
45
EMu Release Notes ADO Reports EMu 5.0 Document Version 1
Transcript
Page 1: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

EMu Release Notes

ADO Reports EMu 5.0

Document Version 1

Page 2: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report
Page 3: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Contents

S E C T I O N 1 ADOReports 1 

Note 1 

S E C T I O N 2 CrystalReports 3 

How to create a Crystal ADO Report 3 How to modify a Crystal Report to use ADO instead of ODBC 10 

S E C T I O N 3 MicrosoftExcel 21 

How to create an Excel Report using the ADO RecordSet 21 How to create an Excel Report with nested tables using the ADO RecordSet 32 

S E C T I O N 4 Registryentries 39 

Index 41 

Page 4: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report
Page 5: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

ADO Reports

ADO Reports  

1

ADOReportsReportgenerationandperformancehavebeenimprovedwithEMu5.0anditisnowpossibletoreportdirectlytoanOpenDatabaseConnectivity(ODBC)datasourceandto anActiveXDataObjects (ADO)RecordSetobject, bypassing theODBC filteringprocess.

Thenewreportoptionsare:

CrystalReports:reportdirectlyinODBCformat,bypassingtheODBCfilteringprocess.

CrystalADO:reportusingADORecordSetsforCrystal(whichareaccessibleviaCrystal'sADOconnector).

MicrosoftADO:reportusingADORecordSetsforMicrosoftproducts.

CrystalandMicrosoftreports(Excel,PowerPointandWord)whichcurrentlyconnecttoanODBCdatasourcecanbemodifiedtouseanADORecordSet.ItremainspossibletocreatereportsbyconnectingdirectlytoanODBCdatasource.

NoteThisdocumentassumesfamiliaritywithReportcreationinEMu.FulldetailsaboutReport Creation are available in the EMu Help: Working with EMurecords>Reports.

S E C T I O N 1

Page 6: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report
Page 7: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Crystal Reports

ADO Reports  

3

CrystalReportsCreating a Crystal Report using the new ADO RecordSet is similar to creating aCrystalreportwithadirectODBCconnection.Themaindifferencesareinselectingthedatasource.Thisdocumentdescribesthedifferences.

HowtocreateaCrystalADOReportInEMu:

1. Searchfororotherwiselistagroupofrecordsonwhichtoreport.

WhendesigningaCrystalADOreporttherecordsinyourinitialrecordsetmusthaveavalueineachfieldtobeincludedinthereport.Ifnot,thefieldnamewillnotappearinthelistofavailablecolumns.Oncethereportisdefined,itdoesnotmatterifarecorddoesnothavevaluesineveryfieldincludedinthereport.

2. ClickReports intheToolbartodisplaytheReportsbox.

3. Click intheReportsbox.TheReportPropertiesboxdisplays.

4. EnteradescriptivenamefortheReportinthetoptextfield.5. SelectCrystalADOReportfromtheTypedroplist:

S E C T I O N 2

Page 8: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Crystal Reports

4  

ADO Reports

6. OntheFieldstab,addthefieldstobeincludedinthereport.

Inthisexamplethefieldsselectedare:

Page 9: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Crystal Reports

ADO Reports  

5

NotethatagroupwascreatedusingtheCreateGroup button.7. Makechangesontheothertabsasrequired.

SeetheEMuHelpfordetailsaboutsettingasortorder,sortoptions,andsecurity.

8. Click .ThenewreportisaddedtotheReportsbox.

9. In the Reports box, select the new report and click to run thereportforthefirsttime.Amessagewilldisplayindicatingthatyourreportdoesnotexistontheserver.ThisistobeexpectedasthereporthasnotyetbeenbuiltinCrystalReports:

10. Click .An xml file is generated and savedwith the data from your record set. Thelocationofthisfilecanvary,buttypicallyitcanbefoundin:C:\Users\[yourusername]\AppData\Local\KESoftware\Reports\e[modulename]

Page 10: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Crystal Reports

6  

ADO Reports

Forexample,areportruninthePartiesmodule,willsavethexmldatafileto:C:\Users\[yourusername]\AppData\Local\KESoftware\Reports\epartiesTheCrystalReportsDesignerapplicationwillopen.

11. OntheStartPageoftheCrystalReportsDesigner,selectBlankReportundertheNewReportsheading‐OR‐SelectFile>New>BlankReportintheMenubar.TheDatabaseExpertboxdisplays:

12. Double‐clickCreateNewConnectionandclick besideADO.NET(XML):

Page 11: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Crystal Reports

ADO Reports  

7

Thefollowingscreenwilldisplay:

Page 12: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Crystal Reports

8  

ADO Reports

13. ClickthebuttonbesidetheFilePathfieldtolocateandselectthexmldata.xmlfilecreatedwhenthereportwasfirstrun(Step9).SeeStep10fordetailsofthelocationofthexmldata.xmlfile.

14. Click toreturntotheDatabaseExpert:

Group 1containsvaluesfromfieldsthatwegroupedintheEMureportinthisexample(seeStep6).Thesefieldsaretablesofvalues(theycanholdmorethanonevalue).Thisdataneedstobeaddedtoourreportusingasub‐report(seetheEMuHelpfordetails).FieldvaluesfromtheCataloguearecontainedinthetablecalledrow.

15. SelectrowandaddittotheSelectedTablespane:

Page 13: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Crystal Reports

ADO Reports  

9

16. Click .The Crystal Report Designer displays, ready for you to design your Crystalreport.SeetheEMuHelpfordetailsofdesigningaCrystalReport.

It is importantnot tomove thexmldata.xml fileas thiswill causeproblemswhensharingthereportwithotherusers.

Page 14: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Crystal Reports

10  

ADO Reports

HowtomodifyaCrystalReporttouseADOinsteadofODBC

TomodifyaCrystalReporttouseADOratherthanODBC:

1. OpentheReportPropertiesdialogueforthereport.ThisexampleusesthedefaultreportList (A4).

2. SelectCrystalADOReportfromtheTypedroplist:

Thefieldsforthisreportare:

Page 15: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Crystal Reports

ADO Reports  

11

Twotablesaregeneratedinthisreport.

3. Click andrunthereport.CrystalwillcreatetheADOrecordsetandthefollowingerrorwilldisplay:

4. Open the Crystal report in the Crystal Report Designer and select the

Database>SetDatasourceLocationmenuoption.TheSetDatasourceLocationdialoguewilldisplay:

Page 16: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Crystal Reports

12  

ADO Reports

5. SelectCreateNewConnection in theReplacewithpaneandclick beside

ADO.NET(XML).Thefollowingscreenwilldisplay:

Page 17: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Crystal Reports

ADO Reports  

13

6. ClickthebuttonbesidetheFilePathfieldtolocateandselectthexmldata.xml

filecreatedwhenthereportwasrun.Thelocationofthisfilecanvary,buttypicallyitcanbefoundin:C:\Users\[yourusername]\AppData\Local\KESoftware\Reports\e[modulename]Forexample,areportruninthePartiesmodule,willsavethexmldatafileto:C:\Users\[yourusername]\AppData\Local\KESoftware\Reports\eparties

7. Click .YouarereturnedtotheSetDatasourceLocationdialogue:

Page 18: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Crystal Reports

14  

ADO Reports

NextitisnecessarytomapfieldsfromtheoldODBCdatasourcetothenewADORecordSet.Inthisexampletherearetwotablestomapandonesub‐report.

8. To map the old ODBC Catalogue fields to the new Catalogue table, clickecatalogue_csvintheCurrentDataSourcepaneandthenclicktherowtableintheReplacewithpane.TheUpdatebuttonwillbeenabled.

9. ClicktheUpdatebuttonandtheMapFieldsdialoguewilldisplay:

Page 19: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Crystal Reports

ADO Reports  

15

Fieldswiththesamenamewillbemappedautomatically.

10. UnchecktheMatchtypecheckboxtorevealmorefieldsintheUnmappedFieldspane:

Page 20: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Crystal Reports

16  

ADO Reports

11. CompletemappingfieldsintheUnmappedFieldspane.

Inthisexamplewemapecatalogue_keytoecatalogue_keyandirntoirnbyselectingbothfieldstomapandclickingtheMapbutton.Oncemapped,fieldswillbemovedtotheMappedFieldspane:

Page 21: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Crystal Reports

ADO Reports  

17

12. Click whenallfieldsaremapped.

YouarereturnedtotheSetDatasourceLocationdialogue.13. Repeatthemappingprocessforallfields(inthisexample,mappingfieldsinthe

CreatorD_csvtabletotheADOtableCreatorDetails):

Page 22: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Crystal Reports

18  

ADO Reports

14. OnceallfieldshavebeenremappedinalltablesclickClose.

YouarereturnedtotheCrystaldesignwindow.Ifyourefreshreportdataatthisstageandyouhaveasub‐reportobject,youwillprobablyreceiveanerrorregardingsub‐reportlinks,e.g.:

Page 23: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Crystal Reports

ADO Reports  

19

Click toopentheRecordSelectionFormulaEditor.ChangethelinkkeyfieldusedbytheoldODBCtabletothelinkkeyfieldreferencedbytheADORecordSet:

Thereportshouldnowworkcorrectly.

Page 24: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report
Page 25: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Microsoft Excel

ADO Reports  

21

MicrosoftExcel

The following examples demonstrate how to create a basic Excelreport using VBA. Please note that it is not the intention of thisdocumenttoteachVBA.Excel2013wasusedtocreatethesereports.

HowtocreateanExcelReportusingtheADORecordSet

WithODBCdatasourcesthereisanoptioninExceltoopenaconnectionwithoutwritingVisualBasiccode.ThisisnotthecasewhenmakingaconnectiontoanADOrecordsetanditisnecessarytowriteVBcode.

S E C T I O N 3

Page 26: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Microsoft Excel

22  

ADO Reports

Step1:CreateanewreportinEMuThis first example is a simple report on single value fields from the Cataloguemodule. The VBA code provided in this example will automatically populateheadingsandrowdataforeachcolumnselected.

InEMu:

1. Searchfororotherwiselistagroupofrecordsonwhichtoreport.

2. ClickReports intheToolbartodisplaytheReportsbox.

3. Click intheReportsbox.TheReportPropertiesboxdisplays.

4. EnteradescriptivenamefortheReportinthetoptextfield.5. SelectMicrosoftADOReportfromtheTypedroplist:

6. OntheFieldstab,addthefieldstobeincludedinthereport.

Fieldsselectedinthisexampleare:

Page 27: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Microsoft Excel

ADO Reports  

23

7. Makechangesontheothertabsasrequired.

SeetheEMuHelpfordetailsaboutsettingasortorder,sortoptions,andsecurity.

8. Click .ThenewreportisaddedtotheReportsdialoguebox.

9. Selectthenewreportandclick torunthereportforthefirsttime.Amessagewilldisplayindicatingthatyourreportdoesnotexistontheserver.ThisistobeexpectedasthereporthasnotyetbeenbuiltinExcel:

10. Click .An xml file is generated and savedwith the data from your record set. Thelocationofthisfilecanvary,buttypicallyitcanbefoundin:C:\Users\[yourusername]\AppData\Local\KESoftware\Reports\e[modulename]Forexample,areportruninthePartiesmodule,willsavethexmldatafileto:C:\Users\[your

Page 28: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Microsoft Excel

24  

ADO Reports

username]\AppData\Local\KESoftware\Reports\epartiesMicrosoftExcelwillopenwithablankworksheetasfollows:

Page 29: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Microsoft Excel

ADO Reports  

25

EnsurethatExcelissetupcorrectly

IftheDevelopertabdoesnotdisplayintheRibbon:

1. ClickFile>Options>CustomizeRibbon.2. WithMainTabsselectedfromtheCustomizetheRibbondroplist(1),selectthe

Developercheckbox(2):

Inordertorunthemacrosthatwewillcreatewithourreports,weneedtoensurethattheSecuritylevelinExcelisappropriate:

1. OntheDevelopertab,click .2. Enableallmacros:

Page 30: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Microsoft Excel

26  

ADO Reports

3. Click toclosetheTrustCenter.

4. OntheDevelopertab,click .Thefollowingscreendisplays:

Page 31: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Microsoft Excel

ADO Reports  

27

5. EnsurethattheMicrosoftActiveXDataObjectsLibraryisavailable:5.1. SelectTools>ReferencesintheMenubar

IntheReferences–VBAProjectdialoguethatdisplays,makesurethatthefollowingcheckboxischecked:

5.2. Click .

Page 32: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Microsoft Excel

28  

ADO Reports

Step2:DesignthereportinExcel1. Double‐clickSheet1intheVBAProjectpane:

2. CopyandpastethefollowingVBcode:Sub OpenAdoFile() Dim RecordSet As ADODB.RecordSet Dim Worksheet As Excel.Worksheet Dim h As Long Dim col As Long Dim datarow As Long Dim source As String ' Get the persisted record set source = Environ("LocalAppData") & "\KESoftware\ Reports\ecatalogue\xmldata.xml" Set RecordSet = New ADODB.RecordSet RecordSet.Open source, "Provider=MSPersist" ' Get the active page to send the data to Set Worksheet = ThisWorkbook.ActiveSheet Application.Visible = True ' Put out all of the column headers col = 1

Page 33: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Microsoft Excel

ADO Reports  

29

ListColumnNames Worksheet, RecordSet, col ' Print out all the row data While Not RecordSet.EOF col = 1 datarow = datarow + 1 For h = 0 To RecordSet.Fields.count - 1 Worksheet.Cells(datarow + 1, col).Value = RecordSet.Fields(h).Value col = col + 1 Next RecordSet.MoveNext Wend Worksheet.Range("A1").CurrentRegion.Select Worksheet.Columns.AutoFit Set RecordSet = NothingEnd SubPrivate Sub ListColumnNames(ByVal ws As Excel.Worksheet, ByVal rs As ADODB.RecordSet, ByRef col As Long) Dim i As Long ' Loop through the record set pulling out the column names For i = 0 To rs.Fields.count - 1 ws.Cells(1, col).Value = rs.Fields(i).Name col = col + 1 NextEnd Sub

Page 34: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Microsoft Excel

30  

ADO Reports

3. Double‐clickThisWorbook in the VBAProject pane and copy and paste thefollowingcode:Sub Workbook_Open()' Load up the ADO FileSheet1.OpenAdoFileEnd Sub

Page 35: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Microsoft Excel

ADO Reports  

31

4. SavethereportanduploadittoyourEMureport(page22)ontheReportTypetaboftheReportPropertiesbox.

WhenthereportisruninEMu,anExcelreportisgenerated:

Page 36: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Microsoft Excel

32  

ADO Reports

HowtocreateanExcelReportwithnestedtablesusingtheADORecordSet

1. RepeatStep1:CreateanewreportinEMu(page22).Forthisexample,thefollowingfieldswereselected.Notethetwonestedtables‐Creator'sNameandPhysical:

2. InExcel,click ontheDeveloperstab.3. Double‐clickSheet1intheVBAProjectpane:4. CopyandpastethefollowingVBcode:

Page 37: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Microsoft Excel

ADO Reports  

33

Sub Read_XML_Data() Dim rst As ADODB.Recordset Dim Worksheet As Excel.Worksheet Dim i As Long Dim j As Long Dim source As String Dim datarow As Long Dim saverow As Long Dim lastrow As Long Dim col As Long ' These next declaration is a little odd. Its needed in cases where the entire value ' of a nested table is blank. In these cases it is necessary to force a number of columns to be skipped when printing ' out field values. Oddly, as long as a nested table has at least one value, then there is no issue. ' There is only a need to declare one variable for each nested table. ' In this example there are only two nested tables so two declarations are needed ' The value assigned to each variable will depend on the number of fields in that nested table. ' In this example the first nested table is the CreCreatorRef_tab, which has two fields, i.e. NamFirst and NamLast ' and the second nested table, i.e Physical, has 3 fields, i.e. PhyType, PhyHeight and PhyWidth Dim firstnestedtable As Long Dim secondnestedtable As Long Dim nestedtablecount As Long firstnestedtable = 2 secondnestedtable = 3 nestedtablecount = 1 ' Get the persisted record set source = Environ("LocalAppData") & "\KESoftware\Reports\ecatalogue\xmldata.xml" Set rst = New ADODB.Recordset rst.Open source, "Provider=MSPersist" ' Get the active page to send the data to Set Worksheet = ThisWorkbook.ActiveSheet Application.Visible = True

Page 38: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Microsoft Excel

34  

ADO Reports

'Add column labels Worksheet.Cells(1, 1).Select ActiveCell.EntireRow.Insert Worksheet.Cells(1, 1).Value = "Record No" Worksheet.Cells(1, 2).Value = "IRN No" Worksheet.Cells(1, 3).Value = "Title" Worksheet.Cells(1, 4).Value = "Date Created" Worksheet.Cells(1, 5).Value = "Creator First" Worksheet.Cells(1, 6).Value = "Creator Last" Worksheet.Cells(1, 7).Value = "Physical Type" Worksheet.Cells(1, 8).Value = "Physical Length" Worksheet.Cells(1, 9).Value = "Physical Width" col = 1 ' Start printing data from Row 3 datarow = 3 lastrow = datarow While Not rst.EOF col = 1 If datarow < lastrow Then datarow = lastrow End If For j = 0 To rst.Fields.Count - 1 If rst.Fields(j).Type = adChapter Then If rst.Fields(j).Value.BOF Then Worksheet.Cells(datarow, col).Value = "" If nestedtablecount = 1 Then col = col + firstnestedtable nestedtablecount = nestedtablecount + 1 ElseIf nestedtablecount = 2 Then col = col + secondnestedtable nestedtablecount = nestedtablecount + 1 End If Else If rst.Fields(j).Value.EOF Then Worksheet.Cells(datarow, col).Value = "" If nestedtablecount = 1 Then col = col + firstnestedtable nestedtablecount = nestedtablecount + 1 ElseIf nestedtablecount = 2 Then

Page 39: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Microsoft Excel

ADO Reports  

35

col = col + secondnestedtable nestedtablecount = nestedtablecount + 1 End If Else saverow = datarow ListNestedValues Worksheet, rst.Fields(j).Value, col, datarow, lastrow, saverow, nestedtablecount End If End If Else If IsNull(rst.Fields(j).Value) Then Worksheet.Cells(datarow, col).Value = "" Else Worksheet.Cells(datarow, col).Value = rst.Fields(j).Value End If col = col + 1 End If Next rst.MoveNext datarow = datarow + 1 nestedtablecount = 1 Wend 'Closing the recordset. rst.Close 'Release object from memory. Worksheet.Range("A1").CurrentRegion.Select Worksheet.Columns.AutoFit Set rst = Nothing End SubPrivate Sub ListNestedValues(ByVal ws As Excel.Worksheet, ByVal rs As ADODB.Recordset, ByRef col As Long, ByRef datarow As Long, ByRef lastrow As Long, ByRef saverow As Long, ByRef nestedtablecount As Long) Dim i As Long Dim j As Long Dim startrow As Long ' Loop through a nested table pulling out the row values j = 0

Page 40: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Microsoft Excel

36  

ADO Reports

startrow = saverow While Not rs.EOF max = 1 j = col For i = 0 To rs.Fields.Count - 1 ' Don't print key values If rs.Fields(i).Name <> "ecatalogue_key" And rs.Fields(i).Name <> "CreCreatorRef_key" And rs.Fields(i).Name <> "Physical_key" _ Then If IsNull(rs.Fields(i).Value) Then ws.Cells(startrow + 1, j).Value = "" j = j + 1 Else If rs.Fields(i).Type = adChapter Then ListNestedValues ws, rs.Fields(i).Value, j, datarow, lastrow, saverow, nestedtablecount datarow = startrow Else ws.Cells(startrow, j).Value = rs.Fields(i).Value j = j + 1 End If End If End If Next rs.MoveNext startrow = startrow + 1 Wend If (j > 0) Then col = j End If If startrow > lastrow Then lastrow = startrow End If nestedtablecount = nestedtablecount + 1End Sub

5. Double‐clickThisWorbook in the VBAProject pane and copy and paste thefollowingcode:Sub Workbook_Open()' Load up the ADO FileSheet1.Read_XML_DataEnd Sub

Page 41: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Microsoft Excel

ADO Reports  

37

6. SavethereportanduploadittoyourEMureport(page22)ontheReportTypetaboftheReportPropertiesbox.

WhenthereportisruninEMu,anExcelreportisgenerated:

Page 42: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report
Page 43: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Registry entries

ADO Reports  

39

RegistryentriesTheTypeRegistryentryindicateswhichexporttypetouseforeachreportrequest.

TheformatofthisRegistryentryis;

System|Setting|Reports|Type|Crystal CSV|value

value is0or1:

0 Generatesdataintheexistingformat.

1 GeneratesdatainthenewCrystalODBCformat.

Ifthisentryisnotpresent,avalueof0isassumed.

System|Setting|Reports|Type|Crystal ADO|value

value is0or2:

0 Generatesdataintheexistingformat.

2 GeneratesdatainthenewCrystalADOrecordset.

Ifthisentryisnotpresent,avalueof0isassumed.

System|Setting|Reports|Type|Microsoft ADO|value

where:

value is0or3:

0 Generatesdataintheexistingformat.

3 GeneratesdatainthenewMicrosoftADOformat.

Ifthisentryisnotpresent,avalueof0isassumed.

S E C T I O N 4

Page 44: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report
Page 45: ADO Reports emu IE 20160105 - emu.axiell.com an ActiveX Data Objects (ADO) RecordSet object, bypassing the ODBC filtering process. The new report options are: Crystal Reports: report

Index

ADO Reports • 1

Crystal Reports • 3

E Ensure that Excel is setup correctly • 25

How to create a Crystal ADO Report • 3

How to create an Excel Report using the ADO RecordSet • 21

How to create an Excel Report with nested tables using the ADO RecordSet • 32

How to modify a Crystal Report to use ADO instead of ODBC • 11

Microsoft Excel • 21

Note • 1

Registry entries • 39

S Step 1 Create a new report in EMu • 22, 31, 32, 36

Step 2 Design the report in Excel • 28


Recommended