/// <summary> /// Set height of row in points (pixels with 72dpi) /// </summary> /// <param name="row">row instance which height is going to change</param> /// <param name="height">height of row in points (pixels with 72dpi)</param> /// <returns></returns> public static x.Row SetHeightInPoints(this x.Row row, double height) { if (row == null) { return(null); } var ws = row.ParentOfType <x.Worksheet>(); if (ws == null) { throw new InvalidDocumentStructureException(); } var sheetFormatProps = ws.SheetFormatProperties; if (sheetFormatProps == null) { sheetFormatProps = new x.SheetFormatProperties(); ws.Insert(sheetFormatProps).AfterOneOf(typeof(x.Dimension), typeof(x.SheetView)); } if (sheetFormatProps.DefaultRowHeight == null || !sheetFormatProps.DefaultRowHeight.HasValue) { sheetFormatProps.DefaultRowHeight = 18; } row.Height = height; row.CustomHeight = true; return(row); }
public static double GetHeight(this x.Row row) { var height = row.Height; if (height != null) { return(height.Value); } var ws = row.ParentOfType <x.Worksheet>(); if (ws == null) { throw new InvalidDocumentStructureException(); } var sheetFormatProps = ws.SheetFormatProperties; var result = sheetFormatProps?.DefaultRowHeight == null ? 18 : sheetFormatProps.DefaultRowHeight.Value * (72d / 96d); return(result); }