zoukankan      html  css  js  c++  java
  • C# NPOI Excel 合并单元格和取消单元格

    1、合并单元操作

      //合并单元格
      /**
        第一个参数:从第几行开始合并
        第二个参数:到第几行结束合并
        第三个参数:从第几列开始合并
        第四个参数:到第几列结束合并
    **/
     CellRangeAddress region = new CellRangeAddress(15, 15 , 1, 2);
     sheet.AddMergedRegion(region);

    2、取消单元格

     private void RemoveMergedRegion(ISheet sheet,int rowIndex)
            {
                int MergedCount = sheet.NumMergedRegions;
                for (int i = MergedCount - 1; i >= 0; i--)
                {
    /**
    CellRangeAddress对象属性有:FirstColumn,FirstRow,LastColumn,LastRow 进行操作 取消合并单元格
    **/               
     var temp = sheet.GetMergedRegion(i);
                    if (temp.FirstRow == rowIndex)
                    {
                        sheet.RemoveMergedRegion(i);
                    }
                }
            }

  • 相关阅读:
    前缀和
    hdu6290奢侈的旅行
    make_pair
    New Year and Buggy Bot
    STL next_permutation 算法原理和自行实现
    前端面试题集合
    node设置cookie
    黑客与geek
    xss
    node async
  • 原文地址:https://www.cnblogs.com/zoro-zero/p/10867972.html
Copyright © 2011-2022 走看看