public static String createSafeSheetName(final String nameProposal, char replaceChar) {if (nameProposal == null) {return "null";}if (nameProposal.length() < 1) {return "empty";}final int length = Math.min(31, nameProposal.length());final String shortenname = nameProposal.substring(0, length);final StringBuilder result = new StringBuilder(shortenname);for (int i=0; i<length; i++) {char ch = result.charAt(i);switch (ch) {case '\u0000':case '\u0003':case ':':case '/':case '\\':case '?':case '*':case ']':case '[':result.setCharAt(i, replaceChar);break;case '\'':if (i==0 || i==length-1) {result.setCharAt(i, replaceChar);}break;default:}}return result.toString();}

public static String CreateSafeSheetName(String nameProposal, char replaceChar) {if (nameProposal == null) {return "null";}if (nameProposal.Length < 1) {return "empty";}int length = Math.Min(31, nameProposal.Length);String shortenname = nameProposal.Substring(0, length);StringBuilder result = new StringBuilder(shortenname);for (int i=0; i<length; i++) {char ch = result[(i)];switch (ch) {case '\u0000':case '\u0003':case ':':case '/':case '\\':case '?':case '*':case ']':case '[':result[i] = replaceChar;break;case '\'':if (i==0 || i==length-1) {result[i] = replaceChar;}break;default:break;}}return result.ToString();}
