Firstly, I'm grateful for the time that has gone into this nice assembly. I work with VB.NET, and have been successful with creating a customer list from there. I note that many properties in this assembly are, as far as VB.NET (case insensitive) is concerned, the same name. I did a replace all throughout the report.net library and changed the following:
It seems to work fine... I wonder if there's anything I'm missing with this adjustment? It should work without any problems, no? And this leads me to this question: why not rename these members so as to make the Report.NET assembly compatible with VB.NET? Or maybe I'm showing my inexperience and there's a simple/obvious way to handle this situation.
Thanks again for the good work!
Kel
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I renamed all instances with case-insensitive duplicates to the same name with an underscore and then recompiled the library. I really question why it was designed is a way that excludes ~40% of .NET programmers. In any case though, it was an easy work-around. Here's some sample code I used to create a simple customer list table report:
If you have problems recompiling the updated report.net library, you can post your email address and I'll send you my recompiled dll.
Good luck - Kel
Public Class rCustomerList
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim CustList As New CustomerList()
' Set the Sales Engineer name and Employee number for the title and query generation, respectively.
CustList.UserName = User.Identity.Name
CustList.EmployeeNumber = CType(Session("userid"), String)
' Send to the client browser
RT.ResponsePDF(CustList, Response)
End Sub
End Class
Public Class CustomerList
Inherits Report
Private _UserName As String
Private _EmployeeNumber As String
Private fd As FontDef
Private rPosLeft As Double = 13
Private rPosRight As Double = 202.9
Private rPosTop As Double = 13
Private rPosBottom As Double = 266.4
Private rTotalWidth As Double = rPosRight - rPosLeft ' rTotalWidth is the total workable space in the report
WriteOnly Property UserName()
Set(ByVal Value)
_UserName = Value
End Set
End Property
WriteOnly Property EmployeeNumber()
Set(ByVal Value)
_EmployeeNumber = Value
End Set
End Property
Protected Overrides Sub Create()
' Define Main body Font Properties
fd = New FontDef(Me, "Arial")
Dim fp As New FontProp(fd, 4)
' Define Header Font Properties
Dim fp_Header As New FontProp(fd, 6)
fp_Header.bBold = True
' Define Footer Font Properties
Dim fp_Footer As New FontProp(fd, 2.5)
fp_Footer.bItalic = True
' Define cell background Properties
Dim bp_Alternating As New BrushProp(Me, Drawing.Color.Ivory)
' Create Table
Dim tlm As New TableLayoutManager(fp_Header)
tlm.rContainerHeightMM = rPosBottom - rPosTop ' Set the height of the table
tlm._cellDef.pp_LineBottom = New PenProp(Me, 0.1, Drawing.Color.Black)
tlm._headerCellDef.rAlignV = RepObj.rAlignCenter
' Define Columns (column widths = % of Total width of workable space. Sum obviously should = 1.0)
Dim col As TableLayoutManager.Column
col = New TableLayoutManager.ColumnMM(tlm, "Customer Name", 0.25D * rTotalWidth)
col = New TableLayoutManager.ColumnMM(tlm, "Cust. #", 0.075D * rTotalWidth)
col = New TableLayoutManager.ColumnMM(tlm, "Location", 0.15D * rTotalWidth)
col = New TableLayoutManager.ColumnMM(tlm, "Dealer", 0.075D * rTotalWidth)
col = New TableLayoutManager.ColumnMM(tlm, "Notes", 0.45D * rTotalWidth)
Dim con As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim cmd As New SqlCommand("SELECT Name1, cuno, City, State, Dealer, Notes FROM t_Customers WHERE SalesRep = " & _
_EmployeeNumber & " ORDER BY Name1", con)
con.Open()
Dim reader As SqlDataReader = cmd.ExecuteReader()
Dim i As Int16 = 0 ' For alternating row colors
While reader.Read()
' If we're on an odd numbered row, then change the background to light gray
If i Mod 2 = 0 Then
tlm._cellDef.bp_Back = Nothing
Else
tlm._cellDef.bp_Back = bp_Alternating
End If
tlm.NewRow()
tlm.Add(0, New RepString(fp, reader.GetString(0)))
tlm.Add(1, New RepString(fp, reader.GetString(1)))
tlm.Add(2, New RepString(fp, reader.GetString(2) & ", " & reader.GetString(3)))
tlm.Add(3, New RepString(fp, MagSharedFunctions.getYesOrNo(reader(4))))
tlm.Add(4, New RepString(fp, reader.GetString(5)))
i += 1
End While
reader.Close()
reader = Nothing
con.Close()
con = Nothing
' Add Page level output - page number and current date and time.
Dim thePage As Root.Reports.Page
For Each thePage In enum_Page
Dim rY As Double = rPosBottom + 1.5
thePage.AddLT_MM(rPosLeft, rY, New RepString(fp, DateTime.Now.ToShortDateString() & " @ " & _
DateTime.Now.ToShortTimeString()))
thePage.AddRT_MM(rPosRight, rY, New RepString(fp, "Page " & thePage.iPageNo.ToString() & " / " & _
iPageCount.ToString()))
Next
End Sub
Private Sub Tlm_NewContainer(ByVal sender As Object, ByVal ea As TableLayoutManager.NewContainerEventArgs)
Dim newPage As New Root.Reports.Page(Me)
newPage.rWidthMM = 215.9 ' 8.5"
newPage.rHeightMM = 279.4 ' 11"
If (page_Cur.iPageNo = 1) Then
Dim fp_Title As New FontProp(fd, 10)
fp_Title.bBold = True
page_Cur.AddCT_MM(rPosLeft + (rPosRight - rPosLeft) / 2, rPosTop, New RepString(fp_Title, _UserName & "'s Customer List"))
ea.container.rHeightMM -= fp_Title.rLineFeedMM ' Reduce height of table container for the first page
End If
' Add new container to current page
page_Cur.AddMM(rPosLeft, rPosBottom - ea.container.rHeightMM, ea.container)
End Sub
End Class
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for your prompt reply, however i was not successful. Partly it is due to the poor knowledge i have on C# hence i couldn't relate it much. Can I have the modified dll as you have mentioned. My email address is rammuraly@yahoo.co.uk.
Once again Thanks for your time.
Regards
Murali
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I sent you this in an email, but for the possible benefit of anyone who attempts to help you with this:
My code works fine to create a table report if there is enough data to fill up more than one page. If there isn't, however, the table is not rendered. This didn't show itself until late in the game for me, and my company has since moved on to a commercial PDF report writer so I didn't bother looking into it...
Kel
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can I also have the modified dll for vb.net email to me. I tried to modify the dll as you mentioned but was not successful. My email address is vang_houa@hotmail.com.
Thank you.
Kevin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
Firstly, I'm grateful for the time that has gone into this nice assembly. I work with VB.NET, and have been successful with creating a customer list from there. I note that many properties in this assembly are, as far as VB.NET (case insensitive) is concerned, the same name. I did a replace all throughout the report.net library and changed the following:
columnDef --> _columnDef
headerRowDef --> _headerRowDef
rowDef --> _rowDef
tableHeight --> _tableHeight
cellDef --> _cellDef
headerCellDef --> _headerCellDef
It seems to work fine... I wonder if there's anything I'm missing with this adjustment? It should work without any problems, no? And this leads me to this question: why not rename these members so as to make the Report.NET assembly compatible with VB.NET? Or maybe I'm showing my inexperience and there's a simple/obvious way to handle this situation.
Thanks again for the good work!
Kel
Hi Can you please let me know how you solved this problem. I am using vb.net and I am unable to use the objects you have mentioned.
>>columnDef --> _columnDef
>>headerRowDef --> _headerRowDef
>>rowDef --> _rowDef
>>tableHeight --> _tableHeight
>>cellDef --> _cellDef
>>headerCellDef --> _headerCellDef
If you can post some sample code it would go a long way in helping me.
Thanks and Regards
Murali
Hi rammuraly,
I renamed all instances with case-insensitive duplicates to the same name with an underscore and then recompiled the library. I really question why it was designed is a way that excludes ~40% of .NET programmers. In any case though, it was an easy work-around. Here's some sample code I used to create a simple customer list table report:
If you have problems recompiling the updated report.net library, you can post your email address and I'll send you my recompiled dll.
Good luck - Kel
Public Class rCustomerList
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim CustList As New CustomerList()
' Set the Sales Engineer name and Employee number for the title and query generation, respectively.
CustList.UserName = User.Identity.Name
CustList.EmployeeNumber = CType(Session("userid"), String)
' Send to the client browser
RT.ResponsePDF(CustList, Response)
End Sub
End Class
Public Class CustomerList
Inherits Report
Private _UserName As String
Private _EmployeeNumber As String
Private fd As FontDef
Private rPosLeft As Double = 13
Private rPosRight As Double = 202.9
Private rPosTop As Double = 13
Private rPosBottom As Double = 266.4
Private rTotalWidth As Double = rPosRight - rPosLeft ' rTotalWidth is the total workable space in the report
WriteOnly Property UserName()
Set(ByVal Value)
_UserName = Value
End Set
End Property
WriteOnly Property EmployeeNumber()
Set(ByVal Value)
_EmployeeNumber = Value
End Set
End Property
Protected Overrides Sub Create()
' Define Main body Font Properties
fd = New FontDef(Me, "Arial")
Dim fp As New FontProp(fd, 4)
' Define Header Font Properties
Dim fp_Header As New FontProp(fd, 6)
fp_Header.bBold = True
' Define Footer Font Properties
Dim fp_Footer As New FontProp(fd, 2.5)
fp_Footer.bItalic = True
' Define cell background Properties
Dim bp_Alternating As New BrushProp(Me, Drawing.Color.Ivory)
' Create Table
Dim tlm As New TableLayoutManager(fp_Header)
tlm.rContainerHeightMM = rPosBottom - rPosTop ' Set the height of the table
tlm._cellDef.pp_LineBottom = New PenProp(Me, 0.1, Drawing.Color.Black)
tlm._headerCellDef.rAlignV = RepObj.rAlignCenter
AddHandler tlm.eNewContainer, AddressOf Tlm_NewContainer
' Define Columns (column widths = % of Total width of workable space. Sum obviously should = 1.0)
Dim col As TableLayoutManager.Column
col = New TableLayoutManager.ColumnMM(tlm, "Customer Name", 0.25D * rTotalWidth)
col = New TableLayoutManager.ColumnMM(tlm, "Cust. #", 0.075D * rTotalWidth)
col = New TableLayoutManager.ColumnMM(tlm, "Location", 0.15D * rTotalWidth)
col = New TableLayoutManager.ColumnMM(tlm, "Dealer", 0.075D * rTotalWidth)
col = New TableLayoutManager.ColumnMM(tlm, "Notes", 0.45D * rTotalWidth)
Dim con As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim cmd As New SqlCommand("SELECT Name1, cuno, City, State, Dealer, Notes FROM t_Customers WHERE SalesRep = " & _
_EmployeeNumber & " ORDER BY Name1", con)
con.Open()
Dim reader As SqlDataReader = cmd.ExecuteReader()
Dim i As Int16 = 0 ' For alternating row colors
While reader.Read()
' If we're on an odd numbered row, then change the background to light gray
If i Mod 2 = 0 Then
tlm._cellDef.bp_Back = Nothing
Else
tlm._cellDef.bp_Back = bp_Alternating
End If
tlm.NewRow()
tlm.Add(0, New RepString(fp, reader.GetString(0)))
tlm.Add(1, New RepString(fp, reader.GetString(1)))
tlm.Add(2, New RepString(fp, reader.GetString(2) & ", " & reader.GetString(3)))
tlm.Add(3, New RepString(fp, MagSharedFunctions.getYesOrNo(reader(4))))
tlm.Add(4, New RepString(fp, reader.GetString(5)))
i += 1
End While
reader.Close()
reader = Nothing
con.Close()
con = Nothing
' Add Page level output - page number and current date and time.
Dim thePage As Root.Reports.Page
For Each thePage In enum_Page
Dim rY As Double = rPosBottom + 1.5
thePage.AddLT_MM(rPosLeft, rY, New RepString(fp, DateTime.Now.ToShortDateString() & " @ " & _
DateTime.Now.ToShortTimeString()))
thePage.AddRT_MM(rPosRight, rY, New RepString(fp, "Page " & thePage.iPageNo.ToString() & " / " & _
iPageCount.ToString()))
Next
End Sub
Private Sub Tlm_NewContainer(ByVal sender As Object, ByVal ea As TableLayoutManager.NewContainerEventArgs)
Dim newPage As New Root.Reports.Page(Me)
newPage.rWidthMM = 215.9 ' 8.5"
newPage.rHeightMM = 279.4 ' 11"
If (page_Cur.iPageNo = 1) Then
Dim fp_Title As New FontProp(fd, 10)
fp_Title.bBold = True
page_Cur.AddCT_MM(rPosLeft + (rPosRight - rPosLeft) / 2, rPosTop, New RepString(fp_Title, _UserName & "'s Customer List"))
ea.container.rHeightMM -= fp_Title.rLineFeedMM ' Reduce height of table container for the first page
End If
' Add new container to current page
page_Cur.AddMM(rPosLeft, rPosBottom - ea.container.rHeightMM, ea.container)
End Sub
End Class
Hi Kelway,
Thanks for your prompt reply, however i was not successful. Partly it is due to the poor knowledge i have on C# hence i couldn't relate it much. Can I have the modified dll as you have mentioned. My email address is rammuraly@yahoo.co.uk.
Once again Thanks for your time.
Regards
Murali
Hi i was able to work that out. I was stupid enough to ask you back quickly. Any way thanks for your help.
Thanks and Regards
Murali
I used the sample code,
but mu table are hidden.
Somebody have an idea?
I sent you this in an email, but for the possible benefit of anyone who attempts to help you with this:
My code works fine to create a table report if there is enough data to fill up more than one page. If there isn't, however, the table is not rendered. This didn't show itself until late in the game for me, and my company has since moved on to a commercial PDF report writer so I didn't bother looking into it...
Kel
Missing tlm.Close() in your code.
This command render tables.
Hi Kelway (Anyone),
Can I also have the modified dll for vb.net email to me. I tried to modify the dll as you mentioned but was not successful. My email address is vang_houa@hotmail.com.
Thank you.
Kevin