huangzengtian commented on issue #696:
URL: https://github.com/apache/fesod/issues/696#issuecomment-3845651269

   我也遇过这个问题,原因是业务方做表的时候从网页上复制的数据,会混入不可见字符(上面你提到的那些 \u0002 
那些)。当时用的注册全局转换器,使用正则表达式 \p{C} 处理就可以。  转换器代码如下:
   ```
   public class ZeroWidthCharCleanUpConverter implements Converter<String> {
   
       @Override
       public Class<?> supportJavaTypeKey() {
           return String.class;
       }
   
       @Override
       public CellDataTypeEnum supportExcelTypeKey() {
           return CellDataTypeEnum.STRING;
       }
   
       @Override
       public WriteCellData<?> convertToExcelData(String value,
                                                  ExcelContentProperty 
contentProperty,
                                                  GlobalConfiguration 
globalConfiguration) throws Exception {
           // 去除不可见字符
           return new WriteCellData<>(value.replaceAll("\\p{C}", ""));
       }
   
       @Override
       public String convertToJavaData(ReadCellData<?> cellData, 
ExcelContentProperty contentProperty,
                                       GlobalConfiguration globalConfiguration) 
{
           String value = cellData.getStringValue();
           if (value == null) {
               return null;
           }
   
           // 去除不可见字符
           return value.replaceAll("\\p{C}", "");
       }
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to