簡體   English   中英

從對象列表創建DataGrid

[英]Create DataGrid from list of object

我有這兩節課:

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

和:

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

我創建了FrigoriferoClass列表,並希望使用其中的一些數據創建網格。 我希望網格看起來像這樣(例如,我僅在excel上做到了):

例

之后,我需要使用此網格創建一個pdf文件。

我嘗試使用syncfusion,但是我不知道如何以這種方式制作網格。

有人可以幫助我嗎? 謝謝!

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