将asp.net,C#GridView输出到PDF的好方法是什么?

时间:2021-03-30 14:46:23

I tried using the Microsoft ReportingControls but found them overly cumbersome, with too little documentation. I'd like a simple control that would convert a GridView control into a PDF document. I've started looking into PDFSHarp and am running into dead ends with documentation. Same thing with iTextSharp. I'm willing to dig into them further if they have worked for others in the past.

我尝试使用Microsoft ReportingControls,但发现它们过于繁琐,文档太少。我想要一个简单的控件,将GridView控件转换为PDF文档。我已经开始研究PDFSHarp并且正在使用文档进入死胡同。 iTextSharp也是如此。如果他们过去曾为其他人工作,我愿意进一步深入研究它们。

2 个解决方案

#1


1  

You could iterate over the data in your gridview and write it to a PDF table using iTextSharp. Have a look here: http://www.codeproject.com/KB/cs/iTextSharpPdfTables.aspx

您可以迭代gridview中的数据,并使用iTextSharp将其写入PDF表格。看看这里:http://www.codeproject.com/KB/cs/iTextSharpPdfTables.aspx

I also recommend getting the book iText In Action.

我还建议您阅读iText In Action一书。

#2


0  

I can recommend the ceTe DynamicPDF product if you just need to create PDF files. It is well documented and pretty easy to use. The only caveat that I would have is that your reports will all be built in Code. If you plan on adding a lot of reports then you might want to explore an alternative like Telerik's new reporting tool (which will export to PDF).

如果您只需要创建PDF文件,我可以推荐ceTe DynamicPDF产品。它有很好的文档记录,非常易于使用。我唯一需要注意的是,你的报告都将在Code中构建。如果您计划添加大量报告,那么您可能希望探索Telerik的新报告工具(将导出为PDF)等替代方案。

Well, make that two caveats: DynamicPDF is a bit expensive if you are just doing the one GridView export.

好吧,提出两个警告:如果你只是做一个GridView导出,DynamicPDF有点贵。

#1


1  

You could iterate over the data in your gridview and write it to a PDF table using iTextSharp. Have a look here: http://www.codeproject.com/KB/cs/iTextSharpPdfTables.aspx

您可以迭代gridview中的数据,并使用iTextSharp将其写入PDF表格。看看这里:http://www.codeproject.com/KB/cs/iTextSharpPdfTables.aspx

I also recommend getting the book iText In Action.

我还建议您阅读iText In Action一书。

#2


0  

I can recommend the ceTe DynamicPDF product if you just need to create PDF files. It is well documented and pretty easy to use. The only caveat that I would have is that your reports will all be built in Code. If you plan on adding a lot of reports then you might want to explore an alternative like Telerik's new reporting tool (which will export to PDF).

如果您只需要创建PDF文件,我可以推荐ceTe DynamicPDF产品。它有很好的文档记录,非常易于使用。我唯一需要注意的是,你的报告都将在Code中构建。如果您计划添加大量报告,那么您可能希望探索Telerik的新报告工具(将导出为PDF)等替代方案。

Well, make that two caveats: DynamicPDF is a bit expensive if you are just doing the one GridView export.

好吧,提出两个警告:如果你只是做一个GridView导出,DynamicPDF有点贵。