I want 2 tables in the word document like this:
Test ID : TS1
Test Data : Sample Data
Test Description : Sample Description
Test ID : TS2
Test Data : Sample Data
Test Description : Sample Description
For above tables i written code like this:
XWPFDocument document = new XWPFDocument();
XWPFParagraph tmpParagraph = document.createParagraph();
XWPFRun tmpRun = tmpParagraph.createRun();
FileOutputStream fos = new FileOutputStream(new File("E:\\Selenium\\yoj.doc"));
for(int tabNo = 0;tabNo<=1;tabNo++) //to get two tables
{
XWPFTable tab = document.createTable(10,2);
XWPFTableRow row = tab.getRow(0);
tab.getRow(0).getCell(0).setText("Test Scenario ID: ");
tab.getRow(0).getCell(1).setText("TS1");
tab.getRow(0).setCantSplitRow(true);
tab.getRow(1).getCell(0).setText("Test Scenario Description: ");
tab.getRow(1).getCell(1).setText("2");
tab.getRow(2).getCell(0).setText("Test Data: ");
tab.getRow(2).getCell(1).setText("3");
}
Iam getting output like this(Two tables are getting clubed) :
Test ID : TS1
Test Data : Sample Data
Test Description : Sample Description
Test ID : TS2
Test Data : Sample Data
Test Description : Sample Description