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

Free Support Forum - aspose.com

Displaying label value along with label name in a single cell using smart markers and template based approach in java aspose

Hi Team,

In a cell need to display label name followed by a value. For that value to be populated we are using smart markers with $ i.e "&=$labelname" in the template but we are unable to print the value along with label name in a single cell. But we are able to print only value without label name in single cell.

Could you please provide suggestions on the same which would be greatful for us. Thank you.

Regards

Anitha

Hi,


Thanks for your query.

I am afraid, there is no better way to accomplish the task as Smart Markers feature has its own specifications and attributes and we need to follow it. You cannot add constant value or label value with the conventional markers. You may try any of the following approaches as a workaround if it may help you:
e.g

1) You may have a column (that should be hidden in the template file, in this column you will use smart markers to get ProductName for example). Now you may use Concatenate function in the following way for the dynamic formula marker e.g

e.g
H (this column can be hidden) J

&=DataSource.ProductName &=&=Concatenate("The color of the “, H{r}, " is red”)

2) Another way is to do it dynamically in your codes. For example, once the markers are processed and filled with data, you may loop through your desired cells in the column to concatenate your desired string attached with its value:
e.g
Sample code:

cell.putValue(“my string” + cell.getStringValue());

Thank you.

Hi,

Thanks a lot for your 2 response. I would prefer approach 2 in my code. Need your help to do the same in my code. Attaching my code through "CodeSnippet" file. Please suggest how to use cell.PutValue() method in my code.

Thanking you in advance.Let me know if more inputs are requied.

Regards

Anitha

Hi,


Well, the second approach is nothing but a manual way to do it. For example, after calling WorkbookDesigner.process() method, all the markers are processed in the template file and data is filled into the cells, you may get the Cells collection in the sheet and then manually add your constant values/ label values with the already filled values in the cells, you may loop through your desired cells in the range or column etc., see the sample code below:
e.g
Sample code:

wbd.process();

//get your worksheet Cells collection
Cells cells = wbd.getWorkbook().getWorksheets().get(“worksheet_name”).getCells();

//Now you may loop through the cells input your desired data with existing values in the cells.
//Your code goes here.
//…

Thank you.

Hi,

Thank you for the solution. But i need to add labels manually before calling WorkBookDesigner.process() method. I dont want to loop data later as it may become performance issue in my code as i have large data.Is it possible to add labels parallelly in the code while markesr are processed on template file before calling WorkBookDesigner.process() method.

Thanking you in advance

Regards

Anitha

Hi,

In continuation to above post, i need to use bold style with blue font for label name and for value no formatting style. But both label name and value should be in same cell. How can i achieve this. Please help me out. I am getting bold style with blue font for value also along with label name as i am formatting cell style.

Thanking you in advance.

Regards

Anitha

Hi,

Please see the document on how to apply formatting to selected characters in the cell for your reference:
Formatting selected characters in cell

Thank you.

Hi,

Thank you. Selected characters formatting is working fine.

Could you please give response to 575967 post. Thaning you in advance.

Regards

Anitha

Hi,


I am afraid, Aspose.Cells’ Smart Markers feature has its own specifications and attributes and we need to follow it, it does not support your custom needs. You cannot add constant values or labels with the conventional markers. You may try to accomplish your task after markers are processed as you are currently doing.

Thank you.