Hi Team,
I have a problem with using Cells.ImportCustomObjects method. I tried to insert list of objects to an excel template by using ImportCustomObjects. Inserting data working but the excel template has merged areas. e.g: CustomerId [A1:C1], Name: [D1:F1]
When I inserted multiple rows to merged area, data is shifting. For example Customer1->A2, Name -> B2 But i want to insert data to each of merged cells like as Customer1->A2, Name -> D2
How can I do that using library. I dont want to insert data cell by cell by arranging manually by myself.
The working code sample is stated below.
Thanks for your help
class Program
{
static void Main(string[] args)
{
Workbook wb = new Workbook(@"D:\myTemplate.xlsx");
List<Customer> customerList = new List<Customer>();
//Creating collection for test items
for (int i = 0; i < 5; i++)
{
Customer customer = new Customer
{
CustomerId = i,
Name = "Customer" + i
};
customerList.Add(customer);
}
//Insert data to excell
wb.Worksheets[0].Cells.ImportCustomObjects((ICollection)customerList, new String[] { "CustomerId", "Name" }, false,1, 0, customerList.Count, true, "dd/mm/yyyy", false);
wb.Save(@"D:\outData.xlsx", Aspose.Cells.SaveFormat.Xlsx);
}
}
public class Customer
{
public int CustomerId { get; set; }
public string Name { get; set; }
}