2009-05-22 12 views

答えて

7

DBGridに表示されるデータは、そのdbgridに添付されたデータセットによって提供されるため、DBGridのデータをPDFにエクスポートすると、データセット内のデータをPDFにエクスポートすることを意味します。

最も簡単なオプションは、レポートツールを使用することです。たとえば、Delphiで利用可能なさまざまなレポートツールがあります。 Rave Report、FastReport、Report Builder、QuickReportなどがあります。

このようなツールを使用すると、データから印刷レポートを作成し、レポートを印刷したり、HTML、DOC、PDFなどの形式にエクスポートすることができます。 Rave ReportはDelphiに同梱されており、無料で使用できます。私は個人的にFastReportが好きで、私のアプリケーションでそれを使います。

もう1つの方法として、ターゲットシステムに仮想PDFプリンタがインストールされている場合、それをプリンタとして選択し、DelphiのTPrinterクラスを使用してプリンタキャンバスに直接書き込むことができます。仮想PDFプリンタはPDFファイルを作成する必要はありません。

第3のオプションは、特にPDF操作用に構築されたサードパーティのコンポーネントを使用して、アプリケーションでPDFファイルを作成または編集できるようにすることです。

よろしく

2

17の最も人気のあるフォーマットにEMS高度なデータエクスポートVCL

http://sqlmanager.net/en/products/tools/advancedexport

  • データ(データセット)の輸出をしてみてください:MSアクセス、MSエクセル、MSワード、Open XML形式、 Open Document Format(ODF)、RTF、HTML、XML、PDF、TXT、DBF、CSV、SYLK、DIF、LaTeX、SQLおよびWindowsクリップボード
  • Borland Delphi 5-7,2005,2006、CodeGear Delphi 2007、2009およびBorland C++ Builder 5-6、C odeGear C++ Builder 2007,2009のサポート
  • Unicodeデータのエクスポート。エクスポートされたデータ(UTF-8、UTF-16/UCS-2、UTF-32/UCS-4、Latin1、Latin2、Latin5、Latin7など)のテキストエンコードを手動でプリセットする
  • 将来の表示、変更、印刷のためのデータの保存またはWeb出版
  • ウィザードでは、エンドユーザーが各データ形式
  • 100%ネイティブのDelphiコード
  • 動作させるために必要な追加のライブラリやソフトウェアの迅速
  • パワフルなエクスポートオプションデータをエクスポートすることができます簡単に使用
  • 詳細なヘルプシステムとデモアプリケーション
  • の強力なコンポーネントとプロパティエディタ
  • 個別に各フィールドのユーザフォーマットを設定する多言語サポート
+0

$ 195からですが、うまく見えます。まだ無料のソリューションを探しています;-) – Mawg

1

あなたは、データを介して自分自身を反復処理し、Gnosticeから優れた輸出VCL eDocEngine を使用することができます。また、レポートツールやその他のコンポーネントにも接続します。

+0

価格は$ 199から開始します。http://www.gnostice.com/edocengine_vcl.asp – Mawg

3

Scalabium Delphi(2009を含む)のエクスポートスイートは、PDFやOLEを使用した場合と使用しない場合の他のオフィス形式を含む多くのエクスポート形式をサポートしています。エクスポートコンポーネントは、TDBGridおよびTDataSet子孫で使用できます。

非視覚でも使用できますが、構成可能なエクスポートウィザードも用意されています。デルファイ7から2009へのアプリケーションスイートの移行にも成功しました。

+0

EUR 35出典なし。ソース50ユーロ良いと思う – Mawg

0
Public Sub ExportDataTableToPDF(ByVal dtImport As DataTable) 
    Dim strQuery As String = "select er_num,er_shortd,er_longd,er_severity from mv_error" 
    Dim doc As New Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35) 
    Try 

     '==================================================================== 
     'Dim str As String = DateTime.Now.ToString("yyyyMMddHHmmssff") 
     'Dim sWebSettingPath As String = ConfigurationSettings.AppSettings("ExptLoctPath") 
     'Dim str1 As String = "E:\ExportPdf_File" 
     'Dim WorkingFile As String 
     'Dim s As String 
     'If (Directory.Exists(sWebSettingPath)) Then 
     ' s = "already exists" 
     ' WorkingFile = Path.Combine(sWebSettingPath, "" & str & " DataTestData.pdf") 
     'Else 
     ' Dim ss As String = "C:\ReportPDF" 
     ' WorkingFile = Path.Combine(str1, "" & str & " DataTestData.pdf") 
     ' Directory.CreateDirectory(ss) 
     'End If 


     '==================================================================== 

     'Folder Exists in Particular folder or not cheak ifnot create a folder 
     Dim strDateTime As String = DateTime.Now.ToString("yyyyMMddHHmmssff") 
     Dim sWebSettingPath As String = ConfigurationSettings.AppSettings("ExptLoctPath") 
     Dim str1 As String = "E:\ExportPdf_File" 
     Dim WorkingFile As String 
     Dim s As String 
     If (Directory.Exists(sWebSettingPath)) Then 
      s = "already exists" 
      WorkingFile = Path.Combine(sWebSettingPath, "" & strDateTime & "_DataTestData.pdf") 
     Else 
      Dim sWebStingNotPath As String = "C:\ReportPDFTest" 
      Directory.CreateDirectory(sWebStingNotPath) 
      WorkingFile = Path.Combine(sWebStingNotPath, "" & strDateTime & " DataTestData.pdf") 

     End If 
     '==================================================================== 

     Dim fs As New FileStream(WorkingFile, FileMode.Create, FileAccess.Write, FileShare.None) 


     'Create Document class object and set its size to letter and give space left, right, Top, Bottom Margin 
     PdfWriter.GetInstance(doc, fs) 
     ' Dim wri As PdfWriter = PdfWriter.GetInstance(doc, New FileStream("C:\Documents and Settings\lessly.l\Desktop\iTextSharp\Test11.pdf", FileMode.Create)) 
     doc.Open() 
     'Open Document to write 
     Dim font8 As Font = FontFactory.GetFont("ARIAL", 7) 

     'Write some content 
     Dim paragraph As New Paragraph("Team :: CataPult") 

     Dim dt As DataTable = dtImport 

     If dt IsNot Nothing Then 
      'Craete instance of the pdf table and set the number of column in that table 
      Dim PdfTable As New PdfPTable(dt.Columns.Count) 


      Dim PdfPCell As PdfPCell = Nothing 
      Dim pdfrow As PdfPRow = Nothing 


      For column As Integer = 0 To dt.Columns.Count - 1 

       PdfTable.HeaderRows = dt.Columns.Count 


       PdfPCell = New PdfPCell(New Phrase(New Chunk(dt.Columns(column).Caption.ToString().ToUpper, New Font(Font.HELVETICA, 8.0F, Font.BOLD, Color.WHITE)))) 
       PdfPCell.BackgroundColor = New Color(System.Drawing.ColorTranslator.FromHtml("#66CCFF")) 

       PdfTable.AddCell(PdfPCell) 

      Next 

      'Each Row Values added 

      For rows As Integer = 0 To dt.Rows.Count - 1 
       For column As Integer = 0 To dt.Columns.Count - 1 
        PdfTable.HeaderRows = dt.Columns.Count 
        PdfPCell = New PdfPCell(New Phrase(New Chunk(dt.Rows(rows)(column).ToString(), font8))) 
        PdfTable.AddCell(PdfPCell) 
       Next 
      Next 

      PdfTable.SpacingBefore = 15.0F 
      ' Give some space after the text or it may overlap the table 
      doc.Add(paragraph) 
      ' add paragraph to the document 
      ' add pdf table to the document 
      doc.Add(PdfTable) 

     End If 
    Catch docEx As DocumentException 
     'handle pdf document exception if any 
    Catch ioEx As IOException 
     ' handle IO exception 
    Catch ex As Exception 
     ' ahndle other exception if occurs 
    Finally 
     'Close document and writer 

     doc.Close() 
    End Try 
End Sub 
+0

あなたのコードが何をしているのか、*なぜ*あなたがそれを推薦するのか、*どのように結論に至ったのか、細かい説明を加えてください。 =)また、コメントアウトされたコードがいっぱいです。それは本当に必要なの? –

+0

OPはVisual Basicではなく、Delphiでソリューションを求めました。私は彼が手動でこれを変換する_could_(もしそうなら、ここに投稿してください、ありがとう) – Mawg

関連する問題