Printing Tables

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 1289 Views - Last Post: 30 January 2014 - 11:13 PM Rate Topic: -----

#1 dleduc  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 23-December 13

Printing Tables

Posted 23 December 2013 - 02:31 PM

I would like to print (on a printer) some tables. I might have to resort to something like printing a datagrid, but right now I have the numbers that I want to print in a 2-dimensional array after calculating them. I haven't written any of the code to do this because I am trying to decide what is the best route to take before I commit lots of time to coding. I will admit to having written code to print a page only once so I'm not even very good at doing that although I know I can figure that out if that is the best way to do it.

I want to show what I am trying to achieve and it took m awhile to figure out how to show it. It is in a PDF file located at My link

At this point I'd appreciate suggestions even if they involve cheap commercial software.



`

Is This A Good Question/Topic? 0
  • +

Replies To: Printing Tables

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8849
  • View blog
  • Posts: 33,159
  • Joined: 12-June 08

Re: Printing Tables

Posted 23 December 2013 - 02:46 PM

well.. there's the reporting service print tools.. I find them quite helpful in making an report page used ot print out a dataset passed to it.
Was This Post Helpful? 0
  • +
  • -

#3 dleduc  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 23-December 13

Re: Printing Tables

Posted 23 December 2013 - 08:29 PM

Is that .Net, something commercial, or something else that I will find on the web?
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8849
  • View blog
  • Posts: 33,159
  • Joined: 12-June 08

Re: Printing Tables

Posted 23 December 2013 - 08:31 PM

It's standard with VS.

Right click project -> add -> new -> reporting -> report.
Was This Post Helpful? 1
  • +
  • -

#5 dleduc  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 23-December 13

Re: Printing Tables

Posted 04 January 2014 - 10:37 PM

Sorry, It took me so long to get back to this. I didn't know how long a response might take so I posted while I was away from my code. Thanks for the quick responses.

The report feature looks like it might be really powerful at some point, but it is a big leap from where I am right now since it involves having a dataset which might be a database or at least an object. Right now the table that I want to print is a simple 3-dimensional array. It looks like I just might have to code it from scratch, but I'm still up for other suggestions.
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 8849
  • View blog
  • Posts: 33,159
  • Joined: 12-June 08

Re: Printing Tables

Posted 04 January 2014 - 10:46 PM

the report feature is pretty quick and solid.. I would imagine to 'code it from scratch' would take a substantially longer time.. let alone the 'report' control contains all the needed print functionality one would expect to have.. but, I guess, it is your time to burn how you want.
Was This Post Helpful? 0
  • +
  • -

#7 thecoat  Icon User is offline

  • D.I.C Head

Reputation: 68
  • View blog
  • Posts: 224
  • Joined: 07-December 13

Re: Printing Tables

Posted 05 January 2014 - 02:19 AM

Datasets are in memory objects you don't need a back end database to use them. You can add datatables to datasets, really the most challenging part would be how you want to represent the 3d array in a 2d datatable(s), but really you have to figure that out based on a 2d representation on the report ultimately anyway.
Was This Post Helpful? 0
  • +
  • -

#8 dleduc  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 23-December 13

Re: Printing Tables

Posted 05 January 2014 - 03:32 PM

The 3-d to 2-d part is easy and already figured out. The third dimension is simply another table. I did this code about 30 years ago in BASICA and I'm just trying to update what I once did in a more modern environment.

While the 3-d array is not currently a dataset, I am using a dataset in memory for the new editing part of my code so I could convert the array to a dataset. However, I did spend a few minutes playing with the report feature and I tried to hook it up to my existing dataset but when I browsed for it I didn't see it. How do I make it visible do the report feature?

One of the other ideas that I have been thinking about is to produce my tables as an html page since tables are pretty easy in that format. Two problems occur to me with that: one is that I'm leaving the printing to the user, and the other is that pagination. Either of these problems might have simple solutions, but I haven't gone beyond the thinking about it stage yet. Does anybody have any thoughts on this route? As I said at the beginning of this process, currently I'm exploring possible routes rather than specific code. However, the answer to seeing the dataset would help in that route exploration. Thanks again.
Was This Post Helpful? 0
  • +
  • -

#9 thecoat  Icon User is offline

  • D.I.C Head

Reputation: 68
  • View blog
  • Posts: 224
  • Joined: 07-December 13

Re: Printing Tables

Posted 06 January 2014 - 12:26 AM

The easiest approach would be to add a dataset to the project solution. If you are creating one in code at runtime you can't really use the object with the reports wizard simply because it doesn't exist until runtime. Creating a dataset then replacing it can work but from my experience can get rather involved. By adding the dataset to the solution then creating the structure you want for the datatable, the visual studio designer can access the structure and knows about the various fields etc for the report designer. Then in your code you use the datatable(s) from the dataset instead of one you declare at runtime.
Was This Post Helpful? 1
  • +
  • -

#10 dleduc  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 23-December 13

Re: Printing Tables

Posted 18 January 2014 - 11:36 PM

With your suggestions I've now been able to add a data source to my solution that is not generated in code although I have not yet populated it. I was able to create some form of rudimentary report as well but I'm a long way from creating an easy report output. I looked up how to populate a table and found code that looks like this

                   	table.Rows.Add(25, "Indocin", "David", DateTime.Now)  


Now I have added a DataSet to my solution called OutputData and in it I have created a table called trees with 4 columns
in it, but the following code will not work to populate it.
   OutputData.Trees.Rows.add(SpeciesList(s).Name, d, l, ntrees(s, d, l), volume(s, d, l)) 


I get an error message in Visual Studio telling me that "Reference to a non-shared member requires an object reference."
I can see that the syntax above is not acceptable to Visual Studio even as I type it, but I don't know what properties and methods this new datasource has since it appears to be different from what I've been able to find out about datatables.

As I mentioned in an earlier post, I'm an old procedural programmer who has not yet embraced objects, but I can deal with the concept if I can just find a reference to what the properties of the object are. Right now I mostly guess and try things out. Do you have a pointer to what the properties and methods that apply here are?

The second part of this post relates to the report feature. As I've said I created a rudimentary report, but I don't know how to make it work in any way and the visual studio help has not been very helpful. As above can you give me any pointers to examples or documentation on this feature?

I'm still not sure that the report feature is going to be the solution that I want to use, but it does at least hold promise for other projects if I can figure it out.
Was This Post Helpful? 0
  • +
  • -

#11 thecoat  Icon User is offline

  • D.I.C Head

Reputation: 68
  • View blog
  • Posts: 224
  • Joined: 07-December 13

Re: Printing Tables

Posted 19 January 2014 - 11:14 AM

The problem is rooted in oop, you are indeed working with a datatable, and your syntax is likely correct. What the error message essentially means is you need to create an instance of the dataset. What I've generally done is drop a report viewer control on a form. In the upper right of the control when you click on it will be a button which gives you access to several frequently used properties. You can hit the drop down to assign a report to the control,and there should be an option to create a new report. VS will run a wizard, and create an instance of the dataset as well as a binding object for you. The object it creates will be shown below the form, much like other toolbox controls that don't have a graphic element.

This is one of those cases where the MS tools will do a lot of the plumbing code for you, and at some point make you feel like you are at odds with VS, then you do something like drop a graph at the bottom of the report and marvel at how easy it was. I did a small project last week where I swear the user will think I spent a lot of time on a chart when it took no time, and the majority of my work on it was wiring things up to be able to switch between reports at runtime was the majority of the work.
Was This Post Helpful? 1
  • +
  • -

#12 dleduc  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 23-December 13

Re: Printing Tables

Posted 23 January 2014 - 09:45 PM

Thanks. Your suggestions and puzzling out on my part have resulted in my ability to create a report with all of its included functions. I had serious doubts about the report feature giving me what I wanted, but I think it will do the trick. My big hurdle was that I had to add the dataset and the report to the solution, but then I had to instantiate them to actually use them. Now I just need to tweak my headers and footers and get the pagination correct and I should be fine. Do you have any pointers on good tips for doing that? My next problem to resolve is that I want to change my headers and footers with information from my program. I'm not sure where they are in scope to do this.
Was This Post Helpful? 0
  • +
  • -

#13 dleduc  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 23-December 13

Re: Printing Tables

Posted 28 January 2014 - 04:05 PM

I just about have this table output problem licked, but I encountered two more problems. The first is not exactly a problem, but it would be a nice improvement. The best way that I can explain it is with and example. The table that I get from reportwriter is fine, but not exactly what I intended. I exported it to Excel and then edited it to get what I really want for illustration purposes. What I get is shown in speciesdbh.pdf. What I would prefer is in speciesdbhAsWanted.pdf. Is there anyway to get reportwriter to create my preferred format?

My second issue is a problem and it appears to be one that many others have encountered, but none of their solutions have fixed my problem. This is simply that when I print my table on a printer (or use the printlayout) or export to PDF I get lots of extra pages between pages of my table. The standard solution for this is to make sure that the report doesn't take more room than is allowed between the margins. My report is 7 inches wide and is to be printed on 8.5x11-inch paper with a left margin of 0.5 inches and a right margin of 0.5 inches. Yet it gives me the extra pages. The width probably is the issue since I discovered that I don't get the extra pages if I print in landscape mode, but just how small does it have be. As it is I have left an extra 0.5 inches, but that does not appear to be enough. Any thoughts? Thanks.

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#14 dleduc  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 23-December 13

Re: Printing Tables

Posted 28 January 2014 - 04:40 PM

The last message got posted before I finished some testing. I reduced my report width to 6.4 inches and I still get the blank page in portrait mode.
Was This Post Helpful? 0
  • +
  • -

#15 thecoat  Icon User is offline

  • D.I.C Head

Reputation: 68
  • View blog
  • Posts: 224
  • Joined: 07-December 13

Re: Printing Tables

Posted 29 January 2014 - 09:03 PM

I've had the extra pages issue before, as I recall it was a report control that extended off the visible area in the designer surface and I had to expand the border to see it, although the controls should prevent you from moving the base border past them. Looked at your pdfs and it seems I dealt with a similar goal but I can't for the life of me remember how I did it. I'll look at the report I'm thinking of tomorrow at work.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2