Reputation: 556
I'm trying to merge more then 255 cells using java code but there is error. Maximum column number is 255 so how can i merge more then 255 cell in XLS using java??
public class CellMerge {
public static void main(String[] args) throws IOException {
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("Java Books");
sheet.addMergedRegion(new CellRangeAddress(2, 10, 6, 300));
try (FileOutputStream outputStream = new FileOutputStream("/home/blackpearl/Downloads/newfilesss.xls")) {
workbook.write(outputStream);
System.out.println("good");
}
}
}
Error is
Exception in thread "main" java.lang.IllegalArgumentException: Maximum column number is 255
at org.apache.poi.ss.util.CellRangeAddressBase.validateColumn(CellRangeAddressBase.java:72)
at org.apache.poi.ss.util.CellRangeAddressBase.validate(CellRangeAddressBase.java:54)
at org.apache.poi.hssf.usermodel.HSSFSheet.addMergedRegion(HSSFSheet.java:641)
at com.converting.CellMerge.main(CellMerge.java:28)
Thank You
Upvotes: 1
Views: 608
Reputation: 406
It is not possible because there is limitations of XLS file for merging the 255 cells. But if you want your output in XLS then you can use multile sheet in a one workbook. and divide your data in 250-250 cells. then you can easily show your data to clients in XLS. Thank You
Upvotes: 1