wpf 如何从datagrid的数据中导出PDF?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19107282/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 09:45:32  来源:igfitidea点击:

How to export PDF from data of datagrid?

c#wpfpdfdatagridwpfdatagrid

提问by 1myb

How can I export the data from DataGridinto PDF? The quick solution.

如何将数据从DataGridPDF导出?快速解决方案。

<DataGrid Name="table" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" IsTextSearchEnabled="True" Background="White">
    <DataGrid.Columns>
        <DataGridTextColumn Header="Timestamp" Binding="{Binding StartDate}" SortDirection="Descending" SortMemberPath="StartDate" IsReadOnly="True" />
        <DataGridTextColumn Header="Title" Binding="{Binding Title}" IsReadOnly="True" />
        <DataGridTextColumn Header="Description" Binding="{Binding Description}" IsReadOnly="True" />
        <DataGridTextColumn Header="Type" Binding="{Binding Tag}" IsReadOnly="True" />
    </DataGrid.Columns>
</DataGrid>

回答by dotnetmirror.com

You can use iTextSharp (http://sourceforge.net/projects/itextsharp/) to generate datagrid to pdf.

您可以使用 iTextSharp ( http://sourceforge.net/projects/itextsharp/) 将数据网格生成为 pdf。

(or) Look at http://wpfextendeddatagrid.codeplex.com/

(或)查看http://wpfextendeddatagrid.codeplex.com/

回答by Nitin

You can use iTextSharp to do it. You can add DataGrid visual in iTextSharp Document and use its PdfWriter to write it to the pdf file.

您可以使用 iTextSharp 来做到这一点。您可以在 iTextSharp 文档中添加 DataGrid 视觉对象并使用其 PdfWriter 将其写入 pdf 文件。

Below is the simple tutorial on it.

下面是它的简单教程。

http://www.c-sharpcorner.com/uploadfile/f2e803/basic-pdf-creation-using-itextsharp-part-i/

http://www.c-sharpcorner.com/uploadfile/f2e803/basic-pdf-creation-using-itextsharp-part-i/