@ahsaniqbalsidiqui
Thanks for the sample, I really appreciate this. But, this is not what I am expecting. In my case, I don’t have control of fetching data from an array like this. Because once I push the data to Aspose.Cells
, the smart markers are the once who are iterating thru the list of MyObject
instances. For each and every MyObject
in the List Aspose.Cells
engine creates a row. So, when I am creating a dynamic data column I don’t know which row is related to which MyObject
instance.
Even if I knew it, I can directly go fill the data there, no need a smart marker for the dynamic data. Since attaching things looks too confusing I add the description here.
ABC and DEF are the static columns and next to those two columns, we have dynamic columns. We don’t know how many rows are becoming dynamic, it can be zero, one, two or three. So, that is becoming ARG0, ARG1, …, ARGN. So, for the static columns, I am going and filling the smart markers manually as follows,
Under ABC header I put &=record.abc
Under DEF header I put &=record.def
Now if I pushed the List<MyObject>
Aspose.Cells creates a nice looking output in which my smart marked columns are filled with the data according to my list, each and every row represents each and every object.
Now, In every MyObject
instance is having dynamic data. Let’s say it has an extra column in a particular instance of run time. Since I can’t fill that in the designer worksheet manually, I am going to add that column from the Java code. So, as you explained I can read the 3rd column and fill the header, and under it I can fill a smart marker like this, I cannot fill the data or manually extract the data from java because I don’t know what row is related to what object since row iteration is done by Aspose.Cells I don’t have a control over it.
So, dynamically I can add the header, but I cannot add the data from the same instance of MyObject
since I don’t know what object is being processed under what row in Aspose.Cells. That is why I am asking if there is a way to retrieve the data like,
ABC => &=records.abc
CDE => &=records.def
ARG0 => &=records.arg[0]
or any other way we can read the data from a collection using smart markers. Because in that case, Aspose.Cells knows which object is being processed now on ABC and DEF columns and get the data from the exact object and fill the arg0 rows in its processing instance of the object list.
Why your solutions like following is not working for me is,
//CASE 2: Display 3rd element from the float array wb.getWorksheets().get(0).getCells().get(“G1”).putValue("&=$FloatArray4");
float[] floatArray = new float[]{1.1f,2.2f,3.3f,4.4f,5.5f};
report.setDataSource(“FloatArray4”,floatArray[3]);
you’re directly selecting the data you want to fill as floatArray[3]
from Java code. If I know which data is to select from the Java code, I can directly fill the data into the worksheet no need a smart marker there. I don’t feel any point of having dynamic smart markers when we know the data.
I really appreciate your replies again. According to this discussion, I feel like when there are dynamic columns, Aspose.Cells is a wrong approach but Apache-POI would work with much more control. I chose Aspose.Cells because templates and smart markers are smarter. But losing control because of smart markers is again becoming problematic, it looks, when dynamic columns are there.