Hi @aem1234567890 ,
Your question has 3 requirements. Let me start with first one. Did not understand later two.
1. You wand to add a node on page creation.
2. Properties of these node should be fetch from some source(ex file, excel).
Let me propose a solution for this.
1. Create a workflow or Event Handler. I will prefer workflow with custom workflow process. Trigger this workflow on page creation.
Create a node inside this custom workflow process.
Fetch property/value form excel. Assuming excel file is in dam and having two columns. first column has properties and second columns has values agains those properties.
We will use apache poi api to read excel. These API are available in AEM, SO you don't need to add additional API.
Assuming this code is written in custom process. Please note this is pseudo code. Update node path and name as per your project setup.
final ResourceResolver resourceResolver = workflowSession.adaptTo(ResourceResolver.class);;
String filePath = "/content/dam/excel-file-path";
Asset fileAsset=resourceResolver.getResource(filePath).adaptTo(Asset.class);
InputStream inputStream=fileAsset.getRendition("original").getStream();
XSSFWorkbook workbook = new XSSFWorkbook(inputStream);
XSSFSheet sheet = workbook.getSheetAt(0);
Iterator<Row> rowIterator = sheet.iterator();
Session session =workflowSession.adaptTo(Session.class);
Node node =session.getNode("node path where you want to create child node");
Node childNode=node.addNode("newly created node name");
session.save();
while (rowIterator.hasNext())
{
Row row = rowIterator.next();
//For each row, iterate through all the columns
Iterator<Cell> cellIterator = row.cellIterator();
String prop=StringUtils.EMPTY;
String val=StringUtils.EMPTY;
while (cellIterator.hasNext())
{
Cell cell = cellIterator.next();
int colIndex=cell.getColumnIndex();
if(colIndex%2==0){
prop=cell.getStringCellValue();
}else{
val=cell.getStringCellValue();
}
}
childNode.setProperty(prop,val);
session.save();
}
I will try to answer your later two requirement, if you add some more details.