简体   繁体   English

从对象列表创建DataGrid

[英]Create DataGrid from list of object

I have these two classes: 我有这两节课:

public class FrigoriferoClass
{
    public int codice { get; set; }
    public string contenuto { get; set; }
    public int tempMin { get; set; }
    public int tempMax { get; set; }
    public List<ControlloClass> controllo { get; set; }

    public FrigoriferoClass(int cod, string cont, int min, int max)
    {
        controllo = new List<ControlloClass>();
        codice = cod;
        contenuto = cont;
        tempMin = min;
        tempMax = max;
    }
}

and: 和:

public class ControlloClass
{
    public int temp { get; set; }
    public DateTime data { get; set; }

    public ControlloClass(int t, DateTime d)
    {
        temp = t;
        data = new DateTime();
        data = d;
    }
}

I created a list of FrigoriferoClass and with some of their data I want to create a grid. 我创建了FrigoriferoClass列表,并希望使用其中的一些数据创建网格。 I want the grid to look like this (I made it on excel only for example): 我希望网格看起来像这样(例如,我仅在excel上做到了):

例

And after that I need to create a pdf file with this grid. 之后,我需要使用此网格创建一个pdf文件。

I tried to use syncfusion, but I don't know how to make a grid in this way. 我尝试使用syncfusion,但是我不知道如何以这种方式制作网格。

Anyone can help me? 有人可以帮助我吗? Thanks! 谢谢!

using Syncfusion.XlsIO;
using Syncfusion.Pdf;
using Syncfusion.ExcelToPdfConverter;
...

// in a method
using (Stream readFile = stream for excel file)
{
    ExcelToPdfConverter converter = new ExcelToPdfConverter(readFile);
    PdfDocument pdfDoc = new PdfDocument();
    // set Your setting You like
    ExcelToPdfConverterSettings settings = new ExcelToPdfConverterSettings();
    settings.TemplateDocument = pdfDoc;
    settings.DisplayGridLines = GridLinesDisplayStyle.Invisible;
    pdfDoc = converter.Convert(settings);
    pdfDoc.Save("ExceltoPDF.pdf", Response, HttpReadType.Save);
    readFile.Close();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM