简体   繁体   中英

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. I want the grid to look like this (I made it on excel only for example):

例

And after that I need to create a pdf file with this grid.

I tried to use syncfusion, but I don't know how to make a grid in this way.

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();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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