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; }
}
@MunirNS,
Please share your template file “myTemplate.xlsx”, the program output file “outData.xlsx” and expected output file created by Excel for our reference. We will analyze the sample code with the template file and provide our feedback.
files.zip (18.7 KB)
Hi,
I have just seen your reply, and shared the files,
Thank you,
@MunirNS,
We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.
This issue has been logged as
CELLSNET-46711 - ImportCustomObjects to merged area
@ahsaniqbalsidiqui ui,
Thank you so much, i will be following for the solution
@MunirNS,
Sure, you are welcome.
@MunirNS,
This is to inform you that we have fixed your issue (logged earlier as “CELLSNET-46711”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.
@ahsaniqbalsidiqui,
Thank you for the good news.
I ll be waiting for the fix package.
@MunirNS,
Please try our latest version/fix: Aspose.Cells for .NET v19.4.5 (attached)
Your issue should be fixed in it.
Let us know your feedback.
Aspose.Cells19.4.5 For .Net2_AuthenticodeSigned.Zip (4.9 MB)
Aspose.Cells19.4.5 For .Net4.0.Zip (4.9 MB)
@ahsaniqbalsidiqui,
I ve just tried the latest version. But nothing changed.
Did you add extra parameter for merged areas? Or you just change the core method(ImportCustomObjects) to detect merging and shifting etc?
I couldnt understand what did you fixed exactly?
Thanks,
@ahsaniqbalsidiqui,
Sorry, I realized that I was wrong,
I ve just seen the ImportTableOptions.CheckMergedCells.
It works absolutely fine.
Thank you so much
@MunirNS,
Good to know that your issue is sorted out by the suggested version. Feel free to contact us at any time if you need further help or have some other issue or queries, we will be happy to assist you soon.
@MunirNS,
Please try our latest version/fix: Aspose.Cells for .NET v19.4.6 (attached)
Your issue should be fixed in it.
Let us know your feedback.
Aspose.Cells19.4.6 For .Net2_AuthenticodeSigned.Zip (4.9 MB)
Aspose.Cells19.4.6 For .Net4.0.Zip (4.9 MB)
The issues you have found earlier (filed as CELLSNET-46711) have been fixed in Aspose.Cells for .NET v19.5. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi