2017-08-13 3 views
0

私はdx-data-grid(devExpressグリッド)をPDF文書にエクスポートする必要があります。データをExcelにエクスポートするためのソリューションはありますが、PDFへのエクスポート方法はありますか?これはdxDataGrid、DXサポートからの回答では許可されていない現時点ではdx-data-grid devexpressをpdfにエクスポートするには?

+0

あなたが達成したいものを明確にしてください。 –

+0

ボタンをクリックすると、同じグリッド構造のPDFにすべてのグリッドデータをエクスポートする必要があります – Bassem

+0

サポート:[現時点では、PDFファイル形式はグリッドウィジェットでは使用できません。 Excel形式のみサポートされています。](https://www.devexpress.com/Support/Center/Question/Details/T500288/how-to-export-dx-data-grid-to-pdf)。 – ventiseis

答えて

1

:現時点では

、dxDataGridは、PDF機能への輸出を提供していません。私たちはこの制限を認識しており、この機能はTO-DOリストにあります。しかし、いつ紹介するのか正確な日付を提供することはできません。 https://www.devexpress.com/Support/Center/Question/Details/T458071/dxdatagrid-is-it-possible-to-export-data-to-pdf

しかし、自分のアプリケーションのサーバー側で独自のPDFファイルを生成することができます。 iTextSharpを使用して、この記事では、http://www.c-sharpcorner.com/UploadFile/f4f047/generating-pdf-file-using-C-Sharp/

using iTextSharp.text; 
using iTextSharp.text.pdf; 

protected void GeneratePDF(object sender, System.EventArgs e) 
{ 
using(System.IO.MemoryStream memoryStream = new System.IO.MemoryStream()) 
{ 
    Document document = new Document(PageSize.A4, 10, 10, 10, 10); 

    PdfWriter writer = PdfWriter.GetInstance(document, memoryStream); 
    document.Open(); 

    Chunk chunk = new Chunk("This is from chunk. "); 
    document.Add(chunk); 

    Phrase phrase = new Phrase("This is from Phrase."); 
    document.Add(phrase); 

    Paragraph para = new Paragraph("This is from paragraph."); 
    document.Add(para); 

    string text = @ "you are successfully created PDF file."; 
    Paragraph paragraph = new Paragraph(); 
    paragraph.SpacingBefore = 10; 
    paragraph.SpacingAfter = 10; 
    paragraph.Alignment = Element.ALIGN_LEFT; 
    paragraph.Font = FontFactory.GetFont(FontFactory.HELVETICA, 12f, BaseColor.GREEN); 
    paragraph.Add(text); 
    document.Add(paragraph); 

    document.Close(); 
    byte[] bytes = memoryStream.ToArray(); 
    memoryStream.Close(); 
    Response.Clear(); 
    Response.ContentType = "application/pdf"; 

    string pdfName = "User"; 
    Response.AddHeader("Content-Disposition", "attachment; filename=" + pdfName + ".pdf"); 
    Response.ContentType = "application/pdf"; 
    Response.Buffer = true; 
    Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache); 
    Response.BinaryWrite(bytes); 
    Response.End(); 
    Response.Close(); 
} 
} 

そして、あなたのクライアントに転送することを行う方法を示し How to download a file to client from server?

+0

ありがとうあなたのソリューションは働いていますが、私はもう一度サーバーを呼び出すことなくソリューションを見つけました。可能な解決策は、datagridのデータソースをhtmlテーブルに変換することです。この例はDataGridにもあてはまり、JSライブラリを使ってHTMLからPDFに変換することができます。このリンクは私にそれを助けます:https://www.devexpress.com/Support/Center/Question/Details/T113743/dxdatagrid-provide-the-capability-to-export-data – Bassem

+0

あなたがオプションを見つけたことを知り、うまくいけば、彼らは次のリリースでpdfへのエクスポートを実装する –

+0

悲しいことに、彼らはそれを実装しないでしょう、次のリリースのためにそれをルートマップに入れません – Bassem

関連する問題