We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

ImportCustomObjects wrong result

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

@lsl,

Please notice, I am able to reproduce the issue as you mentioned. I found Cells.ImportCustomObjects produces wrong results when using the method in some condition. It looks like it does not take the condition into account when importing the custom objects into the spreadsheet. I have logged a ticket with an id “CELLSNETCORE-383” for your issue. We will look into it soon. Once we have an update on it, we will let you know.

Please note, System.Web.HttpResponse does not exist in .NET5.0/6.0. Microsoft.AspNetCore.Http.HttpResponse only exists in ASP.NET application. You need to transfer steams to the object you need accordingly. See the thread with sample code for your reference.

@lsl,

This is to notify you that your issue (logged earlier as “CELLSNETCORE-383”) has been resolved now. This fix will be included in the next release (Aspose.Cells for .NET v22.5) scheduled for the second week of May 2022. You will also be notified when the next version is released.