Hi,
I facing a crash while using smart markers group:merge functionality while using custom object list in Aspose.Cells. I am using the Aspose dll with version 4.7.0.0
Problem Faced:System.NullReferenceException: Object reference not set to an instance of an object.
at Aspose.Cells.WorkbookDesigner.⾶(Cells ᒹ, Int32 ሶ, ArrayList ⾷)
at Aspose.Cells.WorkbookDesigner.⾸(Int32 ሁ, Boolean ⾵)
at Aspose.Cells.WorkbookDesigner.Process(Int32 sheetIndex, Boolean isPreserved)
at WindowsFormsApplication1.Form1.CreateDesignerAndSetData() in F:\Manu\Projects\HCAF\Aspose\CalculateSum\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs:line 306
Call Stack:> Aspose.Cells.dll!Aspose.Cells.WorkbookDesigner.?(Aspose.Cells.Cells ? = {Aspose.Cells.Cells}, int ? = 1, System.Collections.ArrayList ? = Count = 2) + 0xff3 bytes
Aspose.Cells.dll!Aspose.Cells.WorkbookDesigner.?(int ? = 0, bool ? = false) + 0x214 bytes
Aspose.Cells.dll!Aspose.Cells.WorkbookDesigner.Process(bool isPreserved = false) + 0x89 bytes
Aspose.Cells.dll!Aspose.Cells.WorkbookDesigner.Process() + 0x20 bytes
WindowsFormsApplication1.exe!WindowsFormsApplication1.Form1.CreateDesignerAndSetData() Line 78 + 0xb bytes C#
WindowsFormsApplication1.exe!WindowsFormsApplication1.Form1.Form1_Load(object sender = {WindowsFormsApplication1.Form1, Text: Form1}, System.EventArgs e = {System.EventArgs}) Line 140 + 0x8 bytes C#
Code: struct Person
{
private String _name;
private Int32 _age;
public String Name
{
get { return _name; }
set { _name = value; }
}
public Int32 Age
{
get { return _age; }
set { _age = value; }
}
}
public void CreateDesignerAndSetData()
{
String xlFileName = @"F:\Manu\WindowsFormsApplication1\Files\MyNewXLFile.xls";
WorkbookDesigner myWorkbook = new WorkbookDesigner();
myWorkbook.Open(xlFileName);
Worksheet curentWorksheet = myWorkbook.Workbook.Worksheets["Sheet1"];
// Create temporary data
IList<Person> myList = new List<Person>();
myList.Add(new Person() { Name = "X", Age = 26 });
myList.Add(new Person() { Name = "X", Age = 32 });
myList.Add(new Person() { Name = "Y", Age = 19 });
// Set the headers and smart markers to the XL file
curentWorksheet.Cells["A1"].PutValue("Name");
curentWorksheet.Cells["B1"].PutValue("Age");
curentWorksheet.Cells["A2"].PutValue("&=Person.Name(group:merge,skip:1)");
curentWorksheet.Cells["B2"].PutValue("&=Person.Age");
// Set the data to the XL sheet
myWorkbook.SetDataSource("Person", myList);
myWorkbook.Process();
myWorkbook.Workbook.Save("c:\\Manu_Test.xls");
Process.Start("c:\\Manu_Test.xls");
}
The code crashes @ the line 'myWorkbook.Process();'. If we replace 'curentWorksheet.Cells["A2"].PutValue("&=Person.Name(group:merge,skip:1)");' with 'curentWorksheet.Cells["A1"].PutValue("&=Person.Name");', the code works with out any merging/grouping. The crash surfaces as soon as we add any group method to the smart marker.
This error only happens in case of a custom object. If the data is read from a database and the dataset is send in to be processed everything works fine. i.e. the merging works.
Please help.
This message was posted using Page2Forum from Smart Markers - Aspose.Cells for .NET and Java