DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Table values visibility at DIAdem report script

Hello,

I have some problems with table values visibility at DIAdem report script - after I generate few tables at different sheets at DIAdem Report, I could only see results of the last one.
Even that, when I manually change anything at last sheet the values which was visible before, after that change disappear, and I don't know why.


File with script is at attachment.

0 Kudos
Message 1 of 2
(1,509 Views)

GRAPHObjOpen() is obsolete.  Try the example below and adapt it to your needs.  

 

Spoiler

Dim sFilePathRpt
sFilePathRpt = CurrentScriptPath & "Rpt_2D_table.TDR"
Call Report.NewLayout
Call bPopulateTbl(sFilePathRpt)
'If Report.Sheets.Exists("Sheet 1") Then Call Report.Sheets.Remove("Sheet 1")
'Call bShowReportObjects()
Report.Settings.Page.Grid.Enable = False
Call WndShow("REPORT")


Function bPopulateTbl(ByVal sFilePathRpt)
Call Report.AppendLayout(sFilePathRpt)
Dim oRptSht, oRptObj
Dim oGrp, oChn, oCol

Set oRptSht = Report.ActiveSheet
Call Report.Refresh

Call Data.Root.Clear
Call Data.Root.Properties.Add("datetime", now,DataTypeDate)
Set oGrp = Data.Root.ChannelGroups.Add("Table1")
Set oChn = oGrp.Channels.Add("Col1",DataTypeChnString)
oChn.Values(1) = "Col1 Row1"
oChn.Values(2) = "Col1 Row2"
oChn.Values(3) = "Col1 Row3"

Set oChn = oGrp.Channels.Add("Col2",DataTypeChnString)
oChn.Values(1) = "Col2 Row1"
oChn.Values(2) = "Col2 Row2"
oChn.Values(3) = "Col2 Row3"

Set oChn = oGrp.Channels.Add("Col3",DataTypeChnString)
oChn.Values(1) = "Col3 Row1"
oChn.Values(2) = "Col3 Row2" & vbCrLf & "Row2a" & vbCrLf & "Row2b"
oChn.Values(3) = "Col3 Row3"

Set oRptObj = oRptSht.Objects.Item("RptTitle")
oRptObj.Text = "2D Table"

Set oRptObj = oRptSht.Objects.Item("RptSubtitle")
oRptObj.Text = "Sub Title"

Set oRptObj = oRptSht.Objects.Item("FileMetaData")
oRptObj.Text = ""
oRptObj.Text = oRptObj.Text & "TDMS: " & Data.Root.Name & vbCrLf
oRptObj.Text = oRptObj.Text & "Recorded: " & Str(Data.Root.Properties("datetime").Value,"#dd-ttt-yyyy hh:nn") & vbCrLf
oRptObj.Text = oRptObj.Text & "Recorded by: " & Data.Root.Properties("Author").Value & vbCrLf

Set oRptObj = oRptSht.Objects.Item("2DTable1")
Call oRptObj.Columns.RemoveAll
For Each oChn In oGrp.Channels
Set oCol = oRptObj.Columns.Add(e2DTableColumnChannel)
oCol.Channel.Reference = oChn.GetReference(eRefTypeNameName)

oCol.Settings.Font.Size = 5
oCol.Settings.Font.Bold = False
'oCol.Settings.Font.Color.SetPredefinedColor(eColorIndexBlue)
'oCol.Settings.Font.BackColor.ColorIndex =eColorIndexTurquoise 'background only for the text, not the cell
oCol.Settings.UseWordWrap = True 'All table colum cell text to wrap (except for header)

oCol.Settings.Header.IndividualSettings.Enable = True
oCol.Settings.Header.IndividualSettings.UseWordWrap = True 'Text wrap column header
oCol.Settings.Header.IndividualSettings.BackgroundColor.ColorIndex = eColorIndexTurquoise
'oCol.Settings.Header.IndividualSettings.Font.Color.SetPredefinedColor(eColorIndexBlue)
oCol.Settings.Header.IndividualSettings.Font.Size = 5
oCol.Settings.Header.IndividualSettings.Font.Bold = True

oCol.Settings.Header.IndividualTitle.Enable = True 'Titles below won't work without .Enable = True
oCol.Settings.Header.IndividualTitle.TitleDefinition1 = e2DTableTitleFree
oCol.Settings.Header.IndividualTitle.Title1 = oChn.GetReference(eRefTypeNameName)
'oCol.Settings.Header.IndividualTitle.TitleDefinition2 = e2DTableTitleFree
'oCol.Settings.Header.IndividualTitle.Title2 = "Title 2"
'oCol.Settings.Header.IndividualTitle.TitleDefinition3 = e2DTableTitleFree
'oCol.Settings.Header.IndividualTitle.Title3 = "Title 3"
Next
oRptObj.Settings.UseAutoFontSize = False
'oRptObj.Settings.IndexSettings.IndexMode=e2DTableIndexModeAutomaticallyIncreasing
'oRptObj.Settings.HideEmptyLines = True 'Only valid for IndexMode = e2DTableIndexModeAutomaticallyIncreasing
''OR..
oRptObj.Settings.IndexSettings.IndexMode=e2DTableIndexModeAutomaticallyRowHeigth

'Adjust table header
'oRptObj.Settings.Header.UseWordWrap = True
'oRptObj.Settings.Header.Alignment = e2DTableAlignmentCentric
'oRptObj.Settings.Header.UseAutoFontSize = False
'oRptObj.Settings.Header.Font.Size = 5
'oRptObj.Settings.Header.Font.Bold = True
'oRptObj.Settings.Header.Title1 = "Title1" 'Affects EVERY column header
''oRptObj.Settings.Header.Title2 = "Title2"
''oRptObj.Settings.Header.BackgroundColor.ColorIndex = eColorIndexTurquoise
'oRptObj.Settings.Header.ShowGridLines = True
''oRptObj.Settings.Header.Height = 20
''Customize column #2
'Set oCol = oRptObj.Columns.Item(2)
'oCol.Settings.Header.IndividualSettings.Enable = True
'oCol.Settings.Header.IndividualSettings.Font.Size = 5
'oCol.Settings.Header.IndividualSettings.Font.Bold = True
'oCol.Settings.Header.IndividualSettings.Font.Color.SetPredefinedColor(eColorIndexBlue)
'oCol.Settings.Header.IndividualTitle.Enable = True 'Title below requires this enabled!
'oCol.Settings.Header.IndividualTitle.Title1 = "Col 2 Title 1"
'oCol.Settings.Header.IndividualTitle.Title2 = "Col 2 Title 2"
'oCol.Settings.Header.IndividualTitle.Title3 = "Col 2 Title 3"

Set oRptSht = Nothing: Set oRptObj = Nothing
Call Report.Refresh
'Call oRptObj.ShowPropertiesDlg()
End Function 'bPopulateTbl()

NOTE:  It is considerably easier to create a custom report layout (template) with the objects (2D chart, table, text box) placed and formatted and then update those objects with specific references and values that it is to programmatically set all of the formatting options. 

0 Kudos
Message 2 of 2
(1,422 Views)