Green World

반응형

엑셀 자동 셀병합 poi

자바






public static List<int[]> getMergeRegionList(String[][] datas) {


 List<int[]> mergeList = new ArrayList<int[]>();


 //가로행 탐색


 for (int r = 0; r < datas.length; r++) {


 String preVal = null;


 int mergeRow = r;


 int[] mergeCol = new int[datas[r].length];


 int mergeRowSize = 1;


 int[] mergeColSize = new int[datas[r].length];


 int countMerge = 0;


 for (int c = 0; c < datas[r].length; c++) {


  String currVal = (datas[r][c] == null) ? "" : datas[r][c];


  if (currVal.equals(preVal)) {


   mergeColSize[countMerge]++;


   preVal = currVal;


   if (c == datas[r].length - 1) {


   if (mergeColSize[countMerge] > 1) {


       int[] e = { mergeRow, mergeRowSize,


        mergeCol[countMerge],


        mergeColSize[countMerge] };


       countMerge++;


       mergeList.add(e);


       System.out.println("ggggggggggereeeeeeeeeee0zzA"


        + e[0] + "" + e[1] + "" + e[2] + "" + e[3]);


   }


   preVal = null;


   break;


   }










반응형