Example for CELLSNET-58755 and CELLSNET-58756

Hi, could you please provide an example of the enhancements introduced in CELLSNET-58755 and CELLSNET-58756 in Aspose.Cells release 25.8? I wasn’t able to find any sample related to this enhancement in Smart Markers related Documents.

@dev.sm

The enhancements introduced in CELLSNET-58755 and CELLSNET-58756 in Aspose.Cells release 25.8 focus on improving the functionality of Smart Markers. These improvements aim to enhance the ease of use and flexibility of Smart Markers in your applications.

To effectively utilize Smart Markers, here’s a simple example demonstrating their implementation in Aspose.Cells:

// Create a new workbook
Workbook workbook = new Workbook();

// Access the first worksheet
Worksheet worksheet = workbook.Worksheets[0];

// Add some sample data
worksheet.Cells["A1"].PutValue("Name");
worksheet.Cells["A2"].PutValue("John Doe");
worksheet.Cells["B1"].PutValue("Age");
worksheet.Cells["B2"].PutValue(30);

// Define a Smart Marker
worksheet.Cells["D1"].PutValue("=Name");
worksheet.Cells["D2"].PutValue("=Age");

// Save the workbook
workbook.Save("SmartMarkerExample.xlsx");

In this example, we create a workbook, add some data, and then use Smart Markers to reference that data in another part of the worksheet. You can expand on this by incorporating more complex data structures or formulas as needed.

If you have specific scenarios in mind regarding the enhancements, please share them, and I will provide more tailored examples or guidance.

To proceed, you can implement the provided example in your project and explore the new functionalities. If you have any further questions or need additional assistance, feel free to reach out!

@dev.sm,

Alright, we will soon compile and provide you examples on “if” parameter support and variables support in Smart Markers. We will also update documentation to include the new features in Smart Markers accordingly.

@dev.sm
Please refer to the following example code and check the attachment. result.zip (26.5 KB)

Workbook workbook = new Workbook(filePath + "template.xlsx");
ABC_1_Data res = (ABC_1_Data)JsonConvert.DeserializeObject(File.ReadAllText(filePath + "data.json"), typeof(ABC_1_Data));
List<ABC_1_Data> listFormData = new List<ABC_1_Data>();
listFormData.Add(res);
                        
WorkbookDesigner workbookDesigner = new WorkbookDesigner(workbook);

workbookDesigner.ContainsVariables = true;
workbookDesigner.SetDataSource("RootData", listFormData);
workbookDesigner.Process();
Assert.AreEqual("director first 2 last fff", workbook.Worksheets[0].Cells["C5"].StringValue);
workbook.Save(filePath + "result.xlsx");

public class ABC_1_Data
{

    public ABC_1_Data()
    {

    }
    [JsonProperty("EntityCin")]
    public string EntityCin { get; set; }

    [JsonProperty("EntityName")]
    public string EntityName { get; set; }
    [JsonProperty("FirstName")]
    public string FirstName { get; set; }
    [JsonProperty("MiddleName")]
    public string MiddleName { get; set; }
    [JsonProperty("LastName")]
    public string LastName { get; set; }
    [JsonProperty("DOB")]
    public string Dob { get; set; }

    [JsonProperty("SSN")]
    public string Ssn { get; set; }
    [JsonProperty("Directors")]
    public List<Employee> Directors { get; set; }
}

public class Employee
{
    [JsonProperty("id")]
    public string Id { get; set; }
    [JsonProperty("FirstName")]
    public string FirstName { get; set; }
    [JsonProperty("MiddleName")]
    public string MiddleName { get; set; }
    [JsonProperty("LastName")]
    public string LastName { get; set; }


    [JsonProperty("Reportees")]
    public List<Employee> Reportees { get; set; }
    [JsonProperty("Department")]
    public string Department { get; set; }
    [JsonProperty("City")]
    public string City { get; set; }
    [JsonProperty("GSTEnabled")]
    public string GstEnabled { get; set; }

    [JsonProperty("ITREnabled")]
    public string ItrEnabled { get; set; }
    public string getFullName()
    {
        return this.FirstName + this.MiddleName + this.LastName;
    }
}

Thanks for sharing the example, I’ll refer to it.

@dev.sm
You are welcome. Please take your time to try the example. If you have any questions, please feel free to contact us at any time.

@dev.sm,

Please note that we have now added documents featuring examples with details on the “range” parameter, “if” parameter and using variables in Smart Markers. Please feel free to check these documents, which also include detailed explanation and sample files for your reference.