Fixed 'excel sheet already exists' error

Signed-off-by: Viktoria Dlugopolskaya <viksnsk@gmail.com>
diff --git a/runtime/org.eclipse.rcptt.ecl.data.apache.poi.impl/src/org/eclipse/rcptt/ecl/data/apache/poi/impl/internal/commands/WriteExcelFileService.java b/runtime/org.eclipse.rcptt.ecl.data.apache.poi.impl/src/org/eclipse/rcptt/ecl/data/apache/poi/impl/internal/commands/WriteExcelFileService.java
index 06e775a..88e3f4e 100644
--- a/runtime/org.eclipse.rcptt.ecl.data.apache.poi.impl/src/org/eclipse/rcptt/ecl/data/apache/poi/impl/internal/commands/WriteExcelFileService.java
+++ b/runtime/org.eclipse.rcptt.ecl.data.apache.poi.impl/src/org/eclipse/rcptt/ecl/data/apache/poi/impl/internal/commands/WriteExcelFileService.java
@@ -30,6 +30,7 @@
 public class WriteExcelFileService implements ICommandService {
 
 	private static final String SHEET_NAME_PATTERN = "Sheet%d";
+	private static final int SHEET_NAME_MAX_LENGTH = 31;
 
 	public IStatus service(Command command, IProcess context) throws InterruptedException, CoreException {
 		WriteExcelFile wef = (WriteExcelFile) command;
@@ -54,6 +55,10 @@
 			if (sheetName == null || sheetName.equals("")) {
 				sheetName = String.format(SHEET_NAME_PATTERN, sheetnum);
 			}
+			// sheet name has max length value, so we have to check it
+			if (sheetName.length() > SHEET_NAME_MAX_LENGTH) {
+				sheetName = sheetName.substring(0, SHEET_NAME_MAX_LENGTH);
+			}
 			Sheet sheet = book.getSheet(sheetName);
 			boolean newSheet = false;
 			if (sheet == null) {