I want to write excel sheet and for that I write a code, but when my program execute in the object WritableSheet it get the below warning. May I know where I am going wrong?? Also, I am using keydriven framework for writing a sheet.
Warning: Sheet name D:\eclipse-jee-kepler-SR1-win32\Workspace\AutomationFramework\configuration\GmailTestSuite.xls too long - truncating
Warning: : is not a valid character within a sheet name - replacing
Warning: \ is not a valid character within a sheet name - replacing
Code which I am using for writing a sheet:
public class WritableData {
Workbook wbook;
WritableWorkbook wwbCopy;
String ExecutedTestCasesSheet;
WritableSheet shSheet;
public WritableData(String testSuitePath, String string) {
// TODO Auto-generated constructor stub
try {
wbook = Workbook.getWorkbook(new File(testSuitePath));
wwbCopy = Workbook.createWorkbook(new File(testSuitePath));
// shSheet=wwbCopy.getSheet(1);
shSheet = wwbCopy.createSheet(testSuitePath, 1);
} catch (Exception e) {
// TODO: handle exception
System.out.println("Exception message" + e.getMessage());
e.printStackTrace();
}
}
public void shSheet(String strSheetName, int iColumnNumber, int iRowNumber,
String strData) throws WriteException {
// TODO Auto-generated method stub
WritableSheet wshTemp = wwbCopy.getSheet(strSheetName);
WritableFont cellFont = null;
WritableCellFormat cellFormat = null;
if (strData.equalsIgnoreCase("PASS")) {
cellFont = new WritableFont(WritableFont.TIMES, 12);
cellFont.setColour(Colour.GREEN);
cellFont.setBoldStyle(WritableFont.BOLD);
cellFormat = new WritableCellFormat(cellFont);
cellFormat.setBorder(Border.ALL, BorderLineStyle.THIN);
}
else if (strData.equalsIgnoreCase("FAIL")) {
cellFont = new WritableFont(WritableFont.TIMES, 12);
cellFont.setColour(Colour.RED);
cellFont.setBoldStyle(WritableFont.BOLD);
cellFormat = new WritableCellFormat(cellFont);
cellFormat.setBorder(Border.ALL, BorderLineStyle.THIN);
}
else {
cellFont = new WritableFont(WritableFont.TIMES, 12);
cellFont.setColour(Colour.BLACK);
cellFormat = new WritableCellFormat(cellFont);
cellFormat.setBorder(Border.ALL, BorderLineStyle.THIN);
cellFormat.setWrap(true);
}
Label labTemp = new Label(iColumnNumber, iRowNumber, strData,
cellFormat);
try {
wshTemp.addCell(labTemp);
} catch (Exception e) {
e.printStackTrace();
}
}
public void closeFile() {
try {
// write the value in work book
wwbCopy.write();
// wwbCopy.close();
// Closing the original work book
wbook.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}