回复 9楼moonlight108的帖子
1 设置列宽自适应,用SizeToFit函数试试:
- <SCRIPT language=javascript>
- function FitSpread()
- {
- var s=document.getElementById("FpSpread1″);
- if(document.all)
- s.SizeToFit(s.ActiveCol);
- else
- s.SizeToFit(s.GetActiveCol());
- }
- </SCRIPT>
复制代码
用法参考:Spread for ASP.NET 7.0 Product Documentation > Client-Side Scripting Reference > Scripting Members > Methods > SizeToFit
2 高度
没有办法直接获得列头的文字高度而去设置文字的宽度,有类似的办法:
- var spread = FpSpread1;
-         var span = FpSpread1.all("FpSpread1_colHeader");
-         var table = span.firstChild;
-         var tr = table.rows(0);
-         var tc;
-  
-         if(spread!=null)
-             {
-            //resize the spread control (take off page heading and left part of page)
-         spread.style.height = document.body.clientHeight – spread.offsetTop – 180;
-       spread.style.width = document.body.clientWidth – 220;
-           
-           //resize columns
-           var w = spread.offsetWidth – 20;
-             //go through all the columns
-           for (var i=0;i<spread.GetColCount();i++)
-                 {
-                //set column width
-                tc = tr.cells(i)
-                 spread.setColWidth(i,tc.innerText.length*10);
-                }
-            }
复制代码 |