|
-
Jun 11th, 2011, 08:16 AM
#1
Thread Starter
Lively Member
Fill Excel and/or Print Loop
Hello,
I have an Access 07 database I'm using to store my data. I have no problem at all filling a worksheet in excel or a table in word from the textboxes currently on the screen and saving it as a pdf. That's basically how I'm reporting my data from my program.
Where I'm stuck is how can I do the same process for each row in my dataset that has a date or value similar to a filter? I can filter the dataset by adding a query in the dataset designer so it only displays the rows I want to build form reports for, but I don't know how to code a loop to make it work for each row.
Basically I'm looking to find a way to print and/or create pdf form from one button click for multiple records and not just the one currently bound on the screen.
Thanks in advance!
-
Jun 11th, 2011, 09:04 AM
#2
Re: Fill Excel and/or Print Loop
Over in the .NET CodeBank, I have a class that will export a dataview or datatable to Excel. That might be of interest to you...or possibly not, since it sounds like you have your exporting.
If I can assume that all of the data that you intend to export comes from one table in the dataset, then you have two options to get the rows. You can either call the .Select method of the datatable to get back a collection of datarows that has the information that you want, or you can get a dataview from the datatable and set the RowFilter property to select the rows you want, thought the dataview gives you DataRowViews (or some name like that), which are very similar to datarows, but not quite the same.
Either way, you end up with a collection of rows and loop through those exporting each to whatever target you want.
If, on the other hand, the data you want to export is coming from multiple tables in the dataset, the problem could become considerably more complicated, depending on exactly what data you want to show. In that case, you might use LINQ, which has JOINs, to get the set of datarows to export, which would look much like the datatable.Select option. However, in that case, you could end up with an arbitrarily complex problem.
My usual boring signature: Nothing
 
-
Jun 11th, 2011, 10:30 AM
#3
Thread Starter
Lively Member
Re: Fill Excel and/or Print Loop
The data is actually coming from 2 different tables I have a sampling data section of the form which contains data about how a sample was collected, then there's a datagrid with another table showing multiple tests run on that sample. I have hundreds of samples, and many of them have 4-10 tests ran each sample on different days. Each time a test is run, I need to generate a report for that sample.
Right now I'm doing it the easy way like sheet.range("A1").value = textbox1.text, etc. which is awesome if I just want to work with that one individual report. Problem is once this application gets up and running, the user isn't going to want to load each record then print each form individually, there may be 10 - 100 different reports with today's date that needs to be sent out to different clients.
Would be nice to find a way to make it pdf all of the reports occurring on a specific date by just one click of a button/menu item.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|