Created attachment 32798 [details] HSSF/XSSFSheet ColumnWidth VBA Compatible Methods Patch POI's set/getColumnWidth is not compatible EXCEL VBA. It is returned EXCEL internal column width value. I added or modified in HSSF/XSSFSheet below methods for getting the VBA compatible column width value. - set/getStandardWidthInChars (VBA's StandardWidth) - set/getColumnWidthInChars (VBA's ColumnWidth) - getColumnWidthInPoints (VBA's Width) - getColumnWidthInPixels These methods require the Standard Font's '0' character's width (px). So I added ColumnWidthUtil.getStandardCharWidthInPixels(font). This method is supported below major fonts. - Calibri - Arial - Arial Unicode MS - Century - Georgia - Verdana - MS Reference Sans Serif - Times New Roman - Symbol - MS Gothic - MS Mincho - MS PGothic - MS PMincho - MS UI Gothic - MingLiU - MingLiU_HKSCS - MingLiU_HKSCS-ExtB - MingLiU-ExtB - Mongolian Baiti - NSimSun - Palatino Linotype - SimHei - SimSun - SimSun-ExtB - Sylfaen - Meiryo - Meiryo UI I tested various conditions. But I'm not completely solve. below methods still exist small remainders. Although it is enough in most cases. - XSSFSheet#getStandardWidthInChars (error rate is less than 1/1000) - XSSFSheet#getColumnWidthInChars (error rate is less than 1/1000) - setStandardWidthInChars (error rate is less than 1/10) - setColumnWidthInChars (error rate is less than 1/10)
According to the description below the patch is not in a state to be applied directly.