[英]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.