首页 文章

从网格视图构造报告或发票

提问于
浏览
2

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

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

谢谢你的帮助

3 回答

  • 2

    存在许多用于创建PDF的C#库,这里有一些list,其中包含一些 . 我过去只使用了 iText ,我认为这是一个很好的图书馆 . 您可以轻松找到教程 . 这个one看起来不错 .

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

  • 0

    您可以使用名为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的好处当然是它使您能够在代码中使用模板,然后将电子表格的副本直接发送给用户 . 模板保持不变,用户收到模板的修改副本,其中包含应用程序处理的数据 . 关注此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();
        }
    }
    
  • 0

    搜索Telerik报告Check this

相关问题