using NetLibrary.ReportPrint; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; namespace NetLibrary.Models { public class JsonTable { public int ColumnNumber { get; set; } public List Cells { get; set; } public JsonTable() { Cells = new List(); } public string ExportExcel() { DataTable tb = new DataTable(); for (int i = 0; i < ColumnNumber; i++) { tb.Columns.Add(new DataColumn() { ColumnName="col"+i }); } int index = 0; DataRow row = null; foreach (var item in Cells) { if (index == 0) row = tb.NewRow(); row[index] = item.CellText; index++; if (index >= ColumnNumber) { index = 0; tb.Rows.Add(row); } } MicrosoftExcel obj = new MicrosoftExcel(); return obj.Export("",tb); } } public class JsonCell { public bool IsHader { get; set; } public string CellText { get; set; } } public class JsonTable { public int ColumnNumber { get; set; } public List> Cells { get; set; } public JsonTable() { Cells = new List>(); } } public class JsonCell { public bool IsHader { get; set; } public string CellText { get; set; } public T ExtModel { get; set; } } }