Workbook wb = new Workbook();
var cells = wb.Worksheets[0].Cells;
var data = new List<PersonInfo>();
data.Add(new PersonInfo()
{
bumen = "11"
});
var propertyInfos = typeof(PersonInfo).GetProperties().ToList();
cells.ImportCustomObjects((System.Collections.ICollection)data,
propertyInfos.Select(x => "sdasd").ToArray(),
true,
0,
0,
data.Count,
true,
"yyyy-MM-dd HH:mm:ss",
false);
wb.Save("out.xlsx");
public class PersonInfo
{
public string bumen { get; set; }
public string fence { get; set; }
public string floor { get; set; }
}
env: net6.0 aspose.net 22.4
q1:in my option, it should throw exception or get empty result (only head) ?
q2: how write file to client in web api directly
MemoryStream stream = new MemoryStream();
wb.Save(stream, SaveFormat.Xlsx);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",fname);
now , I use this mehod