Hi Shakeel,
Thanks for the reply you have sent. I have started using the code as
per your mail. But there is a problem. The data that is to be populated
in the dynamic table is also dynamic. It is not static. I am taking it
from a Map. Even the color for each column has to be dynamic as you can
see below. There is no problem creating table till 2nd row because the
data is known. Now the problem is I have a Map containing the values
like {MF/LY, mmmm, RM/LY}.
I have created a table for the third row as below containing 12
columns. Now I have to iterate through the Map above and also the table
columns to populate the data in each cell. The size if the Map is
lesser than the number of columns in the table. And each alternate cell
has to be populated with value “Equiv R” as you can see below.
The fourth row has numeric values which again are dynamically fetched.
I have tried writing a code but it is populating all the cells with
Equiv R values. Here is my code.
com.aspose.slides.Table
relTable3=slide.getShapes().addTable(relTable2.getX(),relTable2.getY()+relTable2.getHeight(),relTable2.getWidth(),
tableHeight,iColsCount,1);<br>
//Accessing
the text frame of the first cell of the first row in the table
TextFrame reltf3= null;
//Adding corresponding metric names along with Equiv R values(if
applicable) in the table
for(int l=0; l<metricMapList.size(); l++)
{
Map mObject = (Map)metricMapList.get(l);
String sMetricName =
(String)mObject.get(“attribute[”+attrMetricName+"]");
String sHeader = (String)vHeader.get(l);
for(int k=0; k<
relTable3.getColumnsNumber(); k++)
{
reltf3 =
relTable3.getCell(k,0).getTextFrame();
reltf3.getParagraphs().get(0).setAlignment(TextAlignment.CENTER);
if(sHeader!=null)
{
reltf3.getParagraphs().get(0).getPortions().get(0).setText(sMetricName);
System.out.println(">>>>k/2>>>>"+(l/2));
//setting
every alternate cell value as Equiv R
if(“TRUE”.equalsIgnoreCase(strViewEquivR) && (l/2)!=0)
{System.out.println(">>>>Inside Equiv R
Loop>>>>");
reltf3.getParagraphs().get(0).getPortions().get(0).setText(“Equiv R”);
}
if(“Baseline”.equals(sHeader))
{System.out.println(">>>>Inside Baseline
Loop>>>>");
iColor = Integer.parseInt("FFFF00", 16); <br>
color = new java.awt.Color(iColor);<br>
reltf3.getFillFormat().setType(FillType.SOLID);<br>
reltf3.getFillFormat().setForeColor(color.darker());<br>
}<br>
else
if(“Requirement”.equals(sHeader))
{System.out.println(">>>>Inside Requirement
Loop>>>>");
iColor = Integer.parseInt("FFCC00", 16); <br>
color = new java.awt.Color(iColor);<br>
reltf3.getFillFormat().setType(FillType.SOLID);<br>
reltf3.getFillFormat().setForeColor(color.darker());<br>
}<br>
else
if(“Predicted”.equals(sHeader))
{System.out.println(">>>>Inside Predicted
Loop>>>>");
iColor = Integer.parseInt("DADC85", 16); <br>
color = new java.awt.Color(iColor);<br>
reltf3.getFillFormat().setType(FillType.SOLID);<br>
reltf3.getFillFormat().setForeColor(color.darker());<br>
}<br>
else
if(“Actual”.equals(sHeader))
{System.out.println(">>>>Inside Actual
Loop>>>>");
iColor = Integer.parseInt("60BFB4", 16); <br>
color = new java.awt.Color(iColor);<br>
reltf3.getFillFormat().setType(FillType.SOLID);<br>
reltf3.getFillFormat().setForeColor(color.darker());<br>
}<br>
}//if
<br>
<br>
}//for<br>
<br>
}//for<br>
reltf3.getParagraphs().get(0).getPortions().get(0).setFontIndex(fontIndex);
reltf3.getParagraphs().get(0).getPortions().get(0).setFontHeight((short)7);
Please help me out as to how we can dynamically add values to each
cell. Please do let me know if you need any further information.
|
Assembly Level Reliability |
|
Baseline |
|
Actual
|
|
MF/LY |
Equiv R |
mmmm |
Equiv R |
RM/LY |
Equiv R |
MF/LY |
Equiv R |
mmmm |
Equiv R |
RM/LY |
Equiv R |
|
0.0718 |
0.649989
|
0.0 |
0.0 |
0.4759 |
0.057533 |
0.0 |
1.0 |
0.0 |
0.0 |
0.0 |
1.0 |