Workaround: Set the row height of the cell, based on the cell content length
public static float Getexcelcellautoheight (string strtest, float fontcountinline) { float defaultrowheight = 18.00f;//the height of each row specifies float defaultcount = 0.00f; for (int i = 0; I <strtest. Length; i++) { float ff = Getregex (strtest. Substring (i, 1)); Defaultcount = Defaultcount + ff; } return ((int) (defaultcount/fontcountinline) + 1) * defaultrowheight;//calculation }
public static float Getregex (string charstr) { if (charstr = = "") { return 0.5f; } Determines whether the letter or the character if (Regex.IsMatch (Charstr, "^[a-za-z0-9]+$")) { return 0.5f; } Determine if full-width if (Regex.IsMatch (Charstr, "[\u4e00-\u9fa5]+$")) { return 1.00f; } Full-width symbol and Chinese if (Regex.IsMatch (Charstr, "[^x00-xff]")) { return 1.00f; } return 0.5f; }
Excel.Range Range = Ews.get_range ("C" + (+ indexrow *), "H" + + + Indexrow * 10);
Range. RowHeight = getexcelcellautoheight (Prostagename + "", 36f);
C # resolves Excel cell merge, row height is not adaptive problem