Excel insert rows (not Add)

前端 未结 3 1026
盖世英雄少女心
盖世英雄少女心 2020-12-11 20:05

I have an Excel \'07 Template file for a purchase order. On the template, there\'s only room for 3 rows worth of items, then the template shows the Total.

So, basica

3条回答
  •  感情败类
    2020-12-11 20:57

    I didn't see Sid Holland's post until after my lunch break, where a co-worker sent me this code that does basically the same thing as his...

        private void CopyRowsDown(int startrow, int count, Excel.Range oRange, Excel.Worksheet oSheet)
        {
            oRange = oSheet.get_Range(String.Format("{0}:{0}", startrow), System.Type.Missing);
            oRange.Select();
            oRange.Copy();
            //oApp.Selection.Copy();
    
            oRange = oSheet.get_Range(String.Format("{0}:{1}", startrow + 1, startrow + count - 1), System.Type.Missing);
            oRange.Select();
            oRange.Insert(-4121);
            //oApp.Selection.Insert(-4121);
    
        }
    

    Worked perfectly, even when count is 1.

提交回复
热议问题