@@ -145,7 +145,11 @@ private static string RenderHtmlCore(JsonElement root, Dictionary<string, DataTa
145145 sb . AppendLine ( "<table>" ) ;
146146 foreach ( var rr in materialized )
147147 {
148- sb . Append ( "<tr>" ) ;
148+ // 应用设计器的行高设置
149+ var rowHeight = GetRowHeight ( root , rr . TemplateRow ) ;
150+ sb . Append ( "<tr" ) ;
151+ if ( rowHeight > 0 ) sb . Append ( $ " style='height:{ rowHeight } px'") ;
152+ sb . Append ( ">" ) ;
149153 var used = new HashSet < int > ( ) ;
150154 for ( int ci = 0 ; ci < maxCols ; ci ++ )
151155 {
@@ -159,6 +163,7 @@ private static string RenderHtmlCore(JsonElement root, Dictionary<string, DataTa
159163 if ( rr . DataIndex != null ) rowspan = 1 ; // 数据扩展行不支持跨行合并
160164
161165 var style = hasCell ? "border:1px solid #ccc;" + ReadCellStyle ( cell ) : "border:1px solid #ccc;" ;
166+ if ( rowHeight > 0 ) style += $ "height:{ rowHeight } px;";
162167 if ( colspan > 1 ) sb . Append ( $ "<td colspan='{ colspan } ' style='{ style } '>") ;
163168 else sb . Append ( $ "<td style='{ style } '>") ;
164169 sb . Append ( value ) ;
@@ -368,6 +373,19 @@ private static string FormatNum(double d)
368373 private static int GetColCount ( JsonElement root )
369374 => root . TryGetProperty ( "cols" , out var colsEl ) && colsEl . ValueKind == JsonValueKind . Array ? colsEl . GetArrayLength ( ) : 0 ;
370375
376+ /// <summary>读取模板行的行高(px),无设置为 0。</summary>
377+ private static int GetRowHeight ( JsonElement root , int rowIndex )
378+ {
379+ if ( root . TryGetProperty ( "rows" , out var rowsEl ) && rowsEl . ValueKind == JsonValueKind . Array
380+ && rowIndex >= 0 && rowIndex < rowsEl . GetArrayLength ( ) )
381+ {
382+ var rowEl = rowsEl [ rowIndex ] ;
383+ if ( rowEl . TryGetProperty ( "height" , out var he ) && he . ValueKind == JsonValueKind . Number )
384+ return Math . Max ( 0 , he . GetInt32 ( ) ) ;
385+ }
386+ return 0 ;
387+ }
388+
371389 private static int GetInt ( JsonElement el , string prop , int def )
372390 => el . TryGetProperty ( prop , out var v ) ? Math . Max ( 1 , v . GetInt32 ( ) ) : def ;
373391
@@ -418,6 +436,9 @@ private static byte[] ExportExcelCore(JsonElement root, Dictionary<string, DataT
418436 int outRow = 0 ;
419437 foreach ( var rr in materialized )
420438 {
439+ // 应用设计器的行高设置
440+ var rowHeight = GetRowHeight ( root , rr . TemplateRow ) ;
441+ if ( rowHeight > 0 ) ws . Row ( outRow + 1 ) . Height = rowHeight ;
421442 var used = new HashSet < int > ( ) ;
422443 for ( int ci = 0 ; ci < maxCols ; ci ++ )
423444 {
0 commit comments