【问题标题】:Construct reports or invoices from grid view从网格视图构建报告或发票
【发布时间】:2011-12-04 13:21:23
【问题描述】:

我有一个网格视图,其中包含项目及其序列号、描述和订购数量。我想要做的是允许用户在我的网格视图中选择一些行并将它们打印为 PDF 格式或 Excel 格式的发票。发票有自己的模板,例如抬头上的公司名称、交易编号和卖家信息。我设法构建了该网格视图并将所选项目打印到文本文件中,以确保我的工作正常。

我的问题:构建发票模板并从该网格视图读取数据源的最佳方法是什么?有没有可以帮助我的免费组件?有没有关于我的主题的教程?

感谢您的帮助

【问题讨论】:

  • 您已经通过创建文本文件测试了这一点,现在您想要做同样的事情,但通过正确创建 pdf...

标签: c# asp.net sql-server crystal-reports


【解决方案1】:

存在许多用于创建 PDF 的 C# 库,这里有一个 list 和其中的一些。我以前只用过iText,我觉得是个不错的库。您可以轻松找到教程。这个one 看起来不错。

对于 Excel,.NET Framework 已经内置功能,更多信息here

【讨论】:

    【解决方案2】:

    您可以使用名为ExcelLibrary 的库来打印发票 Excel 格式。 它是发布在 Google Code 上的开源库,可通过here 下载。

    将简单的DataSet 表导出到.xls.xlsx

      //Here's the easy part. Create the Excel worksheet from the data set
        ExcelLibrary.DataSetHelper.CreateWorkbook("MyExcelFile.xls", ds);
    

    查看这些Create Excel (.XLS and .XLSX) file from C#Using C# to Create an Excel DocumentHow to format an Excel file using C# 了解更多详情。

    Here is an alternate also available:

    NPOI library

    NPOI 的优点当然在于它使您能够在代码中使用模板,然后将电子表格的副本直接发送给用户。模板保持不变,用户收到模板的修改副本,其中包含应用程序处理的数据。follow this Creating Excel spreadsheets .XLS and .XLSX in C#

    您可以使用 Office Interop 在 Excel 工作表中创建格式。检查这个
    C# - Opening Excel Template(xlt), adding data, and saving to new worksheet(xls).

    iText 用于创建 PDF 格式的发票怎么样?

    查看这些examples 列表,它们可以帮助您创建和操作 pdf 文档。

    using System; 
    using com.lowagie.text;
    using com.lowagie.text.pdf;
    using System.IO;
    
    public class TestPDF 
    {
        public static void Main(string[] args) 
        {
            Console.WriteLine("Hello World");
    
            // step 1: creation of a document-object
            Document document = new Document();
    
            // step 2:
            // we create a writer that listens to the document
            // and directs a PDF-stream to a file
            PdfWriter.getInstance(document, new FileStream("MyPDF.pdf", FileMode.Create));
    
            // step 3: we open the document
            document.open();
    
            // step 4: we add a paragraph to the document
            document.add(new Paragraph("Hello World"));
    
            // step 5: we close the document
            document.close();
        }
    }
    

    【讨论】:

      【解决方案3】:

      搜索 Telerik 报告Check this

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-03-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-08-17
        相关资源
        最近更新 更多