Java to merge cells and export excel examples
introduce
POI provides APIs for Java programs to read and write files in Microsoft Office format. The document formats that POI can operate include excel, word, PowerPoint, etc. the hssfsheet object is required for cross line poi. Now, when our program has defined an hssfsheet object sheet.
The operation across the 1st to 2nd cells in row 1 is
The operation across the first cell in row 1 to the first cell in Row 2 is
Key precautions:
1. Cell and row object subscripts start from 0.
2. When merging cells, the row number of the first value of region (1,2,3,4) must be smaller than the row number at position 3. If it is greater than 3, cells cannot be merged normally
3. When merging cells, the single cell to be merged must be created first, so that it is convenient to obtain this cell again later to fill in data, mainly because it cannot be merged backward and forward.
Sample code
summary
The above is the whole content of this article. I hope the content of this article can bring some help to your study or work. If you have any questions, you can leave a message. Thank you for your support for programming tips.