Solved

Export Dataset/Datagrid into .PDF format

Posted on 2004-04-16
6
2,592 Views
Last Modified: 2012-06-27
Hello,

I found a way to export a dataset/datagird into Excel using the below code, BUT is there a way to do the same thing but export the data into an organized .PDF file, as long as it's not "Action Reports" or any other component I have to buy?

                'Open the file as a stream to read or write
                Dim objExcel As Object
                Dim objBook As Object
                Dim objSheet As Object
                objExcel = CreateObject("Excel.Application")
                objBook = objExcel.Workbooks.Add
                objSheet = objBook.Worksheets(1)

                'Set up the Query Table and tell it where to find the data.
                Dim objQryTable As Object
                objQryTable = objSheet.QueryTables.Add("OLEDB;Provider=sqloledb;Data Source=MyDataSource" & _
                    ";Initial Catalog=MyDatabase" & _
                    ";Trusted Connection=Yes;Integrated Security=SSPI;", objSheet.Range("A1"), strSQL)
                objQryTable.RefreshStyle = 2 ' x1InsertEntire Rows = 2
                objQryTable.Refresh(False)

                'sPath is a string containing the location to save the file to
                objBook.SaveAs(objSaveDialog.FileName)
                'Clear everything so you can display it to the user
                objQryTable = Nothing
                objSheet = Nothing
                objBook = Nothing
                objExcel.Quit()
                objExcel = Nothing

Thanks!

Chris
0
Comment
Question by:Trancedified
  • 3
  • 2
6 Comments
 
LVL 7

Expert Comment

by:ramesh12
ID: 10847020
I think you can use CrystalReports with in .Net to create a report and have that exported/saved to PDF format
0
 
LVL 7

Expert Comment

by:ramesh12
ID: 10847043
0
 
LVL 7

Assisted Solution

by:ramesh12
ramesh12 earned 250 total points
ID: 10847047
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 1

Author Comment

by:Trancedified
ID: 10861945
Yeah crystal reports works, all you do is hit a button, but is there a way to do this w/out Crystal reports?


Chris
0
 
LVL 8

Accepted Solution

by:
nishikanth earned 250 total points
ID: 10875147
0
 
LVL 1

Author Comment

by:Trancedified
ID: 10954445
nishikanth,

I am able to export to Excel, that is how I had it, but how would you export to .PDF format WITHOUT using crystal reports?

Thanks!

Chris
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Exceptions 3 46
Show/Hide ASP.NET controls with JQuery best practices 3 50
Alert on Server memory 2 24
Get number of Files in Directory and Sub Directories 2 42
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question