回复 3楼dxhshitc的帖子
仅就取隐藏行后的索引问题,可以通过以下方法处理:
把隐藏行索引通过 public 变量传到前台,再判断前台的当前单元格是否为受到隐藏行影响的单元格。进而取得正确的公式索引:
前台代码:
- <script language="javascript" type="text/javascript" id="FpSpread1_Script0">
- function FpSpread1_ActiveCellChanged(event){
- //Add code to handle your event here.
- var ss;
- if (document.all) {
- // IE
- ss = this.document.getElementById("FpSpread1");
- var ac = ss.ActiveCol;
- var ar = ss.ActiveRow;
- }
- var hiddenrowindex=<%=hiddenRowIndex %>;
- var rowindex1;
- if (hiddenrowindex!=0&&ar==hiddenrowindex-1) {
- rowindex1 = hiddenrowindex;
- }
- else {
- rowindex1 = ss.GetSheetRowIndex(ar + 1);
- }
- var colindex1 = ss.GetSheetColIndex(ac);
- var CoordonneColx = String.fromCharCode(parseInt(colindex1) + 97).toUpperCase();
- var coordonnee = CoordonneColx + rowindex1;
- }
- </script>
复制代码
后台代码:
- public partial class WebForm1 : System.Web.UI.Page
- {
- public int hiddenRowIndex;
- protected void Page_Load(object sender, EventArgs e)
- {
- if (IsPostBack)
- {
- return;
- }
- this.FpSpread1.Sheets[0].Rows.Count = 10;
- this.FpSpread1.Sheets[0].Cells[0, 0].Value = 1;
- this.FpSpread1.Sheets[0].Cells[1, 0].Value = 1;
- this.FpSpread1.Sheets[0].Cells[2, 0].Formula= "A1+A2";
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- this.FpSpread1.Sheets[0].Rows[3].Visible = false;
- hiddenRowIndex = 3;
- }
- }
复制代码 |